Tutorials

 

Home
About
How it Works
Documentation
Tutorials

Examples

Links
Contact

 

 

Menu of tutorials

Tutorial 1:   The Simplest Window
Tutorial 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: Print Previewing
Tutorial 11: 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.

 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;
}

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.