Flashing form
-
Is there a way to make a Form flashing in c#. First idea is to use a timer changing form color. Is there a more elegant way? Thanks for your time
-
Is there a way to make a Form flashing in c#. First idea is to use a timer changing form color. Is there a more elegant way? Thanks for your time
Why not just call FlashWindowEx[^]?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Is there a way to make a Form flashing in c#. First idea is to use a timer changing form color. Is there a more elegant way? Thanks for your time
Hi, PozzaVecia, There are two main reasons you might want to make a Form/Window flash: one is to indicate an error message, or something urgently requiring the user's attention. In that case you want to bring the Form to the front, to make sure it's visible. The usual practice, in that case, is to put up a modal Form/Window, which will automatically appear as the frontmost window, and block your application. You can define a Form, with whatever you want on it, and use FormX.ShowDialog() to display it modally. In many cases, however, the built-in MessageBox facility is all you need to use. Both these objects will automatically become the frontmost window when they are shown. The second case is when you want to indicate to the end-user that you want them to bring a Form to the front, that's not in front now. But, it's hard for me to see a real reason for doing that: 1. if the Window is covered over by other Windows, the user won't see it change color, or Flash. Using FlashWindowEx will not make the Window the active window, and bring it frontmost, although the Window will appear to have changed status visually, from inactive to active. MSDN docs for 'FlashWindowEx: "It does not change the active state of the window." "When a window flashes, it appears to change from inactive to active status. An inactive caption bar changes to an active caption bar; an active caption bar changes to an inactive caption bar." In summary: 1. yes, you can make a Window flash, either by using the FlashWindowEx api that Dave K. referred you to, or by writing code, as you mentioned, using a Timer. 2. imho, you should use a modal Form/Window whenever you absolutely must get the end-user's attention, are willing to block the application, and require a response from the user. 3. in most cases, the built-in modal MessageBox facility will give you, for "free," a choice of buttons, default action button, icon, etc.
DialogResult result = MessageBox.Show("Core Melt Down Imminent" ,"Chernobyl Emergency Alert !",MessageBoxButtons.AbortRetryIgnore,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button3);
switch (result.ToString())
{
case "Ignore":
MessageBox.Show("Ignorance is life as usual.");
break;
case "Abort":
MessageBox.Show("To abort is impossible, sorry.");
break;
case "Retry":
MessageBox.Show("Trying again is a waste of time."); -
Hi, PozzaVecia, There are two main reasons you might want to make a Form/Window flash: one is to indicate an error message, or something urgently requiring the user's attention. In that case you want to bring the Form to the front, to make sure it's visible. The usual practice, in that case, is to put up a modal Form/Window, which will automatically appear as the frontmost window, and block your application. You can define a Form, with whatever you want on it, and use FormX.ShowDialog() to display it modally. In many cases, however, the built-in MessageBox facility is all you need to use. Both these objects will automatically become the frontmost window when they are shown. The second case is when you want to indicate to the end-user that you want them to bring a Form to the front, that's not in front now. But, it's hard for me to see a real reason for doing that: 1. if the Window is covered over by other Windows, the user won't see it change color, or Flash. Using FlashWindowEx will not make the Window the active window, and bring it frontmost, although the Window will appear to have changed status visually, from inactive to active. MSDN docs for 'FlashWindowEx: "It does not change the active state of the window." "When a window flashes, it appears to change from inactive to active status. An inactive caption bar changes to an active caption bar; an active caption bar changes to an inactive caption bar." In summary: 1. yes, you can make a Window flash, either by using the FlashWindowEx api that Dave K. referred you to, or by writing code, as you mentioned, using a Timer. 2. imho, you should use a modal Form/Window whenever you absolutely must get the end-user's attention, are willing to block the application, and require a response from the user. 3. in most cases, the built-in modal MessageBox facility will give you, for "free," a choice of buttons, default action button, icon, etc.
DialogResult result = MessageBox.Show("Core Melt Down Imminent" ,"Chernobyl Emergency Alert !",MessageBoxButtons.AbortRetryIgnore,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button3);
switch (result.ToString())
{
case "Ignore":
MessageBox.Show("Ignorance is life as usual.");
break;
case "Abort":
MessageBox.Show("To abort is impossible, sorry.");
break;
case "Retry":
MessageBox.Show("Trying again is a waste of time.");very very useful!!! thanks a lot