Microsoft KB Archive/166132

= You cannot create a dialog in Visual C++ if the dialog template has a Rich Edit control =

Article ID: 166132

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

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

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

-

<div class="notice_section">

This article was previously published under Q166132

<div class="notice_section">

<div class="symptoms_section">

SYMPTOMS
Dialog creation may fail if the dialog template has a Rich Edit control in it. This template may be used in a dialog, CformView, or property page.

The following error messages may appear in the IDE output window when you execute the program in the debugger with the debug build. No error message or warning is given if you execute the program outside the debugger or with the release build.

Dialog or Property Page
Visual C++ 5.0:

<pre class="fixed_text">  Warning: Dialog creation failed!

Visual C++ 6.0:

<pre class="fixed_text">  If this dialog has OLE controls: AfxEnableControlContainer has not been called yet. You should call it in your app's InitInstance function.

CFormView
Visual C++ 5.0:

<pre class="fixed_text">  Warning: Dialog creation failed! Warning: could not create view for frame. Failed to create client pane/view for frame. Warning: CDocTemplate couldn't create a frame.

Visual C++ 6.0:

<pre class="fixed_text">  If this dialog has OLE controls: AfxEnableControlContainer has not been called yet. You should call it in your app's InitInstance function.

In the case of a CformView, the following message also appears:

<pre class="fixed_text">  Failed to create empty document.

<div class="cause_section">

CAUSE
The Rich Edit control is not initialized.

<div class="resolution_section">

RESOLUTION
Call the MFC global function AfxInitRichEdit before you create the dialog to initialize the Rich Edit Control. A good place to initialize the Rich Edit control is in the application's InitInstance function before you create the dialog.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
With the new dialog editor in Visual C++ 5.0, it is possible to add a Rich Edit control into a dialog template by dragging the control from the control palette. However, doing this in the dialog editor does not ensure that the required Riched32.dll library will be loaded before the Rich Edit control is created. In Win32 SDK, it is necessary to call the LoadLibrary function to load Riched32.dll before the dialog creation. In MFC, the global function AfxInitRichEdit does this for you. All you need to do is call this function before you create the dialog.

Please use the online help to get more information on AfxInitRichEdit function.

Dialog Scenario
The follow scenario reproduces the problem described above with a dialog.

<ol> Create a new project as follows: File\New\Projects\MFC AppWizard(exe).</li> Create a Dialog based application, and then click Finish.</li> Add a Rich Edit control to the main dialog template in the dialog editor.</li> Build the application.</li> Press the F5 key to start the debugger. Notice that the application does not display the dialog.</li> Observe the following in the Output window in IDE:

<pre class="fixed_text">     ...      Warning: Dialog creation failed! ...

</li></ol>

CformView Scenario
The follow scenario reproduces the problem described above with a CFormView.

<ol> Create a new project as follows: File\New\Projects\MFC AppWizard(exe).</li> Create an SDI or MDI application and in step 6 of Appwizard select CFormview as the Base class for the view.</li> Add a Rich Edit control to the main dialog template for the formview in the dialog editor.</li> Build the application.</li> Press the F5 key to start the debugger. Notice that a message box appears indicating that the empty document could not be created.</li> Observe the following in the Output window in IDE:

<pre class="fixed_text">       ...      Warning: Dialog creation failed! Warning: could not create view for frame. Failed to create client pane/view for frame. Warning: CDocTemplate couldn't create a frame. ...

</li></ol>

Additional query words: CreatDialogIndirect DoModal RichEdit CFormView

Keywords: kbtshoot kbdlg kberrmsg kbprb kbrichedit kbuidesign KB166132

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.