Search code examples
c++hwndwindow-handles

How to change console window style at runtime?


I'm making a game in console application and I want to prevent user resizing and maximizing window. How can I do this using HWND?


Solution

  • I found solution. This code will disable window Size and Maximize box:

    HWND consoleWindow = GetConsoleWindow();
    SetWindowLong(consoleWindow, GWL_STYLE, GetWindowLong(consoleWindow, GWL_STYLE) & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX);