Reputation: 5784
I have an MFC application running in Win7 with no Titlebar (i.e. My title bar is home-cooked, with custom buttons for restore, maximize and close). In Win7 it responds to the maximize event generated by the Win 7 API when a user drags the window to the top of the screen. However, once it's maximized, I can't capture the restore event that occurs when a user drags the window off the top.
I handle the restore on double click, I handle the restore on a click of the restore button, but the drag I can't detect.
I would imagine that it would look similar to:
if (message == WM_WINDOWPOSCHANGING)
{
// DETECT RESTORE MSG HERE.
}
But that doesn't seem to catch it. It's as if somewhere I've disabled moving the window when it's been maximized.
Is there a way perhaps that I'm preventing the WM_RESIZE? How do I handle the drag event to enable the auto-resize?
Upvotes: 2
Views: 1226
Reputation: 1754
Have you tried handling the WM_NCHITTEST message returning HTCAPTION (titlebar) when the mouse is over your custom title bar thus allowing normal windows processing to occur without any further customization?
Upvotes: 1
Reputation: 5784
I discovered that since the app doesn't have a Titlebar, win7 doesn't handle the window drag and therefore doesn't send the WM_SYSCOMMAND at all. In other words, the application was blocking the Titlebar drag because there was no Titlebar to drag.
The solution is in part to detect a drag on our mocked up titlebar. After that the window must be restored in SIZE only, not in position. The position needs to be dynamic to the cursor, just like Win7 does it. Thoughts, people?
Upvotes: 0