CMFCPropertySheet 2 - Controls

Desktop version of Tabs

2025-12-27

Written by: xiaobin

In the initial instance of CmnCtrl1.cpp:

	CAllControlsSheet   allcontrolssheet(_T("Common Controls Sample"));
	m_pMainWnd = &allcontrolssheet;
	allcontrolssheet.DoModal();
	return FALSE;

Project - CmnCtrl1

Use the MFC application wizard to build:

Solution after deleting One1pg:

Create PropertyPage

Add MFC Class:

Add -> Class
MFC -> MFC Class

Note!!!

Base class selection: CPropertyPage, otherwise you cannot select the Diglog ID!

In "Diglog ID", select an existing one.

Create PropertySheet

// Attributes
public:
	CTreeCtrlPage       m_treectrlpage;
	CAnimateCtrlPage    m_animctrlpage;
protected:
	void AddControlPages(void);

add pages

void CAllControlsSheet::AddControlPages()
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_psh.dwFlags |= PSP_USEHICON;
	m_psh.hIcon = m_hIcon;
	m_psh.dwFlags |= PSH_NOAPPLYNOW;    // Lose the Apply Now button
	m_psh.dwFlags &= ~PSH_HASHELP;  // Lose the Help button

	AddPage(&m_treectrlpage);
	AddPage(&m_animctrlpage);
}

m_hIcon declare:

protected:
	HICON m_hIcon;

constructor

// Construction
public:
	CAllControlsSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
	CAllControlsSheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
CAllControlsSheet::CAllControlsSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CMFCPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
	AddControlPages();

	// TODO :: Add the pages for the rest of the controls here.
}

CAllControlsSheet::CAllControlsSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CMFCPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
	AddControlPages();
}

Ref