PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Maximise or show a window without giving it focus

Reply

Maximise or show a window without giving it focus

 
Thread Tools Rate Thread
Old 30-07-2003, 10:56 AM   #1
PaulR
Guest
 
Posts: n/a
Default Maximise or show a window without giving it focus


Hi,

Is there a way of maximising a form without having it
grab the window focus?

Thanks
  Reply With Quote
Old 31-07-2003, 12:27 PM   #2
Bob Powell [MVP]
Guest
 
Posts: n/a
Default Re: Maximise or show a window without giving it focus

You have to use interop. Import the ShowWindow method from user32 and call
the method with the SW_SHOWNOAVTIVATE constant.

[DllImport("User32.dll")]

public extern static int ShowWindow( System.IntPtr hWnd, short cmdShow);

[Flags()]

public enum ShowWindow

{

SW_HIDE = 0,

SW_SHOWNORMAL = 1,

SW_NORMAL = 1,

SW_SHOWMINIMIZED = 2,

SW_SHOWMAXIMIZED = 3,

SW_MAXIMIZE = 3,

SW_SHOWNOACTIVATE = 4,

SW_SHOW = 5,

SW_MINIMIZE = 6,

SW_SHOWMINNOACTIVE = 7,

SW_SHOWNA = 8,

SW_RESTORE = 9,

SW_SHOWDEFAULT = 10,

SW_FORCEMINIMIZE = 11,

SW_MAX = 11

}

The call below does the job

ShowWindow(myWindow.Handle,(short)ShowWindow.SW_SHOWNOACTIVATE);


--
Bob Powell [MVP]
C#, System.Drawing


Check out the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Buy quality Windows Forms tools
http://www.bobpowell.net/xray_tools.htm

New Tips and Tricks include creating transparent controls
and how to do double buffering.

"PaulR" <robinsonpr@aol.com> wrote in message
news:0a4c01c35680$c9317490$a401280a@phx.gbl...
> Hi,
>
> Is there a way of maximising a form without having it
> grab the window focus?
>
> Thanks



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off