How it Works


Why not MFC



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: 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.

  //Set m_View as the view window of the frame
BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)

  // Process the messages from the Menu and Tool Bar
  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.