PRB: Dialog With RichEdit May Fail During Creation

Last reviewed: March 2, 1998
Article ID: Q166132
The information in this article applies to:
  • The Microsoft Foundation Classes (MFC) included with: - Microsoft Visual C++, 32-bit Editions, version 5.0

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:

   Warning: Dialog creation failed!

CFormView:

   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.

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

   Failed to create empty document.

CAUSE

The Rich Edit control is not initialized.

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.

STATUS

This behavior is by design.

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.

Steps to Reproduce Behavior

Dialog Scenario:

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

  1. Create a new project as follows: File\New\Projects\MFC AppWizard(exe).

  2. Create a Dialog based application, and then click Finish.

  3. Add a Rich Edit control to the main dialog template in the dialog editor.

  4. Build the application.

  5. Press the F5 key to start the debugger. Notice that the application does not display the dialog.

  6. Observe the following in the Output window in IDE:

          ...
          Warning: Dialog creation failed!
          ...
    

CformView Scenario:

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

  1. Create a new project as follows: File\New\Projects\MFC AppWizard(exe).

  2. Create a SDI or MDI application and in step 6 of Appwizard select CFormview as the Base class for the view.

  3. Add a Rich Edit control to the main dialog template for the formview in the dialog editor.

  4. Build the application.

  5. Press the F5 key to start the debugger. Notice that a message box appears indicating that the empty document could not be created.

  6. Observe the following in the Output window in IDE:

            ...
          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.
            ...
    


Additional query words: CreatDialogIndirect DoModal RichEdit CFormView
Keywords : MfcUI kberrmsg kbui kbfasttip
Technology : kbmfc
Version : 5.0
Platform : NT WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.