Tutorial 5: Wrapping a Frame around our Scribble Application
This is the code we use to produce a simple frame application. We
inherit a class called CMainframe
from the CFrame
class in Win32++. Notice how we use the SetView function to specify the
"view" window of our frame. This "view" window happens to be the same code
as the simple scribble application shown in the previous tutorial. In
this way, we wrap a frame around our previous scribble application.
CMainFrame::CMainFrame()
{
// Set m_view as the view window of the frame.
SetView(m_view);
}
The CMainFrame
class inherits OnCommand from CFrame
.
This function responds to input from the frame's menu and toolbar. We
haven't implemented many of these inputs yet, so at this stage most of them
simply display a simple message box.
BOOL CMainFrame::OnCommand(WPARAM wparam, LPARAM lparam)
{
UNREFERENCED_PARAMETER(lparam);
// Process the messages from the menu and toolbar.
switch (LOWORD(wparam))
{
case IDM_FILE_NEW: return OnFileNew();
case IDM_FILE_OPEN: return OnFileOpen();
case IDM_FILE_SAVE: return OnFileSave();
case IDM_FILE_SAVEAS: return OnFileSaveAs();
case IDM_FILE_PRINT: return OnFilePrint();
case IDW_VIEW_STATUSBAR: return OnViewStatusBar();
case IDW_VIEW_TOOLBAR: return OnViewToolBar();
case IDM_HELP_ABOUT: return OnHelp();
case IDM_FILE_EXIT: return OnFileExit();
}
return FALSE;
}