Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 16: Text-Based Controls Visual C++ and MFC Fundamentals


//CCompanySheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT
iSelectPage = 0);
virtual ~CCompanySheet();

protected:
DECLARE_MESSAGE_MAP()

public:
CCompanyForms Forms;
CCompanyProjects Projects;
};


  1. Use the constructor to add each page and remove the Apply button:


CCompanySheet::CCompanySheet(UINT nIDCaption, CWnd* pParentWnd, UINT
iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
m_psh.dwFlags |= PSH_NOAPPLYNOW;
AddPage(&Forms);
AddPage(&Projects);
}


  1. Access the String Table and change the caption of AFX_IDS_APP_TITLE to
    The Associates - Employment Agency

  2. Add an COMMAND (MSVC 6) or an Event Handler (MSVC 7) event for the
    ID_FILE_NEW menu identifier associated with the CMainFrame class and
    implement it as follows:


// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "Associates.h"

#include "MainFrm.h"
#include "CompanySheet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

...


// CMainFrame message handlers

void CMainFrame::OnFileNew()
{
// TODO: Add your command handler code here
CCompanySheet CompSheet(AFX_IDS_APP_TITLE);

CompSheet.DoModal();
}


  1. Test the application

Free download pdf