apostrophe27
asked on
Debug assertion after closing a modal dialog
I have a dialog where I'm overriding the WM_LBUTTONDBLCLK event. When the event happens, I go to a function that launches a modal dialog box. After I close the dialog box, I get a debug assertion when the program exits the PreTranslateMessage function.
If I call the LaunchEditWindow function from a button click, there is no assertion.
If I call the LaunchEditWindow function from a button click, there is no assertion.
BOOL CDlgPinOverview::PreTranslateMessage( LPMSG pMsg )
{
if(m_hAccel)
{
if(::TranslateAccelerator(m_hWnd, m_hAccel, pMsg))
return(TRUE);
}
if (pMsg->message ==WM_LBUTTONDBLCLK )
{
LaunchEditWindow();
}
return CDialog::PreTranslateMessage(pMsg);
}
void CDlgPinOverview::LaunchEditWindow(void)
{
CEditDlg pPinEdit;
pPinEdit.DoModal();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I've just been having a look at this and actually both comments aren't correct. Both just provide a workaround.
What you could do is use PostMessage to post a custom message to your dialog and in response to that you run your LaunchEditWindow function.
The following article shows you how to create and respond to custom messages:
https://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/A_3827-Sudoku-a-complete-MFC-application-Part-7.html