翻譯|使用教程|編輯:鮑佳佳|2020-09-23 14:55:35.260|閱讀 648 次
概述:在版本19.2之前,不能夠?qū)⒖丶闹黝}應(yīng)用于ToolkitPro控件(例如CXTPEdit,CXTPTree,CXTPListBox,CXTPListCtrl和CXTPPropertyGrid)中的滾動(dòng)條。因?yàn)橥ㄓ肳indows控件擁有自己顯示和處理的滾動(dòng)條的方式,并且覆蓋Windows通用控件的行為以及保持完全的向后兼容性在技術(shù)上非常具有挑戰(zhàn)性,因此導(dǎo)致需要考慮一定的可使用進(jìn)的解決方案。本文介紹了關(guān)鍵點(diǎn),并試圖回答可能出現(xiàn)的常見(jiàn)問(wèn)題。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
Xtreme Toolkit Pro是MFC開(kāi)發(fā)中最全面界面控件套包,它提供了Windows開(kāi)發(fā)所需要的11種主流的Visual C++ MFC控件,包括Command Bars、Controls、Chart Pro、Calendar、Docking Pane、Property Grid、Report Control、Shortcut Bar、Syntax Edit、Skin Framework 和Task Panel。如果對(duì)產(chǎn)品感興趣的話歡迎下載Xtreme Toolkit Pro最新試用版! 點(diǎn)擊獲取更多免費(fèi)Xtreme Toolkit Pro教程、視頻、示例!
【同類(lèi)產(chǎn)品推薦】
在版本19.2之前,不能夠?qū)⒖丶闹黝}應(yīng)用于ToolkitPro控件(例如CXTPEdit,CXTPTree,CXTPListBox,CXTPListCtrl和CXTPPropertyGrid)中的滾動(dòng)條。因?yàn)橥ㄓ肳indows控件擁有自己顯示和處理的滾動(dòng)條的方式,并且覆蓋Windows通用控件的行為以及保持完全的向后兼容性在技術(shù)上非常具有挑戰(zhàn)性,因此導(dǎo)致需要考慮一定的可使用進(jìn)的解決方案。本文介紹了關(guān)鍵點(diǎn),并試圖回答可能出現(xiàn)的常見(jiàn)問(wèn)題。
解決方案實(shí)際上,以下類(lèi)保持不變,并且仍使用未應(yīng)用主題的標(biāo)準(zhǔn)Windows滾動(dòng)條:
為了能夠應(yīng)用滾動(dòng)條主題或自定義滾動(dòng)條類(lèi),必須使用或派生新特殊適配器模板類(lèi)的新控件類(lèi)CXTPScrollable<Base>。
對(duì)于最常見(jiàn)的用例,將應(yīng)用程序中使用的控件類(lèi)名替換為對(duì)應(yīng)的類(lèi)名就足夠了,這些類(lèi)名源自CXTPScrollable:
CXTPPropertyGrid這是一種特殊情況,它沒(méi)有其他CXTPScrollable派生版本,僅在內(nèi)部使用新方法,保持完全向后兼容,并且除非確認(rèn)新添加會(huì)引起阻塞問(wèn)題,否則不需要任何特殊考慮。如果從版本19.3開(kāi)始是這種情況,則可以禁用PropertyGrid滾動(dòng)條主題。
如果從版本19.3開(kāi)始是這種情況,則可以選擇禁用滾動(dòng)條主題,以回退到19.2之前的行為。對(duì)于這個(gè)無(wú)論是取消對(duì)XTPPropertyGrid.h 文件中 (C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v19.3.0\Source\PropertyGrid\XTPPropertyGrid.h) 的XTP_PROPERTY_GRID_DISABLE_SCROLLBAR_THEMES 宏或?qū)⒑甓x為T(mén)oolkitPro或PropertyGrid庫(kù)項(xiàng)目的C ++編譯器屬性,然后重新構(gòu)建ToolkitPro或PropertyGrid項(xiàng)目,以使更改生效。
使用這些類(lèi)將確保控件將自動(dòng)具有合適的滾動(dòng)條主題,并可以使用新方法設(shè)置自定義滾動(dòng)條主題:
void SetScrollBarTheme(XTPScrollBarTheme nTheme);
使用從CXTPScrollable派生的類(lèi)同時(shí)也會(huì)施加某些限制:
CXTPTreeCtrl m_tree; // As CXTPTreeCtrl is derived from CTreeCtrl it uses CTreeCtrl::Create overloaded // method which has signature different from CWnd::Create and thus should not be used for CXTPScrollableTreeCtrl m_tree.Create(WS_CHILD | TVS_LINESATROOT, rc, this, IDC_TREE);
Example of the fixed code: CXTPScrollableTreeCtrl m_tree; // Call CWnd::Create overridden method to ensure it can be compiled using all Microsoft C++ compilers m_tree.Create(_T("SysTreeView32"), NULL, WS_CHILD | TVS_LINESATROOT, rc, this, IDC_TREE);
CXTPEdit m_edtSingleLine; CXTPScrollableEdit m_edtMultiline; // IDC_EDIT_SINGLELINE is NOT derived from CXTPScrollable and thus can be referenced by Resize control by ID only. SetResize(IDC_EDIT_SINGLELINE, XTP_ANCHOR_TOPLEFT, CXTPResizePoint(1.f / 3.f, 0)); // IDC_EDIT_MULTILINE is derived from CXTPScrollable and thus must be referenced by Resize control by both ID and handle value. SetResize(IDC_EDIT_MULTILINE, m_edtMultiline, XTP_ANCHOR_TOPLEFT, CXTPResizePoint(1.f / 3.f, 0));從CXTPScrollable派生自定義控件
如果控件來(lái)自于受支持的類(lèi)并使用標(biāo)準(zhǔn)的Windows滾動(dòng)條,則可以使用CXTPScrollable自定義控件來(lái)將其應(yīng)用于滾動(dòng)條。
有兩種可能的用例:
對(duì)于第一種情況,ToolkitPro為相應(yīng)的基類(lèi)提供了適配器模板:
例:
// Your existing classes class CCustomEdit : public CEdit { /*...*/ }; class CCustomTreeCtrl : public CXTPTreeCtrl { /*...*/ }; // Your new derived classes class CScrollableCustomEdit : public CXTPScrollableEditT<CCustomEdit> { /*...*/ }; class CScrollableTreeCtrl : public CXTPScrollableEditT<CCustomTreeCtrl> { /*...*/ };
在其他情況下,當(dāng)您需要派生另一種自定義控件時(shí),則需要實(shí)現(xiàn) IXTPScrollable接口:
// Your existing class class CCustomControl : public CWnd { public: void InitializeCustomState(); // ... }; // Your new derived class. // Some or all method may have default implementation, the example demonstrates overloading of all methods. class CScrollableCustomControl : public CXTPScrollable { public: // IXTPScrollable overrides virtual BOOL HasVScroll(DWORD dwStyle, DWORD dwExStyle) const { // Determine if control has vertical scroll. return 0 != (GetStyle() & WS_VSCROLL); } virtual BOOL HasHScroll(DWORD dwStyle, DWORD dwExStyle) const { // Determine if control has horizontal scroll. return 0 != (GetStyle() & WS_HSCROLL); } virtual BOOL HasLeftScrollbar(DWORD dwStyle, DWORD dwExStyle) const { // Determine if control has scroll bar on the lets. return 0 != (GetExStyle() & WS_EX_LEFTSCROLLBAR); } virtual void DisableScrollbars() { // Force default scroll bars to hide. DisableScrollbars(*this); } virtual void DisableScrollbars(CWnd& wnd) { // Force default scroll bars to hide for a specific window. wnd.ModifyStyle(WS_VSCROLL | WS_HSCROLL, 0); } virtual CScrollBar* CreateBar() const { // Create scroll bar instance. return new CXTPScrollBarCtrl(); } virtual CWnd* CreateControl() const { // Re-create custom control instance and perform default initialization if necessary. CCustomControl* pNewCtrl = new CCustomControl(); VERIFY(NULL != pNewCtrl); pNewCtrl->InitializeCustomState(); return pNewCtrl; } virtual DWORD FilterStyle(DWORD dwStyle) const { return dwStyle; } virtual DWORD FilterExStyle(DWORD dwExStyle) const { return dwExStyle; } virtual BOOL RequiresMouseWheelOverriding() const { return true; } // ... };
今天的內(nèi)容就是這些了,下載最新版Xtreme ToolKit Pro并在下方評(píng)論區(qū)分享您對(duì)該產(chǎn)品的想法。您的反饋意見(jiàn)可幫助我們?cè)谝院蟮母轮姓业秸_的方向,慧都作為Codejock的正版代理商現(xiàn)Xtreme ToolKit Pro正版授權(quán)最高立減2000元! Xtreme Command Bars在線訂購(gòu)最低僅需1105元!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: