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.

5 comments

Sort by :
  • Joshua Hudson 14 hours ago

    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 1 day ago · 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
  • Yexuan Xiao · Edited

    Is there a way to create a window without a titlebar icon? As far as I know, apart from fully customizing the titlebar, there is no way to hide the icon without also hiding the title and the system menu. I was writing a small tool earlier and didn’t plan to design an icon for it, so it could only display the default icon, but it was meaningless.

  • liamgraham 2 days ago

    well then Raymond, I shall trap the end users in my application

    “You can use task manager ya know”

    “Dammit.”