Home All Groups Group Topic Archive Search About

Minimizing the Console Window

Author
13 Oct 2006 5:29 PM
Abelard
How do I programmatically minimize the console window in a VB .NET console
application?

Author
13 Oct 2006 5:38 PM
Spam Catcher
=?Utf-8?B?QWJlbGFyZA==?= <Abel***@discussions.microsoft.com> wrote in
news:F6E21274-9538-469A-967F-8963275DCA2D@microsoft.com:

> How do I programmatically minimize the console window in a VB .NET
> console application?

I don't think you can - since it's not a window.
Author
13 Oct 2006 5:56 PM
Abelard
It is a window and can be minimized manually by clicking the minimize box. 
The question is how to programmatically minimize it.

Show quoteHide quote
"Spam Catcher" wrote:

> =?Utf-8?B?QWJlbGFyZA==?= <Abel***@discussions.microsoft.com> wrote in
> news:F6E21274-9538-469A-967F-8963275DCA2D@microsoft.com:
>
> > How do I programmatically minimize the console window in a VB .NET
> > console application?
>
> I don't think you can - since it's not a window.
>

>
>
Author
13 Oct 2006 6:54 PM
Miro
I think you would have to do this through the process of the "console
window" that holds ur dos app.

take a look at this link:
http://www.thescripts.com/forum/thread382333.html

Miro

Show quoteHide quote
"Abelard" <Abel***@discussions.microsoft.com> wrote in message
news:80D2D829-1DD9-4E63-9CEA-3F63A50845DF@microsoft.com...
> It is a window and can be minimized manually by clicking the minimize box.
> The question is how to programmatically minimize it.
>
> "Spam Catcher" wrote:
>
>> =?Utf-8?B?QWJlbGFyZA==?= <Abel***@discussions.microsoft.com> wrote in
>> news:F6E21274-9538-469A-967F-8963275DCA2D@microsoft.com:
>>
>> > How do I programmatically minimize the console window in a VB .NET
>> > console application?
>>
>> I don't think you can - since it's not a window.
>>
>>
>>
>>
Author
13 Oct 2006 9:10 PM
Abelard
Show quote Hide quote
"Miro" wrote:

> I think you would have to do this through the process of the "console
> window" that holds ur dos app.
>
> take a look at this link:
> http://www.thescripts.com/forum/thread382333.html
>
> Miro
>
> "Abelard" <Abel***@discussions.microsoft.com> wrote in message
> news:80D2D829-1DD9-4E63-9CEA-3F63A50845DF@microsoft.com...
> > It is a window and can be minimized manually by clicking the minimize box.
> > The question is how to programmatically minimize it.
> >
> > "Spam Catcher" wrote:
> >
> >> =?Utf-8?B?QWJlbGFyZA==?= <Abel***@discussions.microsoft.com> wrote in
> >> news:F6E21274-9538-469A-967F-8963275DCA2D@microsoft.com:
> >>
> >> > How do I programmatically minimize the console window in a VB .NET
> >> > console application?
> >>
> >> I don't think you can - since it's not a window.
> >>
> >>
> >>
> >>
>
>
>
Author
13 Oct 2006 9:14 PM
Abelard
Thanks to all of yoh for your input.  The link below had exactly the answer I
needed.  The console is a true window.  You have to do a call to this
function with all the correct parameters to control its behavior:

Imports System.Diagnostics

  Private Declare Function ShowWindow Lib "user32.dll" ( _
    ByVal hWnd As IntPtr, _
    ByVal nCmdShow As SHOW_WINDOW _
    ) As Boolean

The link Miro sent has the rest of the details.  It's very nice code and a
generally
useful function.

Show quoteHide quote
"Miro" wrote:

> I think you would have to do this through the process of the "console
> window" that holds ur dos app.
>
> take a look at this link:
> http://www.thescripts.com/forum/thread382333.html
>
> Miro
>
> "Abelard" <Abel***@discussions.microsoft.com> wrote in message
> news:80D2D829-1DD9-4E63-9CEA-3F63A50845DF@microsoft.com...
> > It is a window and can be minimized manually by clicking the minimize box.
> > The question is how to programmatically minimize it.
> >
> > "Spam Catcher" wrote:
> >
> >> =?Utf-8?B?QWJlbGFyZA==?= <Abel***@discussions.microsoft.com> wrote in
> >> news:F6E21274-9538-469A-967F-8963275DCA2D@microsoft.com:
> >>
> >> > How do I programmatically minimize the console window in a VB .NET
> >> > console application?
> >>
> >> I don't think you can - since it's not a window.
> >>
> >>
> >>
> >>
>
>
>
Author
13 Oct 2006 7:14 PM
Spam Catcher
=?Utf-8?B?QWJlbGFyZA==?= <Abel***@discussions.microsoft.com> wrote in
news:80D2D829-1DD9-4E63-9CEA-3F63A50845DF@microsoft.com:

> It is a window and can be minimized manually by clicking the minimize
> box.  The question is how to programmatically minimize it.

It maybe look like a Window but it is merely a container for the console
application. Unlike Winforms application console apps do not have direct
control over their windows.

You'll have to use Win32 API calls to minimize the Window:

http://www.pinvoke.net/default.aspx/user32/ShowWindow.html
Author
13 Oct 2006 7:17 PM
zacks
Abelard wrote:
> It is a window and can be minimized manually by clicking the minimize box.
> The question is how to programmatically minimize it.

The problem is that the way you do it programatically in a Windows
Application project is by setting the Me.WindowState to Minimized. But
the WindowState property is defined in the System.Windows.Forms class
and a Console Application window is not a member of the
Systems.Windows.Forms class. To make things even worse, there is no
Console.WindowState property.

Now, I happen to agree with you, a console window is essentially a
Command Prompt window that is running a specific piece of code. And you
can minimize a Command Prompt (and a Console App) window by clicking on
the minimize button, so there should be some way to do it
programmatically, but I haven't found it. Maybe there is an API call to
do it? (Since .NET I try to avoid API calls whenever possible.)

Show quoteHide quote
>
> "Spam Catcher" wrote:
>
> > =?Utf-8?B?QWJlbGFyZA==?= <Abel***@discussions.microsoft.com> wrote in
> > news:F6E21274-9538-469A-967F-8963275DCA2D@microsoft.com:
> >
> > > How do I programmatically minimize the console window in a VB .NET
> > > console application?
> >
> > I don't think you can - since it's not a window.
> >
> > 
> >
> >