I have an MDI app, which start as hidden, and an icon is shown in system tray. After a time (few seconds), from that system tray icon is show up a notification balloon. And when I click on this balloon, I call this code:
void CMainFrame::On0Restore()
{
// TODO: Add your command handler code here
ShowWindow(SW_RESTORE);
SetForegroundWindow();
SetActiveWindow();
}
But instead MDI app to be restore and activated, it is only restored, but not activated, and the taskbar icon is flashing several times:
The system tray icon has a right click menu, and this menu has Restore item. When user choose this system tray menu item, the MDI window is restored and activated correctly, this menu item also call CMainFrame::On0Restore. But when this CMaiFrame::On0Restore is called from balloon click, this code is run correctly. Why this simple code is not run as I expect every time ?
One important note: this issue is present ONLY if you run the app from Window Explorer, like in real situation. When you run this app from Visual Studio, everything is going alright.
I attach a sample project that illustrate the problem: https://1drv.ms/u/s!AtSPCxnvttzehDceOBTEmJ_Ll0T8?e=354DPT