Win32API Wizzard97 PropSheet_SetWizButtons 不起作用

问题描述 投票:0回答:1

我刚刚学习使用 C 的 Win32 API,我需要向我的应用程序添加向导。这是我第一次这样做,所以我确信这段代码有很多问题。我一直在研究 MSDN 网站,并且我的实现基于我对那里提供的示例和解释的解释。我在这里缺少什么?向导按钮没有改变,并且单击向导最后一页上的“下一步”不会执行任何操作。关闭向导的唯一方法是按取消按钮。我迷路了。非常感谢任何帮助!

 #include <Windows.h>
 #include <WinUser.h>
 #include <richedit.h>
 #include <prsht.h>
 #include <commctrl.h>
 #include "Resource.h"


 //declarations
 BOOL CALLBACK PrpWelcomeProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam);
 BOOL CALLBACK PrpEnvironmentVarsProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam);
 BOOL CALLBACK PrpToolChainVarsProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam);
 BOOL CALLBACK PrpEditorBehaviorProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam);
 BOOL CALLBACK PrpFinishProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam);


 int CreateProjectDialog(HWND Parent)
 {
 HINSTANCE hInstance = GetModuleHandle(NULL);
 PROPSHEETPAGE psp = {sizeof (psp)};
 HPROPSHEETPAGE hPrP[5];



//Setup the Welcome page
psp.hInstance = hInstance;
psp.dwFlags = PSP_HIDEHEADER;
psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE_WELCOME);
psp.pfnDlgProc = PrpWelcomeProc;
psp.lParam = (LPARAM)NULL;
hPrP[0] = CreatePropertySheetPage(&psp);

//Setup the Environment Variagles page
psp.dwFlags =  PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
psp.pszHeaderTitle = TEXT("Environment Variables");
psp.pszHeaderSubTitle = TEXT("Use these options to setup the defualt environment for your OS    project.");
psp.pszTemplate = MAKEINTRESOURCE(IDD_FORMVIEW_ENV_VARIABLES);
psp.pfnDlgProc = PrpEnvironmentVarsProc;
psp.lParam = (LPARAM)NULL;

hPrP[1] = CreatePropertySheetPage(&psp);

//Setup the Toolchain Options page
psp.pszHeaderTitle = TEXT("Toolchain Settings");
psp.pszHeaderSubTitle = TEXT("Use these options to setup your toolchain.");
psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE);
psp.pfnDlgProc = PrpToolChainVarsProc;
psp.lParam = (LPARAM)NULL;

hPrP[2] = CreatePropertySheetPage(&psp);

//Setup the Editor Behavior page
psp.pszHeaderTitle = TEXT("Editor Behavior");
psp.pszHeaderSubTitle = TEXT("Use these options to customize the editor.");
psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE_EDITOR);
psp.pfnDlgProc = PrpEditorBehaviorProc;
psp.lParam = (LPARAM)NULL;

hPrP[3] = CreatePropertySheetPage(&psp);


//Setup the Finish Page
psp.dwFlags = PSP_HIDEHEADER;
psp.pszHeaderTitle = NULL;
psp.pszHeaderSubTitle = NULL;
psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_FINISH);
psp.pfnDlgProc = PrpFinishProc;
psp.lParam = (LPARAM)NULL;
hPrP[4] = CreatePropertySheetPage(&psp);

//Setup the Propage Header to define the Wizzard
//The Watermark Bitmap and the Header Bitmap need to be created

PROPSHEETHEADER pHeader = { sizeof(pHeader) };
pHeader.dwFlags = PSH_WIZARD97 | PSH_WATERMARK;
pHeader.hInstance = hInstance;
pHeader.hwndParent = Parent;
pHeader.nPages = &psp;
pHeader.nStartPage = 0;
pHeader.nPages = 5;
pHeader.pszbmWatermark = MAKEINTRESOURCE(IDB_BITMAP1);
pHeader.phpage = hPrP;
//Launch the Wizzard
PropertySheet(&pHeader);

return 0;
}

//Dialog Procedures for all of the Dialogs in the Create Project Wizzard


 BOOL CALLBACK PrpWelcomeProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam)
{
LPNMHDR pnmh = (LPNMHDR)lParam;

switch (Message)
{
case WM_INITDIALOG:

    
return FALSE;

case WM_NOTIFY:
    

    switch (pnmh->code)
    {
    case PSN_SETACTIVE:
    PropSheet_SetWizButtons(hDialog, PSWIZB_NEXT);
    return FALSE;
    }

}

return  FALSE;
}

BOOL CALLBACK PrpEnvironmentVarsProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam)
{
LPNMHDR pnmh = (LPNMHDR)lParam;
switch (Message)
{
case WM_INITDIALOG:
    
return FALSE;


case WM_NOTIFY:
    

switch (pnmh->code)
{
case PSN_SETACTIVE:
PropSheet_SetWizButtons(hDialog, PSWIZB_NEXT | PSWIZB_BACK | PSWIZB_CANCEL);
return FALSE;


    }
}
return FALSE;
}
  BOOL CALLBACK PrpToolChainVarsProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam)
  {
LPNMHDR pnmh = (LPNMHDR)lParam;

switch (Message)
{
case WM_INITDIALOG:
    
    return FALSE;

case WM_NOTIFY:
    

    switch (pnmh->code)
    {
    case PSN_SETACTIVE:
        PropSheet_SetWizButtons(hDialog, PSWIZB_NEXT | PSWIZB_BACK | PSWIZB_CANCEL);
        return FALSE;


    }
}

return FALSE;
}

BOOL CALLBACK PrpEditorBehaviorProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam)
{
LPNMHDR pnmh = (LPNMHDR)lParam;

switch (Message)
{
case WM_INITDIALOG:

    return FALSE;


case WM_NOTIFY:
    ;

    switch (pnmh->code)
    {
    case PSN_SETACTIVE:
        PropSheet_SetWizButtons(hDialog, PSWIZB_NEXT | PSWIZB_BACK | PSWIZB_CANCEL);
        return FALSE;


    }

}
return FALSE;
}

BOOL CALLBACK PrpFinishProc(HWND hDialog, UINT Message, WPARAM wParam, LPARAM lParam)
{
LPNMHDR pnmh = (LPNMHDR)lParam;

switch (Message)
{
case WM_INITDIALOG:
    
    return FALSE;

case WM_NOTIFY:
    

    switch (pnmh->code)
    {
     case PSN_SETACTIVE:
        PropSheet_SetWizButtons(hDialog, PSWIZB_BACK | PSWIZB_CANCEL | PSWIZB_FINISH);
        PropSheet_SetFinishText(hDialog, TEXT("Finish"));
        return FALSE;


    }

case WM_DESTROY:
    return FALSE;
}
return FALSE;

}”

c winapi wizard propertysheet
1个回答
0
投票

正如Raymond Chen所说:hDlg是“属性表的句柄”。

对于向导本身的句柄,请致电

GetParent(hwnd)

© www.soinside.com 2019 - 2024. All rights reserved.