Microsoft KB Archive/173261

= FIX: Dialog in InitInstance Doesn't Process WM_DDE_INITIATE =

Article ID: 173261

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 2.2

 Microsoft Visual C++ 4.0 Standard Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul>

 Microsoft Visual C++ 4.2 Enterprise Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q173261

<div class="symptoms_section">

SYMPTOMS
When you try to start an application that contains a modal dialog function, such as CDialog::DoModal, AfxMessageBox, or MessageBox, that is called from the CWinApp derived class' InitInstance function by double-clicking on the application from the Windows 95 Explorer, selecting the saved document from the Start Menu or double-clicking on it from File Manager, one of the following may happen:

 It may work fine if built with Visual C 2.x running under Windows NT 3.5x and later. -or-

</li> The dialog or message box may come up, but the application's main window may not come up, and the process is now hung, and can only be terminated by PVIEW. -or-

</li> The following error message box may be displayed:

Cannot find the file <path\filename> (or one of its components). Make sure the path and filename are correct and that all required libraries are available.

And, symptom number 2 may also occur.</li></ul>

<div class="cause_section">

CAUSE
When you launch an application in File Manager or Windows Explorer, a WM_DDE_INITIATE is supposed to be handled by the CWinApp and CFrameWnd OnDDEIntitiate handlers. A call to CDialog::DoModal, AfxMessageBox, or MessageBox interferes with the ability for the MFC framework to handle these messages correctly.

<div class="resolution_section">

RESOLUTION
It has been determined that this behavior is by design and that it is not recommended to place any of these calls within the CWinApp::InitInstance. Any password dialogs or dialog based components which need to be displayed in the InitInstance should be of the modeless type. This does not apply to a dialog based application or an SDI application.

<div class="status_section">

STATUS
This problem was corrected in Visual C++ version 6.0.

<div class="moreinformation_section">

Steps to Reproduce Behavior

 * 1) Create an AppWizard Multiple Document Application, specifying a file extension to associate with the application.
 * 2) Call a modal dialog function such as CDialog::DoModal, AfxMessageBox, or MessageBox from the CWinApp derived class' InitInstance function.
 * 3) Run the application, dismiss the dialog or message box, and save the document.
 * 4) Start the application by:


 * 1) Double-clicking the application from the Windows 95 Explorer. -or-


 * 1) Selecting the saved document from the Start Menu -or-


 * 1) Double-clicking the application from File Manager.

<div class="references_section">