Tutorials |
Menu of tutorials
Tutorial 1: The Simplest
WindowTutorial 2: Using Classes and
Inheritance
Tutorial 3: Using Messages to Create a
Scribble Window
Tutorial 4: Repainting the
Window
Tutorial 5: Wrapping a Frame around
our Scribble Window
Tutorial 6: Customising Window
Creation
Tutorial 7: Customising the
ToolBar
Tutorial 8: Loading and Saving
Files
Tutorial 9: Printing
Tutorial 10: Finishing Touches
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.
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.
CMainFrame::CMainFrame() { //Set m_View as the view window of the frame SetView(m_View); }
BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) { // Process the messages from the Menu and Tool Bar switch (LOWORD(wParam)) { case IDM_FILE_EXIT: // End the application ::PostMessage(m_hWnd, WM_CLOSE, 0, 0); return TRUE; case IDM_HELP_ABOUT: // Display the help dialog OnHelp(); return TRUE; case IDM_FILE_NEW: ::MessageBox(NULL, _T("File New ... Implemented later"), _T("Menu"), MB_OK); return TRUE; case IDM_FILE_OPEN: ::MessageBox(NULL, _T("File Open ... Implemented later"), _T("Menu"), MB_OK); return TRUE; case IDM_FILE_SAVE: ::MessageBox(NULL, _T("File Save ... Implemented later"), _T("Menu"), MB_OK); return TRUE; case IDM_FILE_SAVEAS: ::MessageBox(NULL, _T("File SaveAs ... Implemented later"), _T("Menu"), MB_OK); return TRUE; case IDM_FILE_PRINT: ::MessageBox(NULL, _T("File Print ... Implemented later"), _T("Menu"), MB_OK); return TRUE; } return FALSE; }
The source code for this tutorial is located within the Tutorial folder of the software available from SourceForge at http://sourceforge.net/projects/win32-framework.