PRB: OnInitialUpdate() May Be Called More Than Once (103982)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++
    • Microsoft Visual C++, 32-bit Professional Edition
    • Microsoft Visual C++, 32-bit Enterprise Edition
    • Microsoft Visual C++, 32-bit Learning Edition

This article was previously published under Q103982

SYMPTOMS

The OnInitialUpdate() function of a CView object in a single document interface (SDI) application may be called more than once. Any initialization that needs to be done only when the view's window is created should be done in the OnCreate() message handler instead of in the OnInitialUpdate() function.

MORE INFORMATION

In an SDI application, a single CView object is created to display a view of the document. When the user changes the document, the data in the CDocument is cleared using CDocument::DeleteContents(), and data for the new document is read into the CDocument object. Then the view is updated by sending a WM_INITIALUPDATE message to the view's window, which calls the OnInitialUpdate() function. Therefore, every time the user changes documents, the OnInitialUpdate() function for the view is called.

Modification Type:MajorLast Reviewed:12/2/2003
Keywords:kbArchitecture kbDocView kbprb KB103982