关于BCG中CBCGPButton的问题

pdexcl 2009-03-18 10:38:53
我在CBCGPDockingControlBar的子类中建立一个CBCGPButton。
头文件中声明:CBCGPButton m_constrainButton;
在cpp文件的OnCreate函数中创建如下:
const DWORD dwViewStyle = BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE; //注意是CheckBox
if (!m_constrainButton.Create (_T("Constrain"), dwViewStyle, rectDummy, this, IDC_CONSTRAIN_CHECK))
{
TRACE0("Failed to create constrain check \n");
return -1; // fail to create
}
运行时这个CheckBox的背景总是黑色的,只能看到前面的方框,不管我怎么设置CBCGPButton的属性都不管用,比如我设置m_constrainButton.SetFaceColor(RGB(100,0,0),TRUE);改变里面的颜色,运行时没有任何反应,还是一片黑色,如果创建时改为Button类型时就没有问题,还有,如果我声明的是CButton也没有问题。但是这些都不是我想要的。哎,怎么办,这个问题好久了没有解决,大侠们帮帮忙!
...全文
788 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
pdexcl 2009-03-19
  • 打赏
  • 举报
回复
没有其他办法了吗?只能处理WM_ERASEBKGND等消息吗?
pdexcl 2009-03-18
  • 打赏
  • 举报
回复
自己处理checkbox的WM_PRINT和WM_ERASEBKGND消息时,是不是所有的都需要自绘,包括前面的check小方框
fandh 2009-03-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 abesky 的回复:]
公共控件的checkbox如何?不行可能需要自己处理checkbox的WM_PRINT和WM_ERASEBKGND消息自己处理一下背景
或者WM_CTLCOLOR消息
[/Quote]
建议试一下!
abesky 2009-03-18
  • 打赏
  • 举报
回复
公共控件的checkbox如何?不行可能需要自己处理checkbox的WM_PRINT和WM_ERASEBKGND消息自己处理一下背景
或者WM_CTLCOLOR消息
pdexcl 2009-03-18
  • 打赏
  • 举报
回复
它demo里面所有的程序我都看了,没有在DockingBar上放置CheckBox的例子,大多都是在对话框上放置CheckBox。
还有transparent属性我也设置过,背景倒是可以正常显示了,但是前面的check小方框看不见了。
CBCGPButton所有可能的public属性我都试过了,还是不行
allenhiman 2009-03-18
  • 打赏
  • 举报
回复
看看它的demo里如何做的。另外它不是开源的吗,看看它的相关代码。是不是要设定transparent属性
showxier 2009-03-18
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 pdexcl 的回复:]
自己处理checkbox的WM_PRINT和WM_ERASEBKGND消息时,是不是所有的都需要自绘,包括前面的check小方框
[/Quote]

是的,不过对于checkbox因为只是button中的其中一个类型, 所以处理WM_DRAWITEM和WM_ERASEBKGND更好.

checkbox与push按钮的重绘是一样的,但是多了选中和非选中, 可以先处理背景, 然后处理边框(4种常见状态), 再处理边框内背景, 然后再处理选中和非选中两个状态.
使用方法: 1、解压至C:\Program Files目录下(密码:xiaoqing); 2、双击导入注册表C:\Program Files\BCGSoft\BCGControlBarPro\bcgcontrolbarpro.12.00.reg; 3、运行向导C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBProIntegrationWizard.exe。 与其它不同之处: 1、包含完整的源代码、帮助文件; 2、已经对 BCGPAppWizard2005 的向导进行汉化,在 Visual Studio 2008(2010) 可使用文向导 BCGPAppWizard (参考 Visual Studio 2008 原有的文向导,如果您想学习汉化向导,参考目录是:C:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\AppWiz\MFC\Application\templates\2052) 关于静态链接: 1、首先必须在运行向导BCGCBProIntegrationWizard.exe时已经编译静态库; 2、在 Visual Studio 建立项目向导时,选择静态链接即可。 关于使用 Office2007、2010 风格: 如果您使用了这些新风格,必须在项目包括这些资源,否则 debug 版本启动时会报错(缺少资源,release版本不会提示,但显示不正常),具体有二种方法: 1、直接在“解决方案资源管理器”-“资源文件”点右键,“添加”-“现有项”,把C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles所有扩展名为 .rc 的资源包括进来即可。 2、直接在“资源视图”-“您的项目”上点右键,选择“资源包括”,在“资源包括”的“编译时指令”的#include "BCGCBPro.rc"后面添加以下代码: #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Aqua.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Luna.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Obsidian.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Silver.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2010White.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyleCarbon.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyleScenic.rc" 3、如果使用动态库链接,请手工编译C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\Office2007_styles.sln或者build_all.dsp 仅为学习使用,下载后24小时内删除,请支持 BCGSoft 购买正版,本人不提供技术支持,不对任何负责。 尊重他人劳动成果,欢迎与大家分享成果。 官方更新说明: http://www.bcgsoft.com/bcgcontrolbarpro-versions.htm Version 12.0. Released 01/20/2010 New features CBCGPVisualManager2010 implements Microsoft Office 2010 Beta 1 color themes: Blue theme (see screenshot) Black theme (see screenshot) Silver theme (see screenshot) Just activate CBCGPVisualManager2010 to use these new themes in your application: CBCGPVisualManager::SetDefaultManager (RUNTIME_CLASS (CBCGPVisualManager2010)); Please run BCGPMSOffice2007Demo, DrawCli or BCGPOrganizer to see this feature in action. Added Microsoft Office 2010-style Ribbon Backstage View (see screenshot). The following new methods were added to CBCGPRibbonBar class: SetBackstageMode: enables/disables Backstage View mode. IsBackstageMode: returns TRUE if Backstage View mode is enabled. AddBackstageCategory: creates Backstage View category. GetBackstageCategory: returns Backstage View category. IsBackstageViewActive: returns TRUE if Backstage View is currently active. By default, the Ribbon Application button will be displayed with the default (blue) color, but developers can customize its appearance by calling visual manager's new method 'SetMainButtonColor' (see screenshot). CBCGPRibbonBar::AddBackstageCategory returns a pointer to the new class object - CBCGPRibbonBackstageViewPanel. Usually, you'll need to call the following class methods to create your backstage view: AddCommand: add a single command button such as "Save", "Save As" or "Exit". AddView: add a button with attached right-side form ("Print", "Recent Files" and so on). There are 2 new classes that should be used for implementing right-side views: CBCGPRibbonBackstageViewItemForm: a single page dialog CBCGPRibbonBackstageViewItemPropertySheet: multi-page Please note that our Application Wizards were updated and now, when you're creating a new, Ribbon-based application, you can choose "Backstage view" option (see screenshot) and initial backstage view code will be automatically generated for your pleasure!. The Ribbon bar Application ("main") Button can display a text label instead of icon in the "scenic" mode (usually "File" in English language UI). The following new methods were added to the CBCGPRibbonMainButton class: SetScenicText GetScenicText Implemented ability to add Ribbon Galleries to the dialogs (see screenshot). The new class CBCGPRibbonGalleryCtrl may be used for this purpose. Please take a look at BCGPMSOffice2007Demo example (Backstage view pages) to see this new control in action. Implemented Resizable Dialogs support (see screenshot1 and screenshot2): Added 2 new classes: CBCGPControlsLayout: implements the base class for all layout managers. CBCGPStaticLayout: implements "static" layout management based on anchors. To enable layout support, you've to call EnableLayout/GetLayout methods in the following classes: CBCGPDialog CBCGPDialogBar CBCGPropertyPage CBCGPFormView Please run ResizableForm new sample to see this feature in action. In addition, you can see this feature in the following examples and samples: BCGPMSOffice2007Demo: "Clipboard" Pane and Backstage view. BCGPOrganizer: resizable dialog bar. RibbonGadgets: backstage view. ToolBoxDemo: resizable form Significantly improved CBCGPVisualManagerVS2010 (see screenshot): The color scheme is identical to Visual Studio 2010 Beta 2. Added a new Smart Docking style (BCGP_SDT_VS2010). You can run BCGPVisualStudioGUIDemo example to examine this look. Added content scrolling support to CBCGPDockingControlBar-derived classes (see screenshot). By default, the scrolling is implemented in CBCGPDialogBar class only, but you can easily add this support to any CBCGPDockingControlBar-derived class (please take a look at BCGPGridExample example, COutputBar class). CBCGPDockingBarScrollButton class implements docking pane scroll button (vertical and horizontal) and its look depends on the currently activated visual manager. Calculator control has been significantly improved: All calculator buttons are drawn using built-in bitmaps and use visual manager appearance (see screenshot). Implemented extended commands. Using a new method CBCGPCalculator::SetExtendedCommands developers can add a lot of build-in calculator commands such as idCommandAdvSin, idCommandAdvCos, idCommandAdvTan and others. CBCGPRibbonComboBox allows to display a popup calculator window. Just call CBCGPRibbonComboBox::EnableCalculator method to assign a calculator to the ribbon combobox. Override a new 'OnCalculatorUserCommand' method to implement your calculator commands. Please take a look at BCGPControls example and RibbonGadgets/SkinnedDialog samples to see these new features in action. The following new methods were added to CBCGPVisualManager class: OnDrawDockingBarScrollButton OnDrawCaptionBarCloseButton GetHeaderCtrlTextColor OnFillPropSheetHeaderArea OnDrawDateTimeDropButton GetCalculatorButtonTextColor GetEditCtrlSelectionBkColor GetEditCtrlSelectionTextColor OnDrawDlgSizeBox OnFillRibbonBackstageForm OnDrawRibbonMinimizeButtonImage GetRibbonMinimizeButtonImageSize GetRibbonButtonsGroupHorzMargin IsDrawRibbonGroupSeparator OnDrawRibbonGroupSeparator GetRibbonBackstageTopLineHeight OnDrawRibbonBackstageTopLine SetMainButtonColor GetMainButtonColor IsOwnerDrawDlgSeparator OnDrawDlgSeparator CBCGPPropertySheet has a new mode: PropSheetLook_AeroWizard (see screenshot). In general, this mode has been designed and implemented for Vista/Windows 7 Aero, but you can use it in any OSs/modes (see screenshot). The glass (aero) area can be combined with a page header - we've added a new optional parameter 'bDrawHeaderOnAeroCaption' to EnablePageHeader method. Please take a look at PropSheetDemo sample to see this mode. Added support for the Internet Explorer-like new tab in CBCGPTabWnd class (see screenshot). Call EnableNewTab method to enable this feature. Please take a look BCGPIE7Demo example to see this feature in action. Grid and Report controls changes: Added option to select items by clicks on grid header: New header flag BCGP_GRID_HEADER_SELECT. Implemented color themes for the new visual managers such as CBCGPVisualManager2010 (Office 2010-like) and CBCGPVisualManagerVS2010 (Visual Studio 2010-like) (see screenshot). Improved grid printing support. The following new classes were added: CBCGPGridPage class: this class is used by the grid control to store print pages. A print page specifies which area of the grid is printed at the specified page. The grid counts in items in vertical direction. The grid counts in pixels in horizontal direction. CBCGPGridPageInfo class: This class is used by the grid control to store information about the printing range and the currently printing page. It is stored in CBCGPGridCtrl::m_PrintParams::m_pageInfo member and in CPrintInfo::m_lpUserData member of the CPrintInfo object used while printing at the current print session. Added an option to deselect items. To deselect an item please use SetCurSel with SM_INVERT_SEL flag. New functions were added: CBCGPGridCtrl::EnableInvertSelOnCtrl CBCGPGridCtrl::IsInvertSelOnCtrlEnabled Changes in header click events: New BCGM_GRID_COLUMN_CLICK message. Added CBCGPGridCtrl::OnHeaderColumnRClick. Modified CBCGPGridCtrl::OnHeaderColumnClick. Items align support: New CBCGPGridItem::GetAlign function. Item's alignment is specified by CBCGPGridCtrl::SetColumnAlign. Grid horizontal pagination support. Added CBCGPGridPage::m_nWidth - page width, CBCGPGridPageInfo::m_nPageWidth - width of currently printed page. See CBCGPGridPage class, CBCGPGridPageInfo class. Drag-and-Drop support (see new "Drag and Drop" tab in BCGPGridExample sample): New message BCGM_GRID_BEGINDRAG. Added methods EnableDragSelection, IsDragSelectionEnabled, EnableDragSelectionBorder, IsDragSelectionBorderEnabled, StartDragItems and HitTestSelectionBorder. Extended in-place edit customization support (see new "Easy Input" tab in BCGPGridExample sample): New messages BCGM_GRID_ITEM_BEGININPLACEEDIT, BCGM_GRID_ITEM_ENDINPLACEEDIT. New functions OnBeginInplaceEdit, OnEndInplaceEdit, CanBeginInplaceEditOnChar, CanEndInplaceEditOnChar, OnInplaceEditKeyDown, OnInplaceEditSetSel. New BCGPGRID_ITEM_INFO::dwResultCode member. See BCGPGRID_ITEM_INFO struct. New method SetClearInplaceEditOnEnter. Call SetClearInplaceEditOnEnter (FALSE) to disable grid from clearing content of the item on Enter. Added CBCGPGridCtrl::GoToNextItem method. CBCGPGridCtrl::EnsureVisible is now virtual. Added navigation by TAB (Shift+TAB) key. Added "Ctrl+Z" (Undo) handler for in-place edit of the grid item. Changes in CBCGPGridCtrl::SetCurSel for SM_SET_ACTIVE_ITEM style. Grid item with combo-box now supports F4 to open drop-down list. Added a new parameter CBCGPMDITabParams::m_bReuseRemovedTabGroups. If this flag is TRUE MDI tab groups which were marked as removed will be used for new groups. This reduces memory consumption for applications that frequently create and remove groups. Added OpenType font support for font combo boxes. Added keyboard and MS Active Accessibility support to CBCGPTasksPane class. CBCGPEditCtrl::ExportBuffer has a new optional parameter 'BOOL bForceAnsi'. Setting it to TRUE forces exporting editor's text in ANSI format. CBCGPRibbonStatusBarPane constructor and SetAnimationList method have a new optional parameter 'BOOL bDontScaleInHighDPIMode'. Set it to TRUE if you don't need to scale pane image in the High DPI mode. When user clicks on the glass area of CBCGPExplorerToolBar window, the application window is moved now. Added CBCGPCalendarBar::GetState method - returns the calendar style flags specified in SetState method. CBCGPRibbonEdit displays a drop-down window upon pressing F4 key. Added CBCGPShellManager::IsControlPanel method. Added new font 'fontCaption' to BCGPGLOBAL_DATA. This font will be useful for displaying caption texts. CBCGPStatic has a new member: m_clrText. You can set this member to colorize text labels (see SkinnedDialog sample). New method CBCGPDockManager::ShowFloatingBars shows/hides floating panes. CBCGPListBox control can work with left-side icons and item group headers now. The following new methods were added: SetImageList: set items image list SetItemImage: associate item with a specific icon AddCaption: add a group caption Changes in examples and samples: BCGPControls: "Calculator" page demonstrates new calculator features BCGPGridExample: added new visual managers and new 2 tabs: "Drag and Drop" and "Easy Input" BCGPIE7Demo: the tab control was fully redesigned and derived from the library MDI Tab control. BCGPMSOffice2007Demo: added MS Office 2010 Backstage view. "Clipboard" pane demonstrates a new layout manager. BCGPVisualStudioGUIDemo: Start Page view can be converted to docking control bar. DrawCli: added MS Office 2010 Backstage view and new visual managers. PropSheetDemo: added Aero Wizard demonstration. ResizableForm: new sample, demonstrates how to use a new layout manager along with dialogs, dialog bars, property sheets and form views. RibbonGadgets: added MS Office 2010 Backstage view and edit boxes with calculator. SkinnedDialog: added edit box with calculator and text labels with a custom colors. Changes in the Ribbon Designer: Added "Calculator" element. Support for three new styles introduced in Microsoft Office 2010 (blue, silver, black) Ribbon elements can be edited by double click. Image lists can be loaded from files. Implemented icon editing for Palette (Gallery) Buttons. Fixes: FireChangingActiveTab is called from CBCGPOutlookWnd::SetActiveTab now. Fixed resource leak in CBCGPUserTool::DrawToolIcon Fixed problem with a slider's thumb location in CBCGPRibbonSlider::SetThumbRect in the High DPI mode. Improved appearance of the calendar drop-down button in CBCGPDateTimeCtrl. Fixed problem with setting editbox auto-complete mode in Windows 9x/NT4 CBCGP***FrameWnd::WinHelp dwData parameter has DWORD_PTR type now. This fixes 64-bit compatibility issue with this virtual method. Fixed memory leak in CBCGPPngImage::LoadFromBuffer (VS.NET 2003 or higher, BCGP_EXCLUDE_GDI_PLUS is defined). CBCGPGroup is properly handles WM_SETTEXT message now. CBCGPCalendar always closes dropped-down month picker when the calendar is being destroyed. CBCGPRibbonEdit::OnDraw correctly draws edit box label in case of center/right-side control alignment. Fixed appearance of CBCGPExCheckList items in the high DPI mode (under VC++ 6.0). Fixed problem with displaying disabled check boxes (CBCGPButton class) when some visual managers are activated. Fixed problem with CBCGPHeaderCtrl items text color when some visual managers are activated. Fixed problem with vertical scrolling of elements in CBCGPRibbonPanel::OnKey. CBCGPEdit correctly draws a browse button image and text when control is located on the glass (aero) area. CBCGPEdit uses visual manager color them when control has ES_READONLY style. CBCGPStatic doesn't perform the custom drawing if it has a style like icon, rectangle or frame. CBCGPPropertySheet: fixed some problems with repositioning and redrawing navigation buttons. Fixed some visual problems in owner-draw frame/dialog captions. Ribbon Main Button scenic icon is correctly painted in high DPI mode now. Fixed problem with text alignment in grid columns. CBCGPGridCtrl::SetColumnAlign is working properly now. Fixed bug with using different horizontal color and vertical color for the grid lines. The m_clrVertLine setting did not work when m_bGridItemBorders flag was switched on. Fixed problem with clicking on CBCGPGridURLItem in read-write mode. Fixed a bug with automatic sizing of grid columns. The bug appeared when auto-sizing was enabled with EnableColumnAutoSize(TRUE). Fixed bug with "Ctrl+A" for in-place editing of grid items. "Ctrl+A" selects all text inside in-place editor during in-place editing, instead of the entire grid as before. Fixed memory leak in CBCGPGridCtrl::CopyHtmlToClipboardInternal. Ribbon Designer supports Visual Studio 2008 and Visual Studio 2010 Beta 2 projects.

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧