Help: CPropertySheet and CPropertyPage Home | Overview | How Do I | Sample | TutorialObjects of classCPropertySheet represent property sheets, also called tab dialog boxes. A property sheet consists of a CPropertySheet object and one or more CPropertyPage objects. A property sheet is displayed by the framework as a window with a set of tab indices, with which the user selects the current page, and an area for the currently selected page. Using Help in Property Sheets Help in CPropertySheet is supported by the F1 key and the Help button only. The Help button appears in the application framework by default. No intervention by the user is necessary. When the user adds the help information for each of the pages inside the property sheet, the help mechanism automatically displays the help for that page when the Help button is clicked.You can deactivate the Help button capability by modifying m_psh in the property sheet object as follows:mySheet.m_psh.dwFlags &= ~(PSH_HASHELP);You can activate the Help button again with the following:mySheet.m_psh.dwFlags |= PSH_HASHELP;The m_psh variable is of type PROPSHEETPAGE. The dwFlags field of m_psh determines if the Help button of the property sheet (the parent of the property page) is enabled or disabled.
GetDlgItem(IDOK)->EnableWindow(FALSE);//在他的初始化函数中
1.可以在OnOK()里做检查,给出提示,如果不满足条件就return;而不调用父的OnOK();
2.可以在一开始就把确定按钮设为灰,即用button.EnableWindow(FALSE),然后在每次输入后检查是否满足条件,满足后再button.EnableWindow(TRUE);
方法1里 提到的OnOK() 是属性页里的每个页对话框的OnOK()吧。我有三个页,是不是在三个页里都得检查,如果有一个页返回调用父的OnOK()是不是就关闭属性页了?
方法2有点麻烦。
判断是否用户进行更改
CPropertySheet SetupSheet; SetupSheet.m_psh.dwFlags = (SetupSheet.m_psh.dwFlags) | PSH_NOAPPLYNOW ;
SetupSheet.m_psh.dwFlags &= ~(PSH_HASHELP);
Home | Overview | How Do I | Sample | TutorialObjects of classCPropertySheet represent property sheets, also called tab dialog boxes. A property sheet consists of a CPropertySheet object and one or more CPropertyPage objects. A property sheet is displayed by the framework as a window with a set of tab indices, with which the user selects the current page, and an area for the currently selected page. Using Help in Property Sheets
Help in CPropertySheet is supported by the F1 key and the Help button only. The Help button appears in the application framework by default. No intervention by the user is necessary. When the user adds the help information for each of the pages inside the property sheet, the help mechanism automatically displays the help for that page when the Help button is clicked.You can deactivate the Help button capability by modifying m_psh in the property sheet object as follows:mySheet.m_psh.dwFlags &= ~(PSH_HASHELP);You can activate the Help button again with the following:mySheet.m_psh.dwFlags |= PSH_HASHELP;The m_psh variable is of type PROPSHEETPAGE. The dwFlags field of m_psh determines if the Help button of the property sheet (the parent of the property page) is enabled or disabled.
我发现 CPropertySheet 没办法重栽OnOK()方法啊。
我在我的ClassView里右键单击,然后选 Add Virtual Function后,在弹出的对话框里找不到OnOK()方法啊。
而这个属性页里的每个对话框却都可以找到OnOK()方法。奇怪!
在.h中写 virtual void OnOK();
在.cpp中直接写:void CMyPropertySheet::OnOK()
{
}应该可以吧。
你可以参考,windows的各种属性面,你可以发现它们都是把一个CTabCtrl放在一个对话框中的。然后就可以重载对话框的OnOk()
2、或者你可以用另外一种办法,在属性框初始话时,加上如下代码:
CWnd *pWnd=GetDlgItem(IDOK);
pWnd->EnableWindow(FALSE);
这样,条件不满足,ok按钮就无法响应点击事件
在所有的条件填写以后作判断,条件不满足,执行如下代码:
CWnd *pWnd=GetDlgItem(IDOK);
pWnd->EnableWindow(FALSE);
这样,条件不满足,ok按钮就无法响应点击事件
你们怎么都说有OnOk()函数呢?我怎么就是找不到我的属性页的OnOk()函数呢。
我做属性页的方法如下:
1。根据属性页有几个也面,就创建几个对话框,对话框是在资源里选择插入
然后选择Dialog下的IDD_POPPPAGE_SMALL。然后给每个一对话框创建一个类。继承自CPropertyPage。
2。创建一个新类。如CMyProperSheet继承自CPropertySheet。
3。在CMyProperSheet的类里创建上面创建的对话框类的变量 如 m_Page1,m_Pge2
4。在CMyProperSheet的CMyProperSheet::CMyProperSheet()里写入如下代码
CMyProperSheet::CMyProperSheet()
{
AddPage((CPropertyPage *) &m_Page1);
AddPage((CPropertyPage *) &m_Page2);
}
5。属性页创建完毕。使用的时候代码如下
CMyProperSheet m_mySheet;
m_mySheet.DoModal();我在 CMyProperSheet里就是找不到OnOk()方法啊。是不是我创建属性页的方法有问题?大家都是怎么创建属性页的?
我试过了。不行。
具体可见http://www.lzu.edu.cn/netteach/jiaochen/vc++5.0/vc++5.0/chap5/chap5_5.htm。
朋友,这里还有其它的几种实现方案,其中第5种可以实现你的要求。
当然还可以这样做,那就是把系统提供的确定按钮隐藏掉,再加上一个自己的按钮,然后,在自己的按钮中处理。怎样加入自己的按钮可以见方案4.
也可见http://sanjianxia.myrice.com/pre/12.htm.里面有继承一个CPropertySheet.的全攻略。
CPropertySheet的OK按钮的ID分别是IDOK。在按下确定按钮后,其子类应该作出响应,由于ClassWizard不能为它提供确定按钮的BN_CLICKED消息处理函数,故必须手工声明和定义消息处理函数OnOk(),并在消息映射表中手工加入IDOK的BN_CLICKED消息映射,该映射是通过ON_BN_CLICKED宏实现的(参见一般按钮的点击事件的在消息中的申明)。