Adding splitter windows to Scribble requires two simple procedures:
m_wndSplitter
to class CChildFrame
.OnCreateClient
to class CChildFrame
. After these procedures, you can build and run Scribble to test the splitter window functionality.
Optional Exercise When you select the splitter window option from AppWizard, AppWizard also generates a menu item, which the user can use instead of directly selecting the split box. To duplicate this feature, create a Split item on Scribble’s Window menu, and assign it an ID of ID_WINDOW_SPLIT. There’s no need to create a handler for it—the framework handles it automatically.
To declare the CSplitterWnd member variable
CChildFrame
class icon and click the right mouse button.The Add Member Variable dialog box appears.
CSplitterWnd
.m_wndSplitter
.
You can view the new variable in ClassView under the CChildFrame
class.
To add the OnCreateClient member function
The New Virtual Override dialog box appears.
OnCreateClient
.return m_wndSplitter.Create(this,
2, 2, // TODO: adjust the number of rows, columns
CSize(10, 10), // TODO: adjust the minimum pane size
pContext);
You can view the new function in ClassView under the CChildFrame
class.
In OnCreateClient
, the frame window creates the window that will cover its client area by calling the Create function of its CSplitterWnd member variable. The following parameters passed to the Create function describe the panes that the splitter window will manage:
CScribbleFrame
window the parent of the CSplitterWnd object (the member variable, m_wndSplitter
). OnCreateClient
. This structure is used to determine which view class should be used for each pane in the splitter window. The Create function accepts two additional arguments:
Because Scribble doesn't pass any values for these, the default values are used.