Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Custom WM_NCPAINT processing breaks maximized window

I'm trying to remove native Windows frame of window, and to achieve this, I created custom processing for bunch of non-client window messages, among which there is WM_NCPAINT.

So, the problem is, when I had replaced default processing of WM_NCPAINT by custom one, I faced with maximized window issue: it moved to 8 pixels left and up, and it size increased on 8 pixels in each dimension.

I'm tried to fix the issue by setting appropriate position and dimension in WM_GETMINMAXINFO processing. But here I found out, that window changes it position in maximized state only if I set ptMaxPosition more than (0,0) or ptMaxSize less then rcWork from MONITORINFO structure. If I set ptMaxSize equals to rcWork (which I need as a final result), window ignore this setting and still on 8 pixels spills out on second screen.

So, what I'm wondering about is how I need to handle WM_NCPAINT message, without passing it into DefWindowProc and also, why window reset it's dimensions to default in WM_GETMINMAXINFO proccessing unless I'm set size less than work area.

WM_GETMINMAXINFO processing:

LRESULT SkinWindow::OnGetMinMaxInfo(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
    MINMAXINFO *lpMMI = (MINMAXINFO *)lParam;

    MONITORINFO monitorInfo = GetMonitorInfo(hWnd);   // my custom function
    .
    .
    .
    lpMMI->ptMaxPosition.x = 0; 
    lpMMI->ptMaxPosition.y = 0; 

    lpMMI->ptMaxSize.x = monitorInfo.rcWork.right - monitorInfo.rcWork.left;
    lpMMI->ptMaxSize.y = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top; 

    lpMMI->ptMaxTrackSize.x = GetSystemMetrics(SM_CXVIRTUALSCREEN);  
    lpMMI->ptMaxTrackSize.y = GetSystemMetrics(SM_CYVIRTUALSCREEN);

     return 0;
}

WM_NCPAINT proccessing irrelevant, because there I just getting window device context and drawing in it.

P.S. I'm already found visual solution for that bug in apllying SetWindowRegion to work area while window maximizing and to NULL while restored. But it comes on the surface, when I took screenshot of maximized window, because window size is still 1928x1048 instead of needed 1920x1040

Comments