I have a custom-drawn skin for an app, that eliminates the caption/title bar. All of the menu items and system buttons are owner-drawn. Everything works as it should, except one little bug.
When the Maximize button is pressed, and the window maximizes, the code should also change the button bitmap, from the "Maximize" icon, to the "Restore" icon. Yet, I cannot get it to change. Here is the code that handles that button command:
case ID_MENUBAR_MAX: {
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hwnd, &wp);
mII.cbSize = sizeof(MENUITEMINFO);
mII.fMask = MIIM_BITMAP;
GetMenuItemInfo(hMenu, NUMMI+2, TRUE, &mII);
if (wp.showCmd == SW_SHOWNORMAL){ mII.hbmpItem = hMBB.restore; SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0); }
if (wp.showCmd == SW_SHOWMAXIMIZED){ mII.hbmpItem = hMBB.max; SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); }
SetMenuItemInfo(hMenu, NUMMI+2, TRUE, &mII);
DrawMenuBar(hwnd);
return 0;
}
As I mentioned, everything works as it should. When the button is pressed the window maximizes or normalizes, as it should. I just can't get the bitmap on the button to change along with it. What am I missing? It must be something simple.
See Question&Answers more detail:os