How to prevent WinForms from losing attention?

How to prevent my "Appearance" (without I / O, only the "OK" button) from losing focus, to make the user click "OK"? I tried checking and ErrorProvider. I also tried delegating Show, Activate, and Focus as follows:

AboutForm myAboutForm = new AboutForm(); myAboutForm.Deactivate += delegate { myAboutForm.Show(); myAboutForm.Activate(); }; myAboutForm.Show(); 

but nothing works.

+4
source share
5 answers

Make your modal form a dialog box.

 AboutForm myAboutForm = new AboutForm(); myAboutForm.ShowDialog(); 

From MSDN - ShowDialog :

Shows the form as a modal dialog box.

+10
source

You need to define your form of interruption as modal . Modal window (behind Wikipedia ):

In the design of the user interface, the modal window is a child window that requires users to interact with it before they can return to the parent application, thereby preventing the workflow from entering the main application window. Modal windows are often called heavy windows or modal dialogs, because a window is often used to display a dialog box.

For instance,

myAboutForm.ShowDialog(); instead of myAboutForm.Show(); So:

 AboutForm myAboutForm = new AboutForm(); myAboutForm.ShowDialog(); 

More details in MSDN when displaying modal and modeless windows ,

The modal form or dialog box must be closed or hidden before you can continue working with the rest of the application.

Finally, I'm not sure that Deactivate works the way you think on MSDN:

Occurs when a form loses focus and is no longer an active form.

and

You can use this event to perform tasks such as updating another window in your application with data from a deactivated form.

+2
source

Show the form as a modal dialog:

myAboutForm.ShowDialog();

+2
source

In windows, the desktop has the highest priority. You cannot block a user from accessing the desktop if your application is running. However, there are tricks to do this. You simply set the highest property of the form, so that the user will always see on top of all applications. ShowDialog will save your form on top of your application.

+1
source
 AboutForm myAboutForm = new AboutForm(); myAboutForm.ShowDialog(); 
0
source

All Articles