This section explains the seventh step in writing Phone Book: add message-handler functions for the Help menu. Figure 6.4 shows the Phone Book Help menu. Figures 5.4 through 5.6 in Chapter 5 show the three Help menu dialog boxes in Phone Book.
·To add the Help menu message-handlers:
1.Add the following OnHelp message-handler member function to the CMainWindow section of your VIEW.CPP file below the OnEdit member function:
// CMainWindow::OnHelp
//
void CMainWindow::OnHelp()
{
if ( !m_people.IsPresent() )
{
CModalDialog dlgHelp( "NoData", this );
dlgHelp.DoModal();
return;
}
if ( !m_people.IsNamed() )
{
CModalDialog dlgHelp( "NoName", this );
if ( dlgHelp.DoModal() == IDCANCEL )
return;
}
CModalDialog dlgHelp( "Enter", this );
dlgHelp.DoModal();
}
You already have an OnAbout menu command handler for your main window class. OnAbout is the same as it was in the Hello program. You copied it when you copied the Hello files to start Phone Book. To keep the order of definitions in VIEW.CPP consistent with Listing 2 in Chapter 5, you can put the definition of the OnAbout member function after OnHelp.
To continue the tutorial, see “Add a Keyboard and Mouse Interface” on page 230. For more information on the handlers you just added, see “Discussion: Help Menu Message-Handlers” below.