Search code examples
winapibuttonhidetaskbar

How to hide the windows 10 taskbar close button using WINAPI?


I need to find a way to remove this button:

Taskbar close button

I already tried to put the CS_NOCLOSE flag into the WNDCLASS, but this is not working.

  WNDCLASS    wc;
  wc.style         = CS_OWNDC | CS_NOCLOSE;
  wc.lpfnWndProc   = (WNDPROC)staticWindowProc;
  wc.cbClsExtra    = 0;
  wc.cbWndExtra    = 0;

I also have this code inside the callback:

case WM_INITMENU:
  EnableMenuItem((HMENU)wParam, SC_CLOSE, MF_BYCOMMAND | MF_DISABLED); 
  break

Solution

  • I didn't find a way to disable the close button but I have hidden my window from the taskbar as explained here https://msdn.microsoft.com/en-us/library/windows/desktop/cc144179(v=vs.85).aspx#tbnotify_Taskbar_Display_Options (section Managing Taskbar Buttons)) using the WS_EX_TOOLWINDOW flag.

    Thx for help