如果截获属性页的确定按钮事件
我做了个属性页,在其中的某个页中输入一些属性,当属性不符合要求时候,在用户单击确定时我希望给出提示,并不关闭属性页窗口。我该怎么做? 问题点数:50、回复次数:7Top
1 楼kim_fu(kim_fu)回复于 2003-12-04 19:54:52 得分 0
帮忙啊。Top
2 楼eagle_xmw(飞鹰)回复于 2003-12-04 20:20:28 得分 10
重载对应CPropertyPage的OnOK函数,如果属性不符合要求,不执行CPropertyPage::OnOK();
符合要求就执行CPropertyPage::OnOK();
Top
3 楼BuZhang_AP97091(Email:gold_ap97091@163.com,Q45324223)回复于 2003-12-04 20:24:41 得分 0
CPropertySheet::PressButton
BOOL PressButton( int nButton );
Return Value
Nonzero if successful; otherwise zero.
Parameters
nButton
nButton : Identifies the button to be pressed. This parameter can be one of the following values:
PSBTN_BACK Chooses the Back button.
PSBTN_NEXT Chooses the Next button.
PSBTN_FINISH Chooses the Finish button.
PSBTN_OK Chooses the OK button.
PSBTN_APPLYNOW Chooses the Apply Now button.
PSBTN_CANCEL Chooses the Cancel button.
PSBTN_HELP Chooses the Help button.
Remarks
Call this member function to simulate the choice of the specified button in a property sheet. SeePSM_PRESSBUTTON for more information about the Windows SDK Pressbutton message.
Example
// Simulate the selection of OK and Cancel buttons when Alt+K and
// Alt+C are pressed. CMyPropertySheet is a CPropertySheet-derived
// class.
BOOL CMyPropertySheet::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
{
BOOL altkey = GetKeyState(VK_MENU) < 0;
if (altkey)
{
BOOL handled = TRUE;
switch(toupper(pMsg->wParam))
{
case 'C': // for Alt+C - Cancel button
PressButton(PSBTN_CANCEL); // or EndDialog(IDCANCEL);
break;
case 'K': // for Alt+K - OK button
PressButton(PSBTN_OK); // or EndDialog(IDOK);
break;
default:
handled = FALSE;
}
if (handled)
return TRUE;
}
}
return CPropertySheet::PreTranslateMessage(pMsg);
}
Top
4 楼BuZhang_AP97091(Email:gold_ap97091@163.com,Q45324223)回复于 2003-12-04 20:26:19 得分 0
来自MSDN的文档,也许可行吧Top
5 楼eagle_xmw(飞鹰)回复于 2003-12-04 20:36:58 得分 0
楼上的,你看错题目了。
他要的是“在用户单击确定时我希望给出提示,并不关闭属性页窗口”,你给出的是模拟按下
某个按钮的函数Top
6 楼greensofter(MC.CN)回复于 2003-12-04 20:58:28 得分 0
自己重载OnOK()Top
7 楼COOL099(Alan Zjou)回复于 2003-12-04 21:16:15 得分 40
根據是哪個Sheet 重載OnWizardNext或是OnWizardFinish.
如.
LRESULT CWizard3::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
UpdateData(true);
if (m_DistFolder.GetLength()>0)
return CPropertyPage::OnWizardNext();
else
//Add you tip message here!
return -1;
}
Top




