I need a way to be notified when my application is activated (through Alt-Tab task switching, clicking its icon on the taskbar, etc.) in order to display a reload “file” dialog box.
I tried MainForm.Activated but this event is called whenever I close an application modal dialog.
Ideally, what I would like is something akin to the Application.Activated event found in WPF, but that I can use from a WinForms application.
TheActivatedandDeactivateevents seem to work fine for me. When you tab away,Deactivateis called. When you tab too the form,Activatedis called:Just found the solution from here
Then inside OnActivateApp, activate will be true if the Application is activated, and false if deactivated.