您的位置:首页 > 运维架构

CPropertySheet 使用技巧

2008-12-31 00:58 429 查看
前言:

其实,已经有前人做过关于CPropertySheet的使用介绍。
参考 http://www.codeguru.com/Cpp/controls/propertysheet/article.php/c3973/ 在该文中,作者介绍了以下一些应用技巧:
1.隐藏和移动标准按钮(ok, cancel,apply,help)
2.改变 Tab Label 的文本内容
3.改变 Tab Label 的文本字体
4.在Tab Label上使用image
5.在Property Sheet上放一个Bitmap
6.在Property Sheet上添加控件
7.在Property Sheet上部添加一个header
8.响应标准按钮

还有 MFC 提供的例子,建议大家先下载下来自己研究
Visual C++ MFC Samples
PROPDLG Sample: Demonstrates Property Sheet Support
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_PROPDLG.asp

在本文中,作者就介绍以下其中没有提及的一些功能和使用问题。
(基本上来说网上都有现成的实现,就贴URL。。)

1. 创建非模态的CPropertySheet并实现标准按钮的响应(非模态的CPropertySheet默认是没有任何button的)

Q146916:
How To Create a Modeless CPropertySheet with Standard Buttons
http://support.microsoft.com/kb/146916/en-us



2. 隐藏Apply按钮(前言链接中的实现也包括在以下链接的介绍中)

Q141039:
HOWTO: How to Hide the Apply Button in CPropertySheet
http://support.microsoft.com/kb/141039/en-us



3. 一个非模态的CPropertySheet是一个对话框或者CPropertySheet的子控件,当进行焦点切换时,应用程序无响应的问题

BOOL CMySheet::OnInitDialog()
{
ModifyStyleEx (0, WS_EX_CONTROLPARENT);//添加该句

return CPropertySheet::OnInitDialog();
}

详细解释请参阅:
Q149501:PRB: Child CPropertySheet Hangs If Focus Is Switched
http://support.microsoft.com/kb/149501/en-us



4. 在运行时改变 CPropertyPage 大小

Q143291:
How to resize CPropertyPages at run time in Visual C++
http://support.microsoft.com/kb/143291/en-us



5. 调用 CPropertySheet 的 DoModal 或 Create 时显示 “0xC0000005: Access Violation”错误

Q158552:
You receive a "0xC0000005: Access Violation" error message when you call the CPropertySheet::DoModal method or the Create method in Visual C++
http://support.microsoft.com/kb/158552/en-us



6. 设置 CPropertySheet 的 默认按钮

Q140587:HOWTO: How to Change Default Button on CPropertySheet
http://support.microsoft.com/kb/140587/en-us



7. Disable Tab

Q151662:
HOWTO: How To Disable Tabs in CPropertySheet
http://support.microsoft.com/kb/151662/en-us

disable tab同时使tab变灰
http://www.codeguru.com/cpp/controls/propertysheet/article.php/c549/
http://www.microsoft.com/msj/0398/c0398.aspx



8. 改变 Tab Label 的文本内容(前言链接中的实现也包括在以下链接的介绍中)

Q141487:
HOWTO: How to Change the Text in the Tabs of a CPropertySheet
http://support.microsoft.com/kb/141487/en-us



9. 在 CPropertySheet 的 title bar 上加帮助按钮 Context Help Button

Q244232:
How To Add Context Help Button (? Button) to Title Bar of CPropertySheet
http://support.microsoft.com/kb/244232/en-us



10. tab 标签行使用scrollbar

CPropertySheet在DoModal或create前调用EnableStackedTabs(FALSE);

11. 改变 CPropertyPage 字体

Q142170:
Prpfont.exe sample demonstrates how to set the desired font for your CPropertyPages in Visual C++
http://support.microsoft.com/kb/142170/en-us



12. 改变选中的Tab 的 文本颜色

Q206626:
How to change the text color of the selected property sheet tab in Visual C++
http://support.microsoft.com/kb/206626/en-us



13. 可改变大小的CPropertySheet

Q300606:
How to implement a resizable property sheet class that contains a menu bar in Visual C++ 6.0
http://support.microsoft.com/kb/300606/en-us



14. 改变 CPropertyPage 上控件的默认focus

Q148388:
HOWTO: How to Change Default Control Focus on CPropertyPage
http://support.microsoft.com/kb/148388/en-us



15. wizard 风格的CPropertySheet同时显示Back/Next button 和 Finish button

默认情况下,Finish是在Next下的,并且是hidden的。所以如果要同时显示,需要show finish,并且移动Next。
Q143210:
HOWTO: How to Add the Finish Button to a Wizard Property Sheet
http://support.microsoft.com/kb/143210/en-us
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: