PRB: Error C2039: OnInitDialog is Not a Member of CFormView
Article ID: 132675
Article Last Modified on 11/21/2006
APPLIES TO
- Microsoft Foundation Class Library 4.2, when used with:
- Microsoft Visual C++ 1.0 Professional Edition
- Microsoft Visual C++ 1.5 Professional Edition
- Microsoft Visual C++ 1.51
- Microsoft Visual C++ 1.52 Professional Edition
- Microsoft Visual C++ 2.0 Professional Edition
- Microsoft Visual C++ 4.0 Standard Edition
- 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++ 6.0 Standard Edition
This article was previously published under Q132675
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.
Keywords: kberrmsg kbprb kbwizard KB132675