C++ MFC

Moderators: Lundin
Number of threads: 3354
Number of posts: 9032

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
capturing ESCAPE key Posted by pinkie on 3 Jul 2003 at 4:12 AM
how do i prevent the dialog box from closing when ESCAPE key is pressed?

can anybody help
pinkie
Report
Re: capturing ESCAPE key Posted by stober on 3 Jul 2003 at 4:46 AM
: how do i prevent the dialog box from closing when ESCAPE key is pressed?
:
: can anybody help
: pinkie
:
In the PreTranslateMessge() function. When the message is VK_ESCAPE just return TRUE. I put it in my project's CWinApp-derived class so that it will be disabled throughout the entire program, not just one specific view or dialog.
Report
Re: capturing ESCAPE key Posted by pinkie on 4 Jul 2003 at 5:03 AM
i tried as u suggested. The ESCAPE key is working as expected, but TAB is not working now. what do i do?


: : how do i prevent the dialog box from closing when ESCAPE key is pressed?
: :
: : can anybody help
: : pinkie
: :
: In the PreTranslateMessge() function. When the message is VK_ESCAPE just return TRUE. I put it in my project's CWinApp-derived class so that it will be disabled throughout the entire program, not just one specific view or dialog.
:

Report
Re: capturing ESCAPE key Posted by stober on 4 Jul 2003 at 6:09 AM
: i tried as u suggested. The ESCAPE key is working as expected, but TAB is not working now. what do i do?
:
:

post the OnTranslateMessage() function that you created. Disabling the ESC key should not have that side affect. That must be a different problem.
Report
Re: capturing ESCAPE key Posted by pinkie on 5 Jul 2003 at 4:04 AM
here it is


BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == VK_ESCAPE )
{
return TRUE;
}
else
{
return FALSE;// but TAB is not working
}

//return CDialog::PreTranslateMessage(pMsg);

}

Pl tell me is anything wrong with my code???



: : i tried as u suggested. The ESCAPE key is working as expected, but TAB is not working now. what do i do?
: :
: :
:
: post the OnTranslateMessage() function that you created. Disabling the ESC key should not have that side affect. That must be a different problem.
:

Report
Re: capturing ESCAPE key Posted by stober on 5 Jul 2003 at 8:20 AM
This message was edited by stober at 2003-7-5 8:36:16

: here it is
:
 
 BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
 {
 	if (pMsg->message == VK_ESCAPE )
 	{
 	    return TRUE;
 	}
delete the else statement!
// 	else
//         {
// 	     return FALSE;//  but TAB is not working
// 	}
      
UN-delete this next line!  
      return CDialog::PreTranslateMessage(pMsg);
 
 }

: Pl tell me is anything wrong with my code???
:
:
:
: : : i tried as u suggested. The ESCAPE key is working as expected, but TAB is not working now. what do i do?
: : :
: : :
: :
: : post the OnTranslateMessage() function that you created. Disabling the ESC key should not have that side affect. That must be a different problem.
: :
:
:



Report
Re: capturing ESCAPE key Posted by pinkie on 7 Jul 2003 at 4:38 AM
this is not working.dont know why?? have u tried?

: This message was edited by stober at 2003-7-5 8:36:16

: : here it is
: :
:
 
:  BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
:  {
:  	if (pMsg->message == VK_ESCAPE )
:  	{
:  	    return TRUE;
:  	}
: delete the else statement!
: // 	else
: //         {
: // 	     return FALSE;//  but TAB is not working
: // 	}
:       
: UN-delete this next line!  
:       return CDialog::PreTranslateMessage(pMsg);
:  
:  }
: 

: : Pl tell me is anything wrong with my code???
: :
: :
: :
: : : : i tried as u suggested. The ESCAPE key is working as expected, but TAB is not working now. what do i do?
: : : :
: : : :
: : :
: : : post the OnTranslateMessage() function that you created. Disabling the ESC key should not have that side affect. That must be a different problem.
: : :
: :
: :
:
:
:
:

Report
Re: capturing ESCAPE key Posted by stober on 7 Jul 2003 at 5:57 AM
: this is not working.dont know why?? have u tried?
:
BOOL CTest5Dlg::PreTranslateMessage(MSG* pMsg) 
{
	if(pMsg->message == WM_KEYDOWN)
	{
		if(pMsg->wParam == VK_ESCAPE)
			return TRUE;
	}
	return CDialog::PreTranslateMessage(pMsg);
}


Report
Re: capturing ESCAPE key Posted by weicco on 8 Jul 2003 at 1:02 AM
Another way to do this, but it will make life little harder on dialogs:

BOOL COwnApp::PreTranslateMessage(MSG* pMsg)
{
    if (pMsg->message == WM_KEYDOWN)
    {
        SendMessage(GetActiveWindow(), pMsg->message, pMsg->wParam, pMsg->lParam);
        return TRUE;
    }

    return CDialog::PreTranslateMessage(pMsg);
}


: : this is not working.dont know why?? have u tried?
: :
:
: BOOL CTest5Dlg::PreTranslateMessage(MSG* pMsg) 
: {
: 	if(pMsg->message == WM_KEYDOWN)
: 	{
: 		if(pMsg->wParam == VK_ESCAPE)
: 			return TRUE;
: 	}
: 	return CDialog::PreTranslateMessage(pMsg);
: }
: 

:
:

Report
Re: capturing ESCAPE key Posted by pinkie on 15 Jul 2003 at 9:24 PM
tnx it is working
pinkie

: : this is not working.dont know why?? have u tried?
: :
:
: BOOL CTest5Dlg::PreTranslateMessage(MSG* pMsg) 
: {
: 	if(pMsg->message == WM_KEYDOWN)
: 	{
: 		if(pMsg->wParam == VK_ESCAPE)
: 			return TRUE;
: 	}
: 	return CDialog::PreTranslateMessage(pMsg);
: }
: 

:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.