Pressing ESC

LuNacHicK
LuNacHicK used Ask the Experts™
on
How can I prevent pressing ESC and the Windows key in order not to terminate my program.. any ideas?!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
I guess you are talking about dialog. Overriding PreTranstaleMessage solves the problem:

BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
    if( pMsg->message == WM_KEYDOWN )
    {
        if( pMsg->wParam == VK_ESCAPE )
        {
            ::TranslateMessage(pMsg);
            ::DispatchMessage(pMsg);
            return TRUE;
        }
    }
     
    return CDialog::PreTranslateMessage(pMsg);
}

Windows key doesn't terminate any program, what do you mean?

Author

Commented:
Hey thanks a lot!!!ÜÜ

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial