Remove a window's title context menu, but leaving everything else intact


The only way I found to remove the title context menu of a window is this:

SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);

Where WS_SYSMENU is something like 0x80000.

But this also hides the window’s close button, which I don’t want.

There is a workaround which I’ve not yet tried. I can probably override right click on the window, and also override the ALT+Space (or ALT+Up) key combinations. I’m using WPF.

More specifically I want a window, that looks like this:

  1. Has no icon in the title bar
  2. Has no context menu
  3. Has no maximize button (not just disabled)
  4. Has a minimize button

The first I can achieve with this

The third and forth point cannot be done at the same time. So instead I chose to hide the minimize and the maximize button, and use the close button and tray icon solution. (Clicking the close button won’t close the app, but minimize it to tray icon.)

The only remaining is the second point. Is there an easy solution for that? I don’t want to create a completely custom window, and I don’t particularly like the workaround I mentioned.


The answer is: this is not possible.

Answered By – Ádám Bozzay

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published