ijkl
asked on
problem with modeless!...
hi!
my main application is a dialog based app.i created a modeless dialog box as below
BOOL CMDApp::InitInstance()
{
AfxEnableControlContainer( );
#ifdef _AFXDLL
Enable3Controls();
#else
Enable3ControlsStatic();
#endif
CMDDlg *dlg= new CMDDlg;
dlg->Create();
m_pMainWnd = dlg;
return TRUE;
}
i destroyed it using..
void CMDDlg::OnCancel()
{
CMDDlg::DestroyWindow();
}
now my problem is that when the user presses the ESC key the dialog box vanishes.i want the dialog box to stay.
how can modify this?..what is the reason for the dialog box to vanish even after overriding the OnCancel() function?
my main application is a dialog based app.i created a modeless dialog box as below
BOOL CMDApp::InitInstance()
{
AfxEnableControlContainer(
#ifdef _AFXDLL
Enable3Controls();
#else
Enable3ControlsStatic();
#endif
CMDDlg *dlg= new CMDDlg;
dlg->Create();
m_pMainWnd = dlg;
return TRUE;
}
i destroyed it using..
void CMDDlg::OnCancel()
{
CMDDlg::DestroyWindow();
}
now my problem is that when the user presses the ESC key the dialog box vanishes.i want the dialog box to stay.
how can modify this?..what is the reason for the dialog box to vanish even after overriding the OnCancel() function?
As you mentioned ESC invokes OnCancel.
Remove the DestroyWindow from OnCancel - leaving the handler blank.
Remove the DestroyWindow from OnCancel - leaving the handler blank.
If you remove the "CMDDlg::DestroyWindow();" from the code, then your dialog should not close when Esc is pressed.
You should use:
void CMDDlg::OnCancel()
{
}
to destroy it instead.
You should use:
void CMDDlg::OnCancel()
{
}
to destroy it instead.
Toad
I hate to ask this...but your answer differs from mine how?
I hate to ask this...but your answer differs from mine how?
As an alternative - if you wish **just** to disable the Escape key...
BOOL CTestDlg::PreTranslateMess age(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_ESCAPE)
{
return TRUE;
}
}
return CDialog::PreTranslateMessa ge(pMsg);
}
BOOL CTestDlg::PreTranslateMess
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_ESCAPE)
{
return TRUE;
}
}
return CDialog::PreTranslateMessa
}
ASKER
I tried to do that but it is givig the error as
'PreTranslateMessage' : overloaded member function 'int (struct tagMSG *)' not found in 'CTestDlg'
!
'PreTranslateMessage' : overloaded member function 'int (struct tagMSG *)' not found in 'CTestDlg'
!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the method given by Toad224 is not working for my purpose.
i want the dialog box to close when clicked cancel but stay when ESC is pressed!
thanx anyway..
i want the dialog box to close when clicked cancel but stay when ESC is pressed!
thanx anyway..
ASKER
Mt Mu thanx it is working now...i appreciate it..
ijkl..:-)
ijkl..:-)
ASKER
i already added a comment MT MU ...:-)
thanx..
ASKER