如何在CPropertyPage上自定义PSN_SETACTIVE以显示其他页面?

问题描述

用户单击给定的选项卡(CPropertyPage)时,我想覆盖认行为:我不想激活该页面内容,而是要激活同一Cpropertysheet的另一个页面

根据本文档,这是可能的: https://docs.microsoft.com/en-us/windows/win32/controls/psn-setactive

返回零以接受激活,或者返回-1以激活下一页上一页(取决于用户单击“下一步”还是“后退”按钮)。要将激活设置为特定页面,请返回页面的资源标识符。

我成功实现了返回-1时的行为,但这不是我想要的。 当我尝试返回另一页的资源标识符时,获得的行为不是预期的(另一页未激活)。

下面是我的代码

BOOL CMyPropPage1::OnNotify(WParaM wParam,LParaM lParam,LRESULT* pResult)
{
    BOOL bRes = FALSE;
    NMHDR* pNMHDR = (NMHDR*)lParam;
    ASSERT(pNMHDR != NULL);
    switch (pNMHDR->code)
    {
        //This page becomes active
        case PSN_SETACTIVE:
        {
            LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;

            //prevent the display of this page and switch to another page :
            //LRESULT lValue = -1; //set the focus on next tab : OK,it works
            LRESULT lValue = IDD_PROPPAGE_3;  //try to set focus on page 3,//using page 3 resource identifier : it doesn't work
            ASSERT(pResult != NULL);
            *pResult = lValue;
            ASSERT(pNMHDR->hwndFrom != NULL);
            SetwindowLong(m_hWnd,DWL_MSGRESULT,lValue);
            bRes = TRUE;
            break;
        }
        default:
        {
            bRes = CPropertyPage::OnNotify(wParam,lParam,pResult);
        }
    }
    return bRes;
}

有人知道如何实现此行为吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)