Article ID: 172336 - Last Review: June 3, 2005 - Revision: 3.0 An assertion is hit in the Afxwin2.inl file when you try to launch an MFC MDI application through a documentThis article was previously published under Q172336 SYMPTOMS When launching an MFC MDI application through a document
from Explorer, an assertion is hit in the Afxwin2.inl file. This assertion only
occurs if the application contains the Tip of the Day and Splash Screen
components from the Component Gallery. CAUSE When an application is launched by opening its document,
MFC delays showing the main frame window. This delay is enough to cause the Tip
of the Day modal dialog box to be parented off the modeless Splash Screen
dialog box instead of the main frame. When the timer expires for the Splash
Screen, it destroys itself and its children including the Tip of the Day dialog
box. MFC still tries to process messages for that dialog box, thereby causing
the assertion. RESOLUTION Delay showing the Tip of the Day dialog until after the
Splash Screen destroys itself. STATUS This behavior is by design. MORE INFORMATION When an MFC application is normally launched (from the .exe
file), the default behavior is to create the MDI Main frame window and to show
it at the end of InitInstance(). When a splash screen is inserted from the
component gallery, the Splash Screen modeless dialog box is displayed during
CMDIFrameWnd::LoadFrame() which is called before the main window is shown. When
the Tip of the Day component is inserted, its modal dialog box is shown after
the main window is shown. A modal dialog box by default uses the last activated
popup window as returned from ::GetLastActivePopup() as its parent. The code in
CWnd::GetSafeOwner() which is called by CDialog::PreModal() uses the main
window as the parameter to GetLastActivePopup() thereby returning the main
window because it was the most recently active. As a result, the Tip of the Day
dialog box is parented off the main window. For example: Because the Splash Screen kills itself by using a timer, it takes the tip of the day dialog box with it. This causes an assertion in line 35 (or line 39 in Visual C versions 5.0 and 6.0) in the CWnd::SendMessage() inline function in the Afxwin2.inl file. This is because MFC is still running its RunModalLoop() and is trying to send a message to an invalid hWnd. One workaround is to remove the call to ShowTipAtStartup() from InitInstance() and to simply display the Tip of the Day dialog box after the Splash Screen is destroyed. For example: APPLIES TO
| Article Translations
|
Back to the top
