Is there an easy way to detect when a .NET application gains or loses focus?
The events you are looking for are Form.Activated and Form. Deactivated
I was curious how this method would work under various conditions in an MDI application. It turns out that this will not work in all situations.
MDI-, MDI / , MDI , / ( ). , ( ), MDI / ( , / , , ). , , , / MDI, , / , .
, , / MDI, , ( ShowDialog).
:
this.LostFocus
this.GotFocus
In the parent form / window itself
For WPF, FocusChanged in the window. Winforms should have a similar event. You can find out using intellisense in Visual Studio.
Activated / deactivated seems to be standard though.
In winforms he is Activated
Handle the Control.GotFocus and Control.LostFocus events for the main window.
Source: https://habr.com/ru/post/1709100/More articles:What is a good platform for devoloping web services in C ++? - c ++AS3- Is it possible to call a variable from a string? - actionscript-3Migration from Vinarma to Jagarti - gccAJAX & ASP.net, links to server controls in an external file - javascriptвернуть общий тип из общей функции - javamemory mapped files in C - chow to handle constantly changing ad template code for a site in version control - version-controlDisconnect and reconnect the connected datagram connector - posixWinForms - Does the DoubleBuffered format control affect this form? - c #WCF and Fluent NHibernate: How Can I Keep Clean Classes? - nhibernateAll Articles