OOFILE | Downloads | Purchasing | Press | Services | Company Information | Soapbox | References | F.A.Q. | HOME


Temperature Walk-through v1.0 7 July 2000


This walkthrough describes the major actions performed as a user starts up the Temperature sample program and how the program reacts, to illustrate how PP2MFC maps PowerPlant to MFC and to aid as a debugging guide should anything be going wrong.

This document will keep being revised for each version of PP2MFC so is worth checking at each new version as better explanations are developed. Your feedback on the value of this and other documentation is highly appreciated.


Temperature is a simple example with two data members in a single DataDef used in the main Document. Its file contains just two floats.

It provides conversion between Fahrenheith and Celsius with entry by slider or edit boxes and display in edit boxes, slider and thermometer control.

All values are linked so they mutually update.


- user launches application 
  - Main Window appears
- user edits Centigrade and tabs out of box
  - Centigrade slider moves
  - Fahrenheit value changes
  - Fahrenheit thermometer changes
- user drags the Centigrade slider and releases the mouse
  - Centigrade value changes
  - Fahrenheit value changes
  - Fahrenheit thermometer changes
- user edits Fahrenheit and tabs out of box
  - Fahrenheit thermometer changes
  - Centigrade value changes
  - Centigrade slider moves
- user chooses File-Quit
  - application exits immediately with no alert saying the document is dirty
    (this may be a limit of the C/C++ generation language rather than


Temperature.cpp contains CTemperatureApp::InitInstance creates a CSingleDocTemplate which links a CTemperatureDoc, CMainFrame and CTemperatureView.

Think of the DocTemplate a bit like a PPob that describes what combination of document, command handler and initial view will be used.

CTemperatureView::OnInitialUpdate creates the first of our windows (later generators will make other windows appear or be selectable) by calling CMainWindow::MakeWindow which creates a CMainWindow.


With the SDI model, CMainWindow::OnInitialUpdate embeds itself in the containing view, changing its window style so it becomes a "child window" of CMainFrame and adjusting the boundaries of the containing window so it exactly fits.

OnInitialUpdate also creates MFC controls and the PP2MFC shadows. This is the equivalent of FinishCreateSelf.

After creating the CMainWindow, CMainWindow::MakeWindow calls ConnectToData which causes the default new values in the document data to be copied to controls.


The current version reacts to edit fields as you type, rather than on tabbing out of the field. An EN_CHANGE message is trapped iLWindow::OnCommandRedirector and the control's message is passed on to ListenToMessage. This is equivalent to an LEditText::UserChangedText causing the value message to be broadcast.

From this point on the behaviour almost exactly matches the PowerPlant generated code (being driven by AppMaker's idioms for data message propagation).

CMainWindow::ListenToMessage reacts to msgEditCentigrade by updating the data model with mData->SetCentigrade.

This causes a broadcast of msgDataChanged with idCentigrade and idFahrenheit and so two calls to CMainWindow::DataChanged, resulting in new values being copied to the sliders, progress bar and Fahrenheit edit text.

back to PP2MFC main page