Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
AnswerRe: c# Thumbnail Viewer Pin
BillWoodruff17-May-13 20:42
professionalBillWoodruff17-May-13 20:42 
GeneralRe: c# Thumbnail Viewer Pin
Dinesh Salunke18-May-13 5:44
Dinesh Salunke18-May-13 5:44 
GeneralRe: c# Thumbnail Viewer Pin
Dave Kreskowiak18-May-13 7:46
mveDave Kreskowiak18-May-13 7:46 
GeneralRe: c# Thumbnail Viewer Pin
BillWoodruff19-May-13 2:05
professionalBillWoodruff19-May-13 2:05 
GeneralRe: c# Thumbnail Viewer Pin
Dinesh Salunke19-May-13 4:16
Dinesh Salunke19-May-13 4:16 
QuestionFlashing form Pin
PozzaVecia17-May-13 12:28
PozzaVecia17-May-13 12:28 
AnswerRe: Flashing form Pin
Dave Kreskowiak17-May-13 17:34
mveDave Kreskowiak17-May-13 17:34 
AnswerRe: Flashing form Pin
BillWoodruff17-May-13 20:17
professionalBillWoodruff17-May-13 20:17 
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.
C#
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.");
        break;
}
There are some articles here on CP that may be useful to you: [^].

yours, Bill
“Humans are amphibians: half spirit, half animal; as spirits they belong to the eternal world; as animals they inhabit time. While their spirit can be directed to an eternal object, their bodies, passions, and imagination are in continual change, for to be in time, means to change. Their nearest approach to constancy is undulation: repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis


modified 18-May-13 10:10am.

GeneralRe: Flashing form Pin
PozzaVecia17-May-13 22:01
PozzaVecia17-May-13 22:01 
QuestionTimestamp Value in SQLServer Pin
abhi_here17-May-13 8:13
abhi_here17-May-13 8:13 
AnswerRe: Timestamp Value in SQLServer Pin
PIEBALDconsult17-May-13 8:43
mvePIEBALDconsult17-May-13 8:43 
AnswerRe: Timestamp Value in SQLServer Pin
abhi_here29-May-13 4:34
abhi_here29-May-13 4:34 
AnswerRe: Timestamp Value in SQLServer Pin
jschell17-May-13 10:32
jschell17-May-13 10:32 
GeneralRe: Timestamp Value in SQLServer Pin
PIEBALDconsult17-May-13 11:04
mvePIEBALDconsult17-May-13 11:04 
QuestionDifferent behaviour from button in MDI parent and button in child form Pin
FRotondo17-May-13 4:09
FRotondo17-May-13 4:09 
AnswerRe: Different behaviour from button in MDI parent and button in child form Pin
Simon_Whale17-May-13 10:21
Simon_Whale17-May-13 10:21 
GeneralRe: Different behaviour from button in MDI parent and button in child form Pin
FRotondo17-May-13 22:12
FRotondo17-May-13 22:12 
QuestionExtract XML values using XpathNavigator Pin
baranils17-May-13 1:03
baranils17-May-13 1:03 
AnswerRe: Extract XML values using XpathNavigator Pin
PIEBALDconsult17-May-13 4:39
mvePIEBALDconsult17-May-13 4:39 
GeneralRe: Extract XML values using XpathNavigator Pin
baranils17-May-13 4:56
baranils17-May-13 4:56 
AnswerRe: Extract XML values using XpathNavigator Pin
Abhinav S17-May-13 19:08
Abhinav S17-May-13 19:08 
AnswerRe: Extract XML values using XpathNavigator Pin
Alan Balkany20-May-13 11:32
Alan Balkany20-May-13 11:32 
QuestionA question on WCF Pin
Dewald17-May-13 0:56
Dewald17-May-13 0:56 
AnswerRe: A question on WCF Pin
Richard MacCutchan17-May-13 1:06
mveRichard MacCutchan17-May-13 1:06 
GeneralRe: A question on WCF Pin
Dewald17-May-13 2:35
Dewald17-May-13 2:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.