How to handle the drag event on an enlarged window

advertisements

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?


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?