C# winforms application: event handler when returning (focus) from an external application -


i have winforms application has perform action every time when returning external application (i.e. focus has been lost application, alt-tabbing program , back).

is there application event handler this?

i have looked activate , deactive handlers of form, these handlers fired when form receives focus (when closing messagebox or closing subform).

windows sends wm_activateapp message window when being activated, , when being deactivated. want handle, when wparam true (indicating activation).

winforms not wrap event (at least not i'm aware of), you'll need add code form's window procedure manually:

public class myform : form {     // other code      protected override void wndproc(ref message m)     {         const int wm_activateapp = 0x001c;         switch (m.msg)         {             case wm_activateapp:             {                 if (m.wparam.toint32() != 0)                 {                     // application's window being activated,                     // whatever want. or raise event.                     ...                 }                 break;             }         }         base.wndproc(ref m);  // proceed default processing     } } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -