当前位置:网站首页>MFC interface development help document -- BCG how to place controls on the toolbar
MFC interface development help document -- BCG how to place controls on the toolbar
2020-11-10 10:51:00 【FILA6666】
BCGControlBar ("Business Components Gallery ControlBar") yes MFC expanded memory bank , Enables you to create with fully custom options ( Functional area 、 Customizable toolbar 、 Menu, etc ) And a rich set of professional design Microsoft Office and Microsoft Visual Studio Applications for GUI Control , For example, chart 、 The calendar 、 grid 、 Editor 、 Gantt chart and many other controls .
BCGControlBar The library owns 500 Many have been fully designed 、 Tested and fully documented MFC The extension class . Our components can be easily integrated into your application , And save you hundreds of development and debugging time .
This article will show you how to place various controls on the toolbar , Such as combo box or edit box .
for example , You want to create a "Find" Combo box , The combo box appears on the toolbar and contains the most recently used search string . The user will be able to enter a string in the combo box edit control , Then press Enter Key to search for documents , Or press Escape Key to return the focus to the main frame , The document is displayed in CEditView - derived In the view .
The following steps are "setup" Work , Handle the creation of combo box button and the processing of its commands :
1. Open application resources , Will have ID_EDIT_FIND command ID Add a new button to the desired (IDR_MAINFRAME) The toolbar , And create with the same ID New menu items for . Use ID_EDIT_FIND_COMBO command ID Put the new string “ Find the text \ nFind” Add to string table , The ID Will be used as find Combo box button command ID. Be careful ID_EDIT_FIND yes CEditView Standard commands for processing , So you don't need to implement a special handler for this command , But it needs to be for ID_EDIT_FIND_COMBO Command implementation handler .
2. from CBCGPComboBox Class derives a class , We named it CFindComboBox.
3. stay CFindComboBox Class , rewrite PreTranslateMessage Virtual member functions , This will allow you to deal with WM_KEYDOWN News and take appropriate measures . When the user presses the exit key (VK_ESCAPE) when , Returns the focus to the main frame window . When the user presses Enter key (VK_ENTER) when , Will have ID_EDIT_FIND_COMBO command ID Of WM_COMMAND The message is posted to the main frame window ( The command will be routed to the view ).
4. from CBCGPToolbarComboBoxButton Class derives a class , We named it CFindComboButton.
5. CBCGPToolbarComboBoxButton The constructor of takes three parameters : Button command ID、 Button image all and combo box styles , You should ID_EDIT_FIND_COMBO As command ID Pass on , And you can put CImageHash :: GetImageOfCommand And ID_EDIT_FIND Together to get an image index .
6. rewrite CBCGPToolbarComboBoxButton :: CreateCombo Member functions , Here you should create CFindComboBox Object and returns a pointer to it .
7. Use IMPLEMENT_SERIAL Macro makes the combo button durable , The workspace manager will automatically be in Windows The state of the load and save button in the registry .
8. Implement... In your view ID_EDIT_FIND_COMBO The handler , Use a ID_EDIT_FIND_COMBO ID Of CBCGPToolBar::GetCommandButtons You can retrieve all of "Find" Combo box button , Due to customization , It can be with the same command ID Multiple copies of combo box buttons of .
9. Use CBCGPToolBar::IsLastCommandFromButton To determine whether or not sent from our combo box button "Find" command , To do this, find the text and add the search string to the combo box .
You should perform the following steps , take find Put the combo box button on the toolbar :
1. In the main frame window BCGM_RESETTOOLBAR Message handler (OnToolbarReset), Note that when the toolbar is initialized ( When the application starts ), Or when the toolbar is reset during customization , The message is sent from the frame to the main frame window . In either case , All need to use "custom" find The combo box button replaces the standard toolbar button ( See step 2).
2. stay OnToolbarReset In process , Analyze the toolbar ID( It is BCGM_RESETTOOLBAR News WPARAM). encounter IDR_MAINFRAME On the toolbar , Just use ID_EDIT_FIND And for CFindComboButton Object reference calls CBCGPToolBar::ReplaceButton. Note that you can construct... On the stack CFindComboButton object , because ReplaceButton Copy the button object and maintain the copy .
3. If you enable custom , Then realize "customize" The handler (OnViewCustomize) And create CBCGPToolbarCustomize Dialog box , You must use ID_EDIT_FIND And for CFindComboButton Object to call CBCGPToolbarCustomize::ReplaceButton . Note that the custom dialog contains "Commands" List box "Commands" page , Users can drag and drop commands onto the toolbar . By default , The custom dialog handles the application menu and builds a list of standard toolbar buttons for each category . If not used when needed CBCGPToolbarButton - derived Button to replace the standard toolbar button , The extension function provided by the derived object will be lost .
If you are right about BCGSoft We are interested in , You can also consult directly “ Online Service ”!
版权声明
本文为[FILA6666]所创,转载请带上原文链接,感谢
边栏推荐
- CSDN bug8: to be added
- ASP.NET Core framework revealed [blog Summary - continuous update]
- Harbor项目高手问答及赠书活动火热进行中
- python pip命令的使用
- 一个 Task 不够,又来一个 ValueTask ,真的学懵了!
- What can I do if I can't register didi? How to deal with it?
- TCP性能分析与调优策略
- 2020-11-07
- Hystrix 如何解决 ThreadLocal 信息丢失
- CCR coin robot: novel coronavirus pneumonia has accelerated the interest of regulators in CBDC.
猜你喜欢
随机推荐
Collection of blockchain theory [31]
Jsliang job series - 09 - hand written shallow copy and deep copy
TCP性能分析与调优策略
网络时间服务器(医院时钟系统)相关问题汇总
Centos7 rsync+crontab 定时备份
What should micro service authorization do?
[论文阅读笔记] Network Embedding with Attribute Refinement
One task is not enough, but another valuetask. I'm really confused!
ElasticSearch 集群基本概念及常用操作汇总(建议收藏)
C++ STL容器篇
The use of Python PIP command
Bartender2021实现安全远程标签打印,年终全新发布
He doubled the fluency of the long list of idle fish app
上线1周,B.Protocal已有7000ETH资产!
nodejs 个人学习笔记(imook)pm2
2020-11-07
拼多多版滴滴,花小猪还能“香”多久?
Android quick shutdown app
C + + standard library header file
JS basic algorithm (1)