468,532 Members | 1,704 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,532 developers. It's quick & easy.

Activate minimized form

I have a Windows form application that I generally run minimized. When a
critical event occurs it instantiates another "Alert" form which I want to
grab the user focus.

In the Alert constructor I call both this.Show() and this.Activate(), but if
the parent application is minimized then the Alert form will also stay
minimized (and just flash).

How can I cause the Alert form to show itself and grab focus?
Jan 18 '06 #1
2 7568
Try changing the WindowState property of the form to Normal or Maximized.

Dave
Jan 18 '06 #2
Hi,
Welcome to MSDN Newsgroup!

There are strict rules around when an application can actually activate and
steal focus from whatever the user is currently doing. Besides interrupting
the user's workflow, it can cause serious problems if say a user is
currently typing in a password into a text box, stealing focus is not the
right thing to do.

See the remarks section of SetForegroundWindow
http://msdn.microsoft.com/library/de...us/winui/winui
/windowsuserinterface/windowing/windows/windowreference/windowfunctions/setf
oregroundwindow.asp

The other behavior you are describing (parent application being
minimized/alert form staying minimized) sounds like somehow your alert form
is owned by the parent form? When a window is owned by another window it
will tend to stay in front of the owner window and minimize when the owner
window minimizes.
http://msdn.microsoft.com/library/de...us/dnwui/html/
msdn_styles32.asp

You might consider a notify icon application instead with a toaster window
that pops up alerts when critical things happen.
http://www.windowsforms.net/articles...lications.aspx

Toaster window sample in here
http://www.windowsforms.net/Samples/...mId=198&tabind
ex=4

I hope the above information is helpful for you. If you have any questions,
please feel free to let me know. Thanks and have a nice day!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
Thread-Topic: Activate minimized form
thread-index: AcYcay4cFRynwxb9Q/CKSlIjy9Mp8w==
X-WBNR-Posting-Host: 208.252.38.111
From: "=?Utf-8?B?RGF2ZSBCb29rZXI=?=" <db******@newsgroup.nospam>
Subject: Activate minimized form
Date: Wed, 18 Jan 2006 12:10:08 -0800
Lines: 9
Message-ID: <5C**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.csharp:379514
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

I have a Windows form application that I generally run minimized. When a
critical event occurs it instantiates another "Alert" form which I want to
grab the user focus.

In the Alert constructor I call both this.Show() and this.Activate(), but ifthe parent application is minimized then the Alert form will also stay
minimized (and just flash).

How can I cause the Alert form to show itself and grab focus?


Jan 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ole Hanson | last post: by
5 posts views Thread by vooose | last post: by
6 posts views Thread by =?Utf-8?B?QWxsZW4=?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.