#include <tchar.h> #include <Windows.h> #include <CommCtrl.h> #include <Prsht.h> #include "resource.h"
#pragma comment(lib, "Comctl32.lib") #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
INT_PTR CALLBACK DlgProc1(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND hwndParent = GetParent(hDlg); switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BUTTON1: SetDlgItemText(hDlg, IDC_EDIT1, TEXT("You clicked me.")); EnableWindow((HWND)lParam, FALSE); SetWindowText(hwndParent, TEXT("Parent")); //PropSheet_Apply(hwndParent); PropSheet_CancelToClose(hwndParent); break; case IDC_BUTTON2: PropSheet_Changed(hwndParent, hDlg); break; } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { //MessageBox(hwndParent, TEXT("a"), TEXT("b"), MB_ICONWARNING); //PropSheet_RebootSystem(hwndParent); } break; } return FALSE; }
INT_PTR CALLBACK DlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { return FALSE; }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { PROPSHEETPAGE page[2]; page[0].dwSize = sizeof(PROPSHEETPAGE); page[0].dwFlags = PSP_USEICONID | PSP_USETITLE; page[0].hInstance = hInstance; page[0].pszTemplate = MAKEINTRESOURCE(IDD_DIALOG1); page[0].pszIcon = IDI_APPLICATION; page[0].pfnDlgProc = DlgProc1; page[0].pszTitle = TEXT("常规"); page[0].lParam = 0; page[0].pfnCallback = NULL; page[1].dwSize = sizeof(PROPSHEETPAGE); page[1].dwFlags = PSP_USEICONID | PSP_USETITLE; page[1].hInstance = hInstance; page[1].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE); page[1].pszIcon = IDI_ERROR; page[1].pfnDlgProc = DlgProc2; page[1].pszTitle = TEXT("高级"); page[1].lParam = 0; page[1].pfnCallback = NULL;
PROPSHEETHEADER psh; psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE; psh.hwndParent = NULL; psh.hInstance = hInstance; psh.pszCaption = TEXT("属性窗口"); psh.hIcon = LoadIcon(NULL, IDI_APPLICATION); psh.nPages = 2; psh.nStartPage = 0; psh.ppsp = page; psh.pfnCallback = NULL;
PropertySheet(&psh);
return 0; }
|