Original Post
I recently modified some code in my Win32 engine to implement the handling of modal loops (specifically, so my apps can render while the window is being dragged). I added these lines to my WinProc function:
However, I've noticed a couple of problems with this code.
The first problem is something that no one would probably notice during any kind of normal gameplay, but it bugs me anyway. When I click on the icon on the upper left hand corner of my window's title bar, the system menu (or Windows menu, or whatever) pops up. I can click on any of the items in this menu just fine, but if I press the Esc key to dismiss the menu, my program gets stuck in a modal loop and doesn't exit until I click on the window or otherwise give it focus. To add to the confusion, this bug does not occur if I right-click on the window's title bar, then press Esc. I'm guessing there are probably some messages somewhere that I should be processing.
The second problem I noticed is mainly just an aesthetic thing, but it makes me think I might be doing something wrong somewhere. I've noticed that if I bring up one of the aforementioned menus and my menu animation behavior is set to "fade," then the menu tends to flicker as it fades in. This problem is intermittent, and seems dependent on how many CPU cycles my program is taking up.
I guess I probably should be asking these questions in separate threads, but I guess they're somewhat related, and I just typed this all up anyway. :)
Any help would be much appreciated.
-- ProgrammerZ
switch (message){ // snipped case WM_ENTERSIZEMOVE: case WM_ENTERMENULOOP: { ModalLoop = true; // entering a modal loop SetTimer(hWnd, 0, (1000/60), NULL); } break; case WM_EXITSIZEMOVE: case WM_EXITMENULOOP: case WM_CAPTURECHANGED: { ModalLoop = false; // exiting a modal loop KillTimer(hWnd, 0); } break; case WM_TIMER: { if (m_bInModalLoop) { RenderStuff(); } } break;}However, I've noticed a couple of problems with this code.
The first problem is something that no one would probably notice during any kind of normal gameplay, but it bugs me anyway. When I click on the icon on the upper left hand corner of my window's title bar, the system menu (or Windows menu, or whatever) pops up. I can click on any of the items in this menu just fine, but if I press the Esc key to dismiss the menu, my program gets stuck in a modal loop and doesn't exit until I click on the window or otherwise give it focus. To add to the confusion, this bug does not occur if I right-click on the window's title bar, then press Esc. I'm guessing there are probably some messages somewhere that I should be processing.
The second problem I noticed is mainly just an aesthetic thing, but it makes me think I might be doing something wrong somewhere. I've noticed that if I bring up one of the aforementioned menus and my menu animation behavior is set to "fade," then the menu tends to flicker as it fades in. This problem is intermittent, and seems dependent on how many CPU cycles my program is taking up.
I guess I probably should be asking these questions in separate threads, but I guess they're somewhat related, and I just typed this all up anyway. :)
Any help would be much appreciated.
-- ProgrammerZ