Does anyone know how to disable the X button at the top of the screen so the user cannot exit the program through that route?
Does anyone know how to disable the X button at the top of the screen so the user cannot exit the program through that route?
Code:case WM_CLOSE: if (MessageBox(hwnd,_T("sure?"),_T("Quit"),MB_YESNO|MB_APPLMODAL)==IDYES) { DestroyWindow(hwnd); } return 0;
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
I often see: _T("some string"). Is this because of UNICODE?.Originally Posted by Ken Fitlike
If it is why not using TEXT("some string")??
_T does the same thing as TEXT if I remember correctly and I think people use _T because it's shorter.
You can also add CS_NOCLOSE to the class style when you register the window class (with RegisterClassEx).
Hey anon, I tried doing it for my dialog box, but it wont work
Code:IDD_CHANNEL_TIME DIALOG 0, 0, 400, 200 STYLE DS_SYSMODAL | DS_MODALFRAME |WS_POPUP| WS_VISIBLE | WS_CAPTION | WS_MINIMIZEBOX|WS_SYSMENU|CS_NOCLOSE CAPTION "Channels" LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL FONT 8, "MS Sans Serif"
Last edited by osal; 08-12-2004 at 04:50 PM.
CS_NOCLOSE is a class style. You can specify it in the WNDCLASSEX structure when you register a window class.
Since you don't register a class for dialog boxes, you won't be able to use CS_NOCLOSE.Code:WNDCLASSEX wc = { 0 }; wc.style = CS_NOCLOSE; ... RegisterClassEx(&wc);
What can i use for a dialog box then?
nevermind, i got it!
here's the code:
Code:hMenu = GetSystemMenu(hwnd, FALSE); EnableMenuItem (hMenu , SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
Here is one easy..
WM_CLOSE:
break;
lol.. works for me
Yeah But i wanted the close button to be grayed out when the program is doing something, and then when it is done enabled once again.