我刚刚开始学习使用C语言的Win32API,我需要将向导添加到我的应用程序中.这是我第一次这样做,所以我确信这段代码有多处错误.我一直在研究MSDN网站,我基于对那里提供的示例和解释的解释来实现这个实现.我错过了什么吗?向导按钮没有变化,并且在向导的最后一页上单击Next不执行任何操作.关闭向导的唯一方法是按下Cancel按钮.我迷路了.如有任何帮助,不胜感激!

 #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;

}"

推荐答案

正如Raymond Chen所说:hDlg是"属性表的句柄".

有关向导本身的句柄,请拨打GetParent(hwnd).

C++相关问答推荐

有效地计算由一组点构成的等边三角形和等腰三角形的数量

sizeof结果是否依赖于字符串的声明?

Malloc(sizeof(char[Length]))是否不正确?

如何在不使用其他数组或字符串的情况下交换字符串中的两个单词?

非常大的数组的大小

为静态库做准备中的奇怪行为

将 struct 传递给函数

如何在下面的C代码中正确管理内存?

如何读取文件并将内容保存在字符串中?(在C语言中,没有崩溃或核心转储错误)

try 查找带有指针的数组的最小值和最大值

STM32 FATFS用户手册(Um1721)中的代码正确吗?

在我的第一个C语言中观察到的错误';你好世界';程序

使用替代日历打印日期

在C中定义函数指针?

与 C 相比,C++ 中无副作用的无限循环的好处是 UB?

C11 嵌套泛型

malloc:损坏的顶部大小无法找出问题

用于内存布局的size命令(文本、数据、bss)

从寄存器移动到频繁访问的变量时性能意外降低

为什么CMake构建的程序比命令构建的程序运行得慢