Я пытаюсь сделать переоценку свойств, используя пример http://support.microsoft.com/kb/300606. Однако я получаю несколько ошибок в моем коде, которые я не знаю, как их преодолеть. Я создал лист свойств, используя мастер классов в моем диалоге. Мне нужна только функция изменения размера, упомянутая в статье. Любая помощь будет оценена.
.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 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 в соответствии с http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2005-09/msg00585.html; и теперь я получаю эту единственную ошибку.
Код:
int CGeoSheet::DoModal()
{
// Hook into property sheet creation code
m_psh.dwFlags |= PSH_USECALLBACK;
m_psh.pfnCallback = XmnPropSheetCallback;// <--Error
return CPropertySheet::DoModal();
}
Ошибка:
geosheet.cpp(50) : error C2440: '=' : cannot convert from 'int (__cdecl *)(HWND,UINT,LPARAM)' to 'PFNPROPSHEETCALLBACK'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Вы использовали класс CWndResizer, и вы можете изменить размер своей таблицы свойств.
в заголовочном файле включаем класс cwndresizer и создаем объект этого класса. CWndResizer resizer;
в файле cpp вы можете изменить размер всех элементов управления в таблице свойств.
BOOL ClassName :: OnInitDialog() {
CPropertySheet::OnInitDialog();
BOOL ok = FALSE;
ok = resizer.Hook(this);
ASSERT(ok);
//IDC_POLYGONS_LIST идентификатор управления, который вы хотите изменить.
ok = resizer.SetAnchor(IDC_POLYGONS_LIST,ANCHOR_LEFT|ANCHOR_TOP|ANCHOR_BOTTOM);
ASSERT(ok);
bOk = resizer.SetParent("CS",IDC_STATIC_GROUPBOX2);
ASSERT(bOk);
}
более подробно вы следуете по этой ссылке. http://www.codeproject.com/Articles/125068/MFC-C-Helper-Class-for-Window-Resizing
Ошибка заключается в том, что в.h вы забыли настроить обратный вызов на статический
int CGeoSheet ::XmnPropSheetCallback(HWND hWnd, UINT message, LPARAM lParam);
должно быть
static int CGeoSheet::XmnPropSheetCallback(HWND hWnd, UINT message, LPARAM lParam);