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.
Printable View
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.
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.
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
@rxbagain:
thank you for the link to the other thread.
There I can recommend the solution with the accelerator key from Gabriel Fleseriu.