Problem
Meet 2 weird issue in a simple MFC Dialog based Windows CE application:
1. MFC’s single instance mechanism seemed don’t work (My dialog based app won’t quit, it just hide and wait for activated when user try to run it again) , a new instance always come up.
2. Click "today/start" menu item, the today screen don’t show up, instead it show my dialog app’s UI.
3. Smart menu remain to be my dialog app’s smart menu when today’s screen is displayed.
Solution
Read the MFC code, it does have single instance check by create a mutex, however it seemed that if I hide the app’s main window by ShowWindow(SW_HIDE), EnumWindow() will not able to find the previous window handle, so MFC think there is no previous window to activate and it run a new instance. I change to ShowWindow(SW_MINIMIZE), the problem 1 was fixed.
For problem 2, 3, eventually I found the solution from here: http://www.pocketpcdn.com/articles/today_friendly_dialogs.html
Question
I have created a dialog based application. It works ok. But when I click Today item in Start menu my program is shown instead of Today screen. How can I fix it?
Answer
This is because Today application is like a desktop on PC. When a dialog has no parent a Today window is considered as a parent window. This behaviour is necessary to get access to popup messages. For example when message about low battery is shown and you switch to another application. The onl way to access this popup message window is to call Today program. But such behaviour is not necessary for windows that could be accessible from menu.
To fix it you should change dialog’s WS_POPUP style to WS_OVERLAPPED.