Search code examples
cwinapiwindowmodemaximize-window

Prevent exiting maximized window mode


I'm writing window managing code in C. When certain flags are set, I want to have a maximized window that cannot be resized by dragging the window by the title bar. Is there a way to 'lock' a maximized window in its maximized state?


Solution

  • Try this

    case WM_SYSCOMMAND:
        if(IsMaximized(hwnd) && ((wParam & 0xFFF0) == SC_RESTORE || (wParam & 0xFFF0) == SC_MOVE)){
            return 0;
        }
    
        break;
    

    Edit

    The complete code

    switch(message){ //handle the messages
        ...
        ...
        case WM_SYSCOMMAND:
            ...
            break;
        ....
        default:   //for messages that we don't deal with
            return DefWindowProc(hwnd, message, wParam, lParam);
    }
    
    return DefWindowProc(hwnd, message, wParam, lParam);
    

    This is the default WindowProcedure. I thought it was known.

    valter