Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disable "x" button?
#1
How can I disable the "x" close button from a window? This will be on a window that is already created! Is it possible? Anyway to disable the "x"?

Tried finding a style to set in msdn and use SetWinStyle but can't seem to find anything.
Found this C++ code, can you convert?

Macro Macro2
Code:
Copy      Help
HMENU hMenuHandle;
long lngItemCount;
int c, style;

hMenuHandle = GetSystemMenu(hWnd, false);
lngItemCount = GetMenuItemCount(hMenuHandle);

style = GetWindowLong(hWnd, GWL_STYLE);
style &= ~WS_MAXIMIZEBOX;
SetWindowLong(hWnd, GWL_STYLE, style);

c = lngItemCount;
while(c > lngItemCount - 4)
RemoveMenu(hMenuHandle, c--, MF_BYPOSITION | MF_DISABLED);

DrawMenuBar(hWnd);;As you can see this code will go in your window procedure under WM_CREATE. Just as a reminder, some systems have things added to the "standard" system menu so you will need to find a way of allowing for that.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)