//初始化
InitCommonControls();
//在资源编辑器里增加两个PropertySheet Page对话框页
//创建属性表
void OnOption(HWND hWndOwner)
{
PROPSHEETPAGE psp[2];
PROPSHEETHEADER psh;
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = hInst;
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_DLG_PAGE1);
//psp[0].pszIcon = MAKEINTRESOURCE(IDI_FONT);
psp[0].pfnDlgProc =(DLGPROC) DialogProc;
psp[0].pszTitle = TEXT("PAGE1");
psp[0].lParam = 0;
psp[0].pfnCallback = NULL;
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = hInst;
psp[1].pszTemplate =MAKEINTRESOURCE(IDD_DLG_PAGE2);
//psp[1].pszIcon = MAKEINTRESOURCE(IDI_BORDER);
psp[1].pfnDlgProc = (DLGPROC)DialogProc;
psp[1].pszTitle =TEXT("PAGE2");;
psp[1].lParam = 0;
psp[1].pfnCallback = NULL;
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOCONTEXTHELP ;
psh.hwndParent = hWndOwner;
psh.hInstance = hInst;
//psh.pszIcon = MAKEINTRESOURCE(IDI_CELL_PROPERTIES);
psh.pszCaption = MAKEINTRESOURCE(IDS_APP_TITLE);
psh.nPages = sizeof(psp) /sizeof(PROPSHEETPAGE);
psh.nStartPage = 0;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
psh.pfnCallback = NULL;
PropertySheet(&psh);
}
//增加属性页消息处理函数.
LRESULT CALLBACK DialogProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
return TRUE;
}
return FALSE;
}
程序运行如图:
![](/images/blog_csdn_net/ruchimy/MyPropertySheet.JPG)