Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 712
  • Last Modified:

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.

 
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();

}

Open in new window

0
apostrophe27
Asked:
apostrophe27
  • 2
1 Solution
 
AndyAinscowCommented:
I'm not certain exactly why this is happening but I guess it is because the button double click doesn't get processed properly before a new message loop (DoModal) is implemented.

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:
http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/A_3827-Sudoku-a-complete-MFC-application-Part-7.html
0
 
HooKooDooKuCommented:
After the call from LaunchEditWindow() returns inside of PreTranslateMessage, should you be returning a value of (TRUE) to indicate the message has been processed (like TranslateAccelerator() does) rather than dropping into the statement "return CDialog::PreTranslateMessage(pMsg);"?  Or do you really want the message to be processed again by the CDialog basecode?
0
 
AndyAinscowCommented:
I've just been having a look at this and actually both comments aren't correct.  Both just provide a workaround.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now