Normally, you can change the size of a window by calling MoveWindow(). In an application developed with the Microsoft Foundation Class (MFC) Library, the view window is a child window of the frame window that surrounds the view. To change the size of the view window, retrieve a pointer to the frame window of the view by calling GetParentFrame(), then call MoveWindow() to change the size of the parent. When the parent frame window changes size, it automatically changes the size of the view window to fit in the parent frame.
MSVC Knowledge Base. 6/4/94
See MS Knowledge Base article Q98598 for a very long answer. Basically, you need to override OnInitialUpdate() in a CFormView derived class. There's other details to deriving from CFormView that the article goes into.
MSVC Knowledge Base. 6/7/95
In the view ClikethisView declaration:
In the ClikethisView code:
andyr@gate.net, programmer.misc, 8/11/95
In an application created with AppWizard, you have two options: change the derivation of the current view, or create a new view and use the new view in your MDI application along with the original view.
To create a new view, use ClassWizard to create a new class derived from CView. After the class has been created, the steps to use the new view or to modify the view provided by App Wizard are the same.
For more information, please see Knowledge Base article Q99562.
MSVC Knowledge Base 6/7/95
To change the background color for a CView, CFrameWnd, or CWnd object, process the WM_ERASEBKGND message. The following code shows how:
I solved the problem like this->
Tim, tfiner@vrli.com, email, 9/10/95
The best thing to do is to pass the view along as a parameter. If this is impractical, you can get the view if you KNOW, that it is the currently active document and the currently active view. For details, see :
Microsoft KB, article Q108587, "Get Current CDocument or CView from Anywhere".
In brief, use
and
to get the document and the view. It might be a good idea to wrap them in static functions in your CMyDoc and CMyView and check that they are of the correct RUNTIME_CLASS.
If the view isn't the currently active view or if you can run OLE in-place, this won't work however.
null@diku.dk, Niels Ull Jacobsen, programmer.misc, 6/8/95
The CDocTemplate::CreateNewFrame() function creates additional views of a document in an MDI application written with MFC. To call this function, specify a pointer to a CDocument object (the document for which the function will create a view) and a pointer to a frame window that has the properties to duplicate. Typically, the second parameter of this function is NULL.
When an application calls CreateNewFrame(), the function creates a new frame window and a view in the frame window. The frame window type and view type depend on the document template (CDocTemplate) associated with the document specified in the CreateNewFrame() call.
The CHKBOOK MFC sample application that ships with Visual C++ also demonstrates creating additional frames and views for documents. Check out CHKBOOK.CPP, the CChkBookApp::OpenDocumentfile() function.
Another example of using CreateNewFrame() is the MULTVIEW sample application. Also, Dale Rogerson's article, "Multiple Views for a Single Document" located on the Microsoft Developer Network Development Library CD-ROM, which explains in detail how to add additional views to an existing document, is an excellent source of information.
CreateNewFrame() creates both a frame and a view; not only a view. If, for some reason, CreateNewFrame() does not quite address your situation, the source code for CreateNewFrame() is quite useful to demonstrate the steps required to create frames and views.
MS FAQ with mods, 6/25/95
You need to use some functions which are undocumented:
You'll also need to mess with the m_templateList member of CWinApp.
blaszczak@Bix.com, mfc-l, 7/11/95
Note: This has changed with MFC 4.0. There's now a class called CDocManager which can get to all of the views/docs for you. Check out MFC Internals for details.
scot@stingray.com
Download AUTOSV.LZH from the MSMFC library on CIS. This code shows you how to implement a secondary message loop taking care of the mouse activity. Hooks are provided to customize the code. Freeware.
Patrick Philippot, CIS email, 8/3/95