September 11th, 2026
0 reactions

How can I remove the Close button from my window caption?

Occasionally, somebody wants to create a window without a Close button.

The only way to get rid of the Close button is not to have a System menu at all: Remove the WS_SYS­MENU style from the window. But that also gets rid of the Minimize and Maximize buttons, so it’s kind of drastic.

If you want a System menu, or if you want Minimize and Maximize buttons, you can at least disable the Close button by disabling the SC_CLOSE menu item.

HMENU menu = GetSystemMenu(hwnd, FALSE);
EnableMenuItem(menu, SC_CLOSE, MF_DISABLED);

Of course, you could use the nuclear option and implement your own custom title bar. Then you can do whatever you want. But most people are probably not willing to take things to such an extreme.

But really, try not to hide or disable the Close the button at all. End users don’t like it. It makes them feel trapped.

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

6 comments

Discussion is closed. Login to edit/delete existing comments.

Sort by :
  • AlomWare.com

    > try not to hide or disable the Close the button at all. End users don’t like it.

    It depends both on what your app does, and if it’s for public release or in-house.

  • Joshua Hudson

    I am very much surprised that GetSystemMenu followed by RemoveMenu doesn't remove it.

    I've had a case or two for this awhile back in .NET where an uninterruptible server operation was running; and opted for a window that had no menu nor title bar. It would have been nice to allow the user to minimize the application during that time. Oh well.

    Server operation would tend to take about two minutes; transaction handling was normal but cancelling the transaction from the client side was not possible by any means due to a fundamental deficiency of the Windows API itself involving pipes to...

    Read more
  • Michael Dietrich · Edited

    You could handle WM_NCCALCSIZE and extend the client area into the non-client area. That way you can let DWM just draw the caption buttons on the right like normal but the left part (icon, title) stays empty and you only need to draw the window caption text yourself in the right location. That seems to me to be the easiest way to get rid of the caption icon but leaving the rest in place.
    You should know that the system menu is tied to the caption icon, so if you still want the system menu to work, you need to...

    Read more