BUG: Find/Replace Assertions in an MDI MFC Application with CRichEditView-based Views (230377)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q230377 SYMPTOMS
When you use a Find/Replace dialog box in a multiple document interface (MDI) application with CRichEditView-based views, you may receive one of the following messages:
Debug Assertion Failed! Program: [Your.exe]. File: viewrich.cpp. Line: 1674.
User breakpoint called from code at [SomeAddress]. (CRichEditView::AssertValid() will be on the stack)
CAUSE
Dialog box ownership is established statically when the dialog box is created. The view that handles the initial ID_EDIT_FIND or ID_EDIT_REPLACE command becomes the owner of the dialog box. The owner is the window that receives FINDMSGSTRING notifications.
When a Find/Replace dialog box survives its owner, all subsequent notifications are directed to a nonexistent window. The application is not aware that the dialog has been dismissed, which results in the assertions.
RESOLUTIONWARNING: This resolution uses undocumented implementation features of the Microsoft Foundation Classes (MFC). Future versions of MFC may break programs that use this resolution.
To resolve this problem, you need to do two things:
- Override the OnActivateView method to update the dialog box owner dynamically whenever a CRichEditView view becomes active.
- Provide a WM_DESTROY handler to dismiss the dialog box.
See the sample code in the "More Information" section below for details.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 12/2/2003 |
---|
Keywords: | kbbug kbCmnDlg kbCmnDlgFind kbCmnDlgRepl kbpending kbRichEdit KB230377 |
---|
|