473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 7863
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tai | last post by:
Hi all I have 2 forms, frmMain and frmChild. In frmMain, I declare a variable f as frmChid then Call f.ShowDialog() I want when the child form is minimized, the Main form is also minimized...
2
by: Tai | last post by:
Hi all I have 2 forms, frmMain and frmChild. In frmMain, I declare a variable f as frmChid then Call f.ShowDialog() I want when the child form is minimized, the Main form is also minimized...
1
by: Tai | last post by:
Hi all I have 2 forms, frmMain and frmChild. In frmMain, I declare a variable f as frmChid then Call f.ShowDialog() I want when the child form is minimized, the Main form is also minimized...
0
by: Ole Hanson | last post by:
Hi What's the best way of activating a sleeping process on my local machine? I have an application (.exe) minimized to a notifyicon in the tasktray. Now - if the user clicks the exe-file again...
5
by: Adda | last post by:
In a Parent mdi form I have a datagrid. I select a record from the grid and then invoke a childmdi form. I add the childmdi to an arraylist to keep track of it. If a user has selected multiple...
5
by: vooose | last post by:
Consider a Form with dimension Size=(300,300) that is then minimized. Subsequent calls to Size return (160,24). The Form is then restored and Size returns (300,300) Is there any property or...
6
by: kowndinya | last post by:
Hello All, How to activate my restore button when my (program) window/form is in minimized state through code at a particular time only. I have a timer control on my from. Can i use showwindow...
6
by: =?Utf-8?B?QWxsZW4=?= | last post by:
When minimizing Visual Basic application, working memory is greatly reduced from about 20 MB to only about 2 MB. However I want the application to start as minimized, and most of the time it will...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
using WinXp (SP3), VB2005. sometimes when a user opens the app - the app opens in minimized WindowState and clicking on the app's icon in the windows taskbar wont open the app to Normal...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.