Sheet设置PSH_WIZARD97 Page设置PSP_HIDEHEADERWIZ97.CPP/*++Copyright (c) 1998 Microsoft Corporation All rights reserved.Module Name:Wiz97--*/#include "Wiz97.h"INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, INT nCmdShow ) { PROPSHEETPAGE psp = {0}; //defines the property sheet pages HPROPSHEETPAGE ahpsp[4] = {0}; //an array to hold the page's HPROPSHEETPAGE handles PROPSHEETHEADER psh = {0}; //defines the property sheet SHAREDWIZDATA wizdata = {0}; //the shared data structure // //Create the Wizard pages // //Opening page psp.dwSize = sizeof(psp); psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; psp.hInstance = hInstance; psp.lParam = (LPARAM) &wizdata; //The shared data structure psp.pfnDlgProc = IntroDlgProc; psp.pszTemplate = MAKEINTRESOURCE(IDD_INTRO); ahpsp[0] = CreatePropertySheetPage(&psp); //First interior page psp.dwFlags = PSP_DEFAULT|PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE; psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TITLE1); psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUBTITLE1); psp.pszTemplate = MAKEINTRESOURCE(IDD_INTERIOR1); psp.pfnDlgProc = IntPage1DlgProc; ahpsp[1] = CreatePropertySheetPage(&psp); //Second interior page psp.dwFlags = PSP_DEFAULT|PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE; psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TITLE2); psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUBTITLE2); psp.pszTemplate = MAKEINTRESOURCE(IDD_INTERIOR2); psp.pfnDlgProc = IntPage2DlgProc; ahpsp[2] = CreatePropertySheetPage(&psp); //Final page psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; psp.pszTemplate = MAKEINTRESOURCE(IDD_END); psp.pfnDlgProc = EndDlgProc; ahpsp[3] = CreatePropertySheetPage(&psp); //Create the property sheet psh.dwSize = sizeof(psh); psh.hInstance = hInstance; psh.hwndParent = NULL; psh.phpage = ahpsp; psh.dwFlags = PSH_WIZARD97|PSH_WATERMARK|PSH_HEADER; psh.pszbmWater = MAKEINTRESOURCE(IDB_WATERMARK); psh.pszbmHeader = MAKEINTRESOURCE(IDB_BANNER); psh.nStartPage = 0; psh.nPages = 4; //Set up the font for the titles on the intro and ending pages NONCLIENTMETRICS ncm = {0}; ncm.cbSize = sizeof(ncm); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); //Create the intro/end title font LOGFONT TitleLogFont = ncm.lfMessageFont; TitleLogFont.lfWeight = FW_BOLD; lstrcpy(TitleLogFont.lfFaceName, TEXT("Verdana Bold")); HDC hdc = GetDC(NULL); //gets the screen DC INT FontSize = 12; TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * FontSize / 72; wizdata.hTitleFont = CreateFontIndirect(&TitleLogFont); ReleaseDC(NULL, hdc); //Display the wizard PropertySheet(&psh);
// Destroy the fonts DeleteObject(wizdata.hTitleFont); return 0; }BOOL CALLBACK IntroDlgProc ( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { //Process messages from the Welcome page //Retrieve the shared user data from GWL_USERDATA LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLong(hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG : { //Get the shared data from PROPSHEETPAGE lParam value //and load it into GWL_USERDATA pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam; SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD_PTR) pdata);
//It's an intro/end page, so get the title font //from the shared data and use it for the title control HWND hwndControl = GetDlgItem(hwndDlg, IDC_TITLE); SetWindowFont(hwndControl,pdata->hTitleFont, TRUE); break; } case WM_NOTIFY : { LPNMHDR lpnm = (LPNMHDR) lParam; switch (lpnm->code) { case PSN_SETACTIVE : //Enable the Next button PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT); break; case PSN_WIZNEXT : //Handle a Next button click here break; case PSN_RESET : //Handle a Cancel button click, if necessary break; default : break; } } break; default: break; } return 0; }
BOOL CALLBACK IntPage1DlgProc ( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { //Process messages from the first interior page //Retrieve the shared user data from GWL_USERDATA LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLong(hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG : { //Get the PROPSHEETPAGE lParam value and load it into //DWL_USERDATA pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam; SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD_PTR) pdata); break; }
case WM_COMMAND : switch(LOWORD (wParam)) { case IDC_CHECK1 : pdata->IsBoxChecked = !(pdata->IsBoxChecked); break; case IDC_RADIO1 : case IDC_RADIO2 : case IDC_RADIO3 : pdata->IsButtonClicked = TRUE; break;
default : break; } //If any of the radio buttons are clicked, or the //check box checked, enable the Next button if(pdata->IsBoxChecked || pdata->IsButtonClicked) { PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT); } else //otherwise, only enable the Back button { PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK); } break; case WM_NOTIFY : { LPNMHDR lpnm = (LPNMHDR) lParam; switch (lpnm->code) { case PSN_SETACTIVE : //Enable the appropriate buttons //If a radio button has been clicked or the //check box checked, enable Back and Next if(pdata->IsBoxChecked || pdata->IsButtonClicked) { PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT); } else //Otherwise, only enable Back { PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK); } break; case PSN_WIZNEXT : //If the check box is checked, jump to the final page if(pdata->IsBoxChecked) { SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_END); return TRUE; } break; case PSN_WIZBACK : //Handle a Back button click, if necessary break; case PSN_RESET : //Handle a Cancel button click, if necessary break; default : break; } } break; default: break; } return 0; }BOOL CALLBACK IntPage2DlgProc ( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { //Process messages from the second interior page //Retrieve the shared user data from GWL_USERDATA LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLong(hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG : { //Get the PROPSHEETPAGE lParam value and load it into //DWL_USERDATA pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam; SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD_PTR) pdata); break; } case WM_NOTIFY : { LPNMHDR lpnm = (LPNMHDR) lParam; switch (lpnm->code) { case PSN_SETACTIVE : //Enable the Next and Back buttons PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT); break; case PSN_WIZNEXT : //Handle a Next button click, if necessary break; case PSN_WIZBACK : //Handle a Back button click, if necessary break; case PSN_RESET : //Handle a Cancel button click, if necessary break; default : break; } } break; default: break; } return 0; }BOOL CALLBACK EndDlgProc ( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
//Process messages from the Completion page //Retrieve the shared user data from GWL_USERDATA LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLong(hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG : { //Get the shared data from PROPSHEETPAGE lParam value //and load it into GWL_USERDATA pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam; SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD_PTR) pdata);
//It's an intro/end page, so get the title font //from userdata and use it on the title control HWND hwndControl = GetDlgItem(hwndDlg, IDC_TITLE); SetWindowFont(hwndControl,pdata->hTitleFont, TRUE); break; } case WM_NOTIFY : { LPNMHDR lpnm = (LPNMHDR) lParam; switch (lpnm->code) { case PSN_SETACTIVE : //Enable the correct buttons on for the active page PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_FINISH); break; case PSN_WIZBACK : //If the check box was checked, jump back //to the first interior page, not the second if(pdata->IsBoxChecked) { SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_INTERIOR1); return TRUE; } break; case PSN_WIZFINISH : //Handle a Finish button click, if necessary break; case PSN_RESET : //Handle a Cancel button click, if necessary break; default : break; } } break; default: break; } return 0; }
Page设置PSP_HIDEHEADERWIZ97.CPP/*++Copyright (c) 1998 Microsoft Corporation
All rights reserved.Module Name:Wiz97--*/#include "Wiz97.h"INT WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
INT nCmdShow
)
{
PROPSHEETPAGE psp = {0}; //defines the property sheet pages
HPROPSHEETPAGE ahpsp[4] = {0}; //an array to hold the page's HPROPSHEETPAGE handles
PROPSHEETHEADER psh = {0}; //defines the property sheet
SHAREDWIZDATA wizdata = {0}; //the shared data structure
//
//Create the Wizard pages
// //Opening page psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER;
psp.hInstance = hInstance;
psp.lParam = (LPARAM) &wizdata; //The shared data structure
psp.pfnDlgProc = IntroDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_INTRO); ahpsp[0] = CreatePropertySheetPage(&psp); //First interior page psp.dwFlags = PSP_DEFAULT|PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TITLE1);
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUBTITLE1);
psp.pszTemplate = MAKEINTRESOURCE(IDD_INTERIOR1);
psp.pfnDlgProc = IntPage1DlgProc; ahpsp[1] = CreatePropertySheetPage(&psp); //Second interior page psp.dwFlags = PSP_DEFAULT|PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;
psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TITLE2);
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUBTITLE2);
psp.pszTemplate = MAKEINTRESOURCE(IDD_INTERIOR2);
psp.pfnDlgProc = IntPage2DlgProc; ahpsp[2] = CreatePropertySheetPage(&psp); //Final page psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER;
psp.pszTemplate = MAKEINTRESOURCE(IDD_END);
psp.pfnDlgProc = EndDlgProc; ahpsp[3] = CreatePropertySheetPage(&psp); //Create the property sheet psh.dwSize = sizeof(psh);
psh.hInstance = hInstance;
psh.hwndParent = NULL;
psh.phpage = ahpsp;
psh.dwFlags = PSH_WIZARD97|PSH_WATERMARK|PSH_HEADER;
psh.pszbmWater = MAKEINTRESOURCE(IDB_WATERMARK);
psh.pszbmHeader = MAKEINTRESOURCE(IDB_BANNER);
psh.nStartPage = 0;
psh.nPages = 4;
//Set up the font for the titles on the intro and ending pages NONCLIENTMETRICS ncm = {0};
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); //Create the intro/end title font
LOGFONT TitleLogFont = ncm.lfMessageFont;
TitleLogFont.lfWeight = FW_BOLD;
lstrcpy(TitleLogFont.lfFaceName, TEXT("Verdana Bold")); HDC hdc = GetDC(NULL); //gets the screen DC
INT FontSize = 12;
TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * FontSize / 72;
wizdata.hTitleFont = CreateFontIndirect(&TitleLogFont);
ReleaseDC(NULL, hdc);
//Display the wizard PropertySheet(&psh);
// Destroy the fonts
DeleteObject(wizdata.hTitleFont); return 0;
}BOOL CALLBACK IntroDlgProc (
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
//Process messages from the Welcome page //Retrieve the shared user data from GWL_USERDATA LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLong(hwndDlg, GWL_USERDATA); switch (uMsg)
{
case WM_INITDIALOG :
{
//Get the shared data from PROPSHEETPAGE lParam value
//and load it into GWL_USERDATA pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam; SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD_PTR) pdata);
//It's an intro/end page, so get the title font
//from the shared data and use it for the title control HWND hwndControl = GetDlgItem(hwndDlg, IDC_TITLE);
SetWindowFont(hwndControl,pdata->hTitleFont, TRUE);
break;
}
case WM_NOTIFY :
{
LPNMHDR lpnm = (LPNMHDR) lParam; switch (lpnm->code)
{
case PSN_SETACTIVE : //Enable the Next button
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
break; case PSN_WIZNEXT :
//Handle a Next button click here
break; case PSN_RESET :
//Handle a Cancel button click, if necessary
break;
default :
break;
}
}
break; default:
break;
}
return 0;
}
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{ //Process messages from the first interior page //Retrieve the shared user data from GWL_USERDATA LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLong(hwndDlg, GWL_USERDATA); switch (uMsg)
{
case WM_INITDIALOG :
{
//Get the PROPSHEETPAGE lParam value and load it into
//DWL_USERDATA pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam;
SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD_PTR) pdata);
break;
}
case WM_COMMAND :
switch(LOWORD (wParam))
{
case IDC_CHECK1 :
pdata->IsBoxChecked = !(pdata->IsBoxChecked);
break; case IDC_RADIO1 : case IDC_RADIO2 : case IDC_RADIO3 :
pdata->IsButtonClicked = TRUE;
break;
default :
break; } //If any of the radio buttons are clicked, or the
//check box checked, enable the Next button if(pdata->IsBoxChecked || pdata->IsButtonClicked)
{
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
} else //otherwise, only enable the Back button
{
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK);
}
break;
case WM_NOTIFY :
{
LPNMHDR lpnm = (LPNMHDR) lParam; switch (lpnm->code)
{
case PSN_SETACTIVE : //Enable the appropriate buttons
//If a radio button has been clicked or the
//check box checked, enable Back and Next
if(pdata->IsBoxChecked || pdata->IsButtonClicked)
{
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
} else //Otherwise, only enable Back
{
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK);
}
break; case PSN_WIZNEXT : //If the check box is checked, jump to the final page if(pdata->IsBoxChecked)
{
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_END);
return TRUE;
}
break; case PSN_WIZBACK :
//Handle a Back button click, if necessary
break; case PSN_RESET :
//Handle a Cancel button click, if necessary
break; default :
break;
}
}
break; default:
break;
}
return 0;
}BOOL CALLBACK IntPage2DlgProc (
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
//Process messages from the second interior page //Retrieve the shared user data from GWL_USERDATA LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLong(hwndDlg, GWL_USERDATA); switch (uMsg)
{
case WM_INITDIALOG :
{
//Get the PROPSHEETPAGE lParam value and load it into
//DWL_USERDATA pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam;
SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD_PTR) pdata);
break;
} case WM_NOTIFY :
{
LPNMHDR lpnm = (LPNMHDR) lParam; switch (lpnm->code)
{
case PSN_SETACTIVE : //Enable the Next and Back buttons PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
break; case PSN_WIZNEXT :
//Handle a Next button click, if necessary
break; case PSN_WIZBACK :
//Handle a Back button click, if necessary
break; case PSN_RESET :
//Handle a Cancel button click, if necessary
break; default :
break;
}
}
break; default:
break;
}
return 0;
}BOOL CALLBACK EndDlgProc (
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
//Process messages from the Completion page //Retrieve the shared user data from GWL_USERDATA LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLong(hwndDlg, GWL_USERDATA); switch (uMsg)
{
case WM_INITDIALOG :
{
//Get the shared data from PROPSHEETPAGE lParam value
//and load it into GWL_USERDATA pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam;
SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD_PTR) pdata);
//It's an intro/end page, so get the title font
//from userdata and use it on the title control HWND hwndControl = GetDlgItem(hwndDlg, IDC_TITLE);
SetWindowFont(hwndControl,pdata->hTitleFont, TRUE);
break;
} case WM_NOTIFY :
{
LPNMHDR lpnm = (LPNMHDR) lParam; switch (lpnm->code)
{
case PSN_SETACTIVE : //Enable the correct buttons on for the active page PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_FINISH);
break; case PSN_WIZBACK : //If the check box was checked, jump back
//to the first interior page, not the second
if(pdata->IsBoxChecked)
{
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_INTERIOR1);
return TRUE;
}
break; case PSN_WIZFINISH :
//Handle a Finish button click, if necessary
break; case PSN_RESET :
//Handle a Cancel button click, if necessary
break; default :
break;
}
}
break; default:
break;
}
return 0;
}