|
-
July 22nd, 2003, 02:43 AM
#1
No closing with Alt-F4
How can I avoid that the user closes the app by pressing Alt-F4 ?
I thought that I can detect the key stroke with OnSysCommand in CMainFrame, but that did not work.
-
July 22nd, 2003, 03:03 AM
#2
Try this out:
In your MainFrame.h file copy the following line of code
#define IsALTpressed() ( (GetKeyState(VK_MENU) & (1 << (sizeof(SHORT)*8-1))) != 0 )
Now in the "PreTranslateMessage" function of your MainFrame.cpp file include the following the following lines of code :
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if(IsALTpressed() && pMsg->wParam==VK_F4)
pMsg->wParam=VK_TAB;
return CFrameWnd::PreTranslateMessage(pMsg);
}
that's all.
-
July 22nd, 2003, 03:07 AM
#3
Take a look at how to not react for Alt-F4 thread. There are other threads regarding this matter. Try to look.
Hope it will help you
-
July 22nd, 2003, 04:18 AM
#4
@rxbagain:
thank you for the link to the other thread.
There I can recommend the solution with the accelerator key from Gabriel Fleseriu.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|