Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals


Practical Learning: Creating a Floating Property Sheet



  1. Display the Add Resource dialog box. Expand the Dialog node and double-click
    IDD_PROPPAGE_SMALL. Delete its TODO line. Change its ID to
    IDD_SMALL_PAGE and its Caption to Small. Add a class for the dialog box.
    Name it CSmallPge and base it on CPropertyPage

  2. In the same way, add another IDD_PROPPAGE_SMALL dialog box. Delete its
    TODO line. Change its ID to IDD_MEDIUM_PAGE and its Caption to Medium.
    Add a class for the dialog box. Name it CMediumPge and base it on
    CPropertyPage

  3. Add a class named CFloatingSheet and based on CPropertySheet

  4. Change the header file as follows:


#pragma once

#include "SmallPage.h"
#include "MediumPage.h"

// CFloatingSheet

class CFloatingSheet : public CPropertySheet
{
DECLARE_DYNAMIC(CFloatingSheet)

public:
// CFloatingSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage
= 0);
CFloatingSheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT
iSelectPage = 0);
virtual ~CFloatingSheet();

protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnClose();
CSmallPage pgSmall;
CMediumPage pgMedium;
};


  1. In its source file, add each page as follows:


// FloatingSheet.cpp : implementation file
//

#include "stdafx.h"
#include "Floating.h"
#include "FloatingSheet.h"

// CFloatingSheet

IMPLEMENT_DYNAMIC(CFloatingSheet, CPropertySheet)
/*
CFloatingSheet::CFloatingSheet(UINT nIDCaption, CWnd* pParentWnd, UINT
iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
Free download pdf