PRB: Error C2039: OnInitDialog is Not a Member of CFormView

Last reviewed: July 10, 1997
Article ID: Q132675
1.00 1.50 1.51 1.52 | 2.00 2.10 4.00
WINDOWS              | WINDOWS NT
kbprg kberrmsg kbprb

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with:

    - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52 - Microsoft Visual C++, 32-bit Edition, versions 2.0, 2.1, and 4.0

SYMPTOMS

The compiler generates the following error message when you try to define a handler for WM_INITDIALOG for your CFormView-derived class using ClassWizard:

   Error C2039: 'OnInitDialog': is not a member of CFormView

CAUSE

This error is a result of the way ClassWizard views CFormView. ClassWizard, in most respects, treats the CFormView class as a CDialog class, and incorrectly allows users to define a handler for the WM_INITDIALOG message. If users choose to have their CFormView derived class handle the WM_INITDIALOG message, ClassWizard generates an OnInitDialog member function for their CFormView-derived class. The ClassWizard added OnInitDialog member function calls the parent OnInitDialog member function as follows:

   CFormView::OnInitDialog();

During compilation, the OnInitDialog member function generates the above mentioned error because CFormView is neither derived from CDialog nor does it have an OnInitDialog member function defined in its class.

RESOLUTION

To perform initialization of your CFormView, either override the OnInitialUpdate member function or define a handler for the WM_CREATE message in the CFormView-derived class.


Additional reference words: 1.00 1.50 2.00 2.10 2.00 2.50 2.51 2.52 3.00
3.10 4.00
KBCategory: kbprg kberrmsg kbprb
KBSubcategory: WizardIss
Keywords : WizardIss kberrmsg kbprb kbprg
Technology : kbMfc
Version : 1.00 1.50 1.51 1.52 | 2.00 2.10
Platform : NT WINDOWS


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: July 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.