Apr 30, 2016 at 3:35am UTC
I was previously using VS2010 and Windows 7, and was able to create and use Property Sheets with various pages.
But now with VS2015 and Windows 10, things do not work well.
The below code is self explanatory:
Class Derived from CPropertySheet:
// CPr_Sheet
IMPLEMENT_DYNAMIC(CPr_Sheet, CPropertySheet)
CPr_Sheet::CPr_Sheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
// CODE IGNORED OR NOT CALLED
}
CPr_Sheet::CPr_Sheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
}
CPr_Sheet::~CPr_Sheet()
{
}
BEGIN_MESSAGE_MAP(CPr_Sheet, CPropertySheet)
ON_COMMAND(IDOK, &CPr_Sheet::OnIdok)
ON_COMMAND(IDHELP, &CPr_Sheet::OnIdhelp)
ON_COMMAND(IDCANCEL, &CPr_Sheet::OnIdcancel)
END_MESSAGE_MAP()
// CPr_Sheet message handlers
BOOL CPr_Sheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
// NOT CALLED
return TRUE;
}
void CPr_Sheet::OnIdok()
{
// NOT CALLED
}
void CPr_Sheet::OnIdhelp()
{
// CODE IGNORED (GOES STRAIGHT TO MICROSOFT HELP)
}
void CPr_Sheet::OnIdcancel()
{
// CODE IGNORED
}
BOOL CPr_Sheet::OnCommand(WPARAM wParam, LPARAM lParam)
{
// CODE IGNORED
return CPropertySheet::OnCommand(wParam, lParam);
}
The Pages have code like the following:
IMPLEMENT_DYNAMIC(CPr_Page_1, CPropertyPage)
CPr_Page_1::CPr_Page_1()
: CPropertyPage(IDD_PR_PAGE_1)
{
}
CPr_Page_1::~CPr_Page_1()
{
}
void CPr_Page_1::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CPr_Page_1, CPropertyPage)
END_MESSAGE_MAP()
BOOL CPr_Page_1::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// WORKS CORRECTLY
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPr_Page_1::OnOK()
{
// WORKS CORRECTLY
CPropertyPage::OnOK();
}
The call to the PropertySheet is:
CPropertySheet Pr_Sheet;
CPr_Page_1 Pr_Page_1;
CPr_Page_2 Pr_Page_2;
Pr_Sheet.AddPage (&Pr_Page_1);
Pr_Sheet.AddPage (&Pr_Page_2);
Pr_Sheet.SetTitle(_T("Property Sheet"));
int nResponse = Pr_Sheet.DoModal();
if (nResponse == IDOK)
{
}
Thanks in advance for any comments.