C++ 调整属性页大小时出错

C++ 调整属性页大小时出错,c++,visual-c++,visual-studio-2008,mfc,C++,Visual C++,Visual Studio 2008,Mfc,我试图用这个例子制作一个可重新调整大小的属性表。然而,我的代码中有几个错误,我不知道如何克服。 我在对话框中使用类向导创建了属性表。 我只需要文章中提到的重新调整大小函数。任何帮助都将不胜感激 .cpp类 #include "stdafx.h" #include "Geometry.h" #include "GeoSheet.h" // CGeoSheet IMPLEMENT_DYNAMIC(CGeoSheet, CPropertySheet)

我试图用这个例子制作一个可重新调整大小的属性表。然而,我的代码中有几个错误,我不知道如何克服。 我在对话框中使用类向导创建了属性表。 我只需要文章中提到的重新调整大小函数。任何帮助都将不胜感激

.cpp类

    #include "stdafx.h"
    #include "Geometry.h"
    #include "GeoSheet.h"


    // CGeoSheet

    IMPLEMENT_DYNAMIC(CGeoSheet, CPropertySheet)


    CGeoSheet::CGeoSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
    :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
    {

    }

    CGeoSheet::CGeoSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
    :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
    {

    }

    CGeoSheet::~CGeoSheet()
    {
    }


    BEGIN_MESSAGE_MAP(CGeoSheet, CPropertySheet)
        ON_COMMAND(IDOK, OnOK)
    END_MESSAGE_MAP()



    // CGeoSheet message handlers

    void CGeoSheet::OnOK()  
    {
        CPropertySheet::OnClose();
    }

    // Overriding DoModal() allows us to hook our callback into
    //    the prop sheet creation
    int CGeoSheet::DoModal() 
    {
        // Hook into property sheet creation code
        AFX_OLDPROPSHEETHEADER* psh = GetPropSheetHeader();
        psh->dwFlags |= PSH_USECALLBACK;
        psh->pfnCallback = XmnPropSheetCallback;
        return CPropertySheet::DoModal();
    }


    // This function must be a STATIC member function. 
    //Callback to allow us set the default window styles 
    //    for the property sheet
    int CGeoSheet ::XmnPropSheetCallback(HWND hWnd, UINT message, LPARAM lParam)
    {
        extern int CALLBACK AfxPropSheetCallback(HWND, UINT message, LPARAM lParam);
        // XMN: Call MFC's callback
        int nRes = AfxPropSheetCallback(hWnd, message, lParam);

        switch (message)
        {
        case PSCB_PRECREATE:
            // Set our own window styles
            ((LPDLGTEMPLATE)lParam)->style |= (DS_3DLOOK | DS_SETFONT
                | WS_THICKFRAME | WS_SYSMENU | WS_POPUP | WS_VISIBLE | WS_CAPTION);
            break;
        }
        return nRes;
    }
.h文件

#pragma once



// CGeoSheet

class CGeoSheet : public CPropertySheet
{
    DECLARE_DYNAMIC(CGeoSheet)

public:

    CGeoSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
    CGeoSheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
    virtual ~CGeoSheet();

protected:
    DECLARE_MESSAGE_MAP()
    //{{AFX_MSG(CMyPropertySheet)
        // NOTE - the ClassWizard will add and remove member functions here.
    afx_msg void OnOK();
    int CGeoSheet::DoModal();
    int CGeoSheet ::XmnPropSheetCallback(HWND hWnd, UINT message, LPARAM lParam);
    //}}AFX_MSG

};
我不断地犯这些错误

geosheet.cpp(49) : error C2065: 'AFX_OLDPROPSHEETHEADER' : undeclared identifier
geosheet.cpp(49) : error C2065: 'psh' : undeclared identifier
geosheet.cpp(49) : error C3861: 'GetPropSheetHeader': identifier not found
geosheet.cpp(50) : error C2065: 'psh' : undeclared identifier
geosheet.cpp(50) : error C2227: left of '->dwFlags' must point to class/struct/union/generic type
        type is ''unknown-type''
geosheet.cpp(51) : error C2065: 'psh' : undeclared identifier
geosheet.cpp(51) : error C2227: left of '->pfnCallback' must point to class/struct/union/generic type
        type is ''unknown-type''
编辑 我根据修改了DoModal函数;现在我得到了一个错误

代码:


您使用了CWndResizer类,可以调整propertysheet的大小

在头文件中包括cwndresizer类和该类的make对象。 CWndResizer树脂化剂

在cpp文件中,可以调整propertysheet中所有控件的大小

BOOL类名称::OnInitDialog() {

//IDC\u多边形\u要调整大小的列表控件id

ok = resizer.SetAnchor(IDC_POLYGONS_LIST,ANCHOR_LEFT|ANCHOR_TOP|ANCHOR_BOTTOM);
ASSERT(ok);
   bOk = resizer.SetParent("CS",IDC_STATIC_GROUPBOX2);
ASSERT(bOk);
}

有关更多详细信息,请点击此链接。

您使用了CWndResizer类,可以调整属性表的大小

在头文件中包括cwndresizer类和该类的make对象。 CWndResizer树脂化剂

在cpp文件中,可以调整propertysheet中所有控件的大小

BOOL类名称::OnInitDialog() {

//IDC\u多边形\u要调整大小的列表控件id

ok = resizer.SetAnchor(IDC_POLYGONS_LIST,ANCHOR_LEFT|ANCHOR_TOP|ANCHOR_BOTTOM);
ASSERT(ok);
   bOk = resizer.SetParent("CS",IDC_STATIC_GROUPBOX2);
ASSERT(bOk);
}

有关更多详细信息,请点击此链接。
错误是因为在.h中您忘记将回调设置为静态

int CGeoSheet ::XmnPropSheetCallback(HWND hWnd, UINT message, LPARAM lParam);
应该是

static int CGeoSheet::XmnPropSheetCallback(HWND hWnd, UINT message, LPARAM lParam);

错误是因为在.h中您忘记将回调设置为静态

int CGeoSheet ::XmnPropSheetCallback(HWND hWnd, UINT message, LPARAM lParam);
应该是

static int CGeoSheet::XmnPropSheetCallback(HWND hWnd, UINT message, LPARAM lParam);

缺少“AFX_OLDPROPSHEETHEADER”和GetPropSheetHeader定义意味着您缺少一些include。在Microsoft示例中查看您缺少的是哪一个。函数CGeoSheet::XmnPropSheetCallback在CGeoSheet和之间不能有空格::。
此外,它必须是静态的。我更正了空格,但错误仍然存在。顺便说一句,请参见编辑。
int(u cdecl*)(HWND,UINT,LPARAM)
XmnPropSheetCallback
方法的签名:返回int,\u cdecl调用样式并接受HWND,UINT和LPARAM。编译器说这与它需要的类型不同,即
typedef
ed为
PFNPROPSHEETCALLBACK
。可能需要将
XmnPropSheetCallback
声明为
static int CALLBACK CGeoSheet::XmnPropSheetCallback(HWND-HWND,UINT-message,LPARAM-LPARAM)缺少“AFX_OLDPROPSHEETHEADER”和GetPropSheetHeader定义意味着您缺少一些include。在Microsoft示例中查看您缺少的是哪一个。函数CGeoSheet::XmnPropSheetCallback在CGeoSheet和之间不能有空格::。
此外,它必须是静态的。我更正了空格,但错误仍然存在。顺便说一句,请参见编辑。
int(u cdecl*)(HWND,UINT,LPARAM)
XmnPropSheetCallback
方法的签名:返回int,\u cdecl调用样式并接受HWND,UINT和LPARAM。编译器说这与它需要的类型不同,即
typedef
ed为
PFNPROPSHEETCALLBACK
。可能需要将
XmnPropSheetCallback
声明为
static int CALLBACK CGeoSheet::XmnPropSheetCallback(HWND-HWND,UINT-message,LPARAM-LPARAM)