![]() |
|
Smart Minimize button on Pocket PC 2002
By Vassili Philippov, May 08, 2001.
SummaryPocket PC 2002 introduces a new feature - Smart Minimize button. This article describes working with this button - its behavior, button removing and handling. BackgroundThe Smart Minimize (X) button is shown by default for all windows that do not contain OK button. This button does not close the application but minimizes it (puts behind the desktop/today window). It is not recommended to remove this button or change its behavior. There are a lot of questions (more than 100 for the last 3 months) in the developer newsgroups about Smart Minimize button. Most people ask:
Remove the Smart Minimize buttonFirst of all I want to say that it is not recommended to remove the Smart Minimize button except some special cases (wizards, question modal dialogs, etc). Nevertheless if you are sure what you do you can remove the Smart Minimize button by adding WS_NONAVDONEBUTTON to the window's style. Read more detailed about how to do it in eVC++ in our QA: How to remove smart minimize (X) button from the taskbar? Here is code for eVB that removes the Smart Minimize button (it adds WS_NONAVDONEBUTTON to the style): Handle event when the the Smart Minimize button is pressed?As in the previous section first of all I want to say that it is not recommended to change behavior of the Smart Minimize button because users do not expect it. But in contrast to the previous question when it was unrecommended but documented this feature (handling smart minimize button) is undocumented and there is not good way to handle it. Many Pocket PC developers were confused by What's New for Developers in the Pocket PC 2002 article (it is already removed from MSDN). It was written: The application gets a notification when the new smart minimize is clicked. The application can then either close or just ignore the click. It seems that he was wrong. No notification is sent when the Smart Minimize button is pressed and it is not impossible to ignore the click. Here is the log of messages sent to the main application window when the Smart Minimize button is pressed:
and the log when just another application is started:
As you see there is no unique message designed for Smart Minimize button. It can be possible to find a pattern of messages that are sent when the Smart Minimize button is pressed and only in that situation. But all such solutions are tricks and we cannot be 100% sure they will always work. Here are two known tricks to handle pressing of the Smart Minimize button. WM_WINDOWPOSCHANGEDIt seems that WM_WINDOWPOSCHANGED message with the desktop window (DesktopExplorerWindow class) as a hwndInsertAfter parameter is sent only when the Smart Minimize button is pressed. So you can handle it in your WindowProc like: Unfortunately our window is already minimized to the moment we handle this message. It is OK if we want to terminate our application but it is not acceptable if we want to ask a question. Surely we can return our window foreground using SetForeground function but it will flicker in that case. WM_SIZE:It seems that WM_SIZE message with SIZE_MINIMIZED parameter is sent only when the Smart Minimize button is pressed. So you can handle it in your WindowProc like: Unfortunately this message is also sent after the window is already minimized and flickering effect seems to be even more than when handle WM_WINDOWPOSCHANGED message. Smart Minimize sometimes does not work for dialog-based applicationsSome people find that Smart Minimize button does not work for MFC dialog-based application with removed OK button. It looks like you press the Smart Minimize button, it disappears but your dialog-based application is still here.
It is a new appearance of the good know "Today" bug of MFC dialog-based applications.
Your dialog is shown instead of Today window. And when your application is just over Today
window and you press Smart Minimize button the Today window is shown but because of this
bug you see your dialog instead of the Today window. Read how to fix it: ConclusionFirst of all do not change default behavior if you are not sure you really need it. But it is possible to remove the Smart Minimize button from your application using WS_NONAVDONEBUTTON style. There is not special message sent to notify application that the Smart Minimize button is pressed. Nevertheless you can catch this event using some tricks. Related resources:DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||