Help and Support
 

powered byLive Search

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

Article ID:166132
Last Review:November 21, 2006
Revision:3.1
This article was previously published under Q166132
On This Page

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.

Back to the top

Dialog or Property Page

Visual C++ 5.0:
   Warning: Dialog creation failed!
					
Visual C++ 6.0:
   If this dialog has OLE controls:
   AfxEnableControlContainer has not been called yet.
   You should call it in your app's InitInstance function.
					

Back to the top

CFormView

Visual C++ 5.0:
   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:
   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:
   Failed to create empty document.
					

Back to the top

CAUSE

The Rich Edit control is not initialized.

Back to the top

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.

Back to the top

STATUS

This behavior is by design.

Back to the top

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.

Back to the top

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

Back to the top


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
  Microsoft Visual C++, 32-bit Learning Edition 6.0

Back to the top

Keywords: 
kberrmsg kbtshoot kbrichedit kbuidesign kbprb kbdlg KB166132

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by E-mail, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.