A SERVICE OF

logo

returns a TWindow *. This return value is a pointer to the old client
window if there was one.,
Before continuing, you should check that the new client window was
successfully created. TView provides the IsOK function, which returns
FALSE if the window wasn’t created successfully If IsOK returns.
FALSE, you should call SetClientWindow again, passing a 0 as the
window pointer and return from the function.,
If the window was created successfully you need to check the view’, s
menu with the GetViewMenu function. If the view has a menu, use the
MergeMenu function of the main window to merge the view’ menus
with the window’ menu.s
The code for EvNewView should look like this:
void
TMyApp::EvNewView(TView& view)
{
GetMainWindow()->SetClientWindow(view.GetWindow());
if (!view.IsOK())
GetMainWindow()->SetClientWindow(0);
else if (view.GetViewMenu())
GetMainWindow()->MergeMenu(*view.GetViewMenu());
}
If the parameter for the WM_OWLVIEW event is dnClose, this
EvCloseView
indicates that a view has been closed. This is handled by the
function
EvCloseView parameter Like the EvNewView function, the EvCloseView.
function returns void and takes a TView & parameter.
T close a view you need to remove the view’ window as the cliento , s
of the main window. T do this, call the main window’o s
SetClientWindow function, passing a 0 as the window pointer Y u can. o
then restore the menu of the frame window to its former state using
the RestoreMenu function of the main window.
When the EvNewView function creates a new view the caption of the,
frame window is set to the file path of the document. Y u need too
reset the main window’ caption using the SetCaption function.s
Here’ the code for the EvCloseView function:s
void
TMyApp::EvCloseView(TView& /*view*/)
{
GetMainWindow()->SetClientWindow(0);
GetMainWindow()->RestoreMenu();
GetMainWindow()->SetCaption("Drawing Pad");
Chapter 2, Learning ObjectWindows
93