DialogBar使用注意事项
2014-04-24 18:30
387 查看
前几天写了一个小的程序,里面用到了DialogBar,用这个东西能够起到简易的工具栏的作用,而且能够象对话框一样直接在上面添加控件使用,但是,在使用的过程中遇到了一些小的问题,拿出来大家分享一下,说不定在同样的问题上能少走一点弯路
在MSDN里面的介绍如下:
dialog bar is a toolbar — a kind of control bar that can contain any kind of control. Because it has the characteristics
of a modeless dialog box, aCDialogBar object provides a more powerful toolbar.
There are several key differences between a toolbar and a
CDialogBar object. A CDialogBar object is created from a dialog-template resource, which you can create with the Visual C++ dialog editor and which can contain any kind of Windows control. The user can tab from control to control.
And you can specify an alignment style to align the dialog bar with any part of the parent frame window or even to leave it in place if the parent is resized. The following figure shows a dialog bar with a variety of controls.
In other respects, working with a CDialogBar object is like working with a modeless dialog box. Use the dialog editor to design and create the dialog resource.
One of the virtues of dialog bars is that they can include controls other than buttons.
While it is normal to derive your own dialog classes from
CDialog, you do not typically derive your own class for a dialog bar.
Dialog bars are extensions to a main window and any dialog-bar control-notification messages, such as
BN_CLICKED or EN_CHANGE, will be sent to the parent of the dialog bar — the main window.
For more information about dialog bars, see classCDialogBar in the
Class Library Reference.
关键就是中间红色的部分,意思就是说,对于Dialog Bar上面的控件的消息响应需要交给他的父窗口来处理
所以,直接在Dialog bar上面添加控件,比如说button,然后双击button,添加消息处理函数,在运行程序后,button是灰色的,是不可以点击的,而如果想要处理这个消息,需要在mainframe里面处理消息响应。大体的思路就是这样了,实例代码如下:
首先在DialogBar上添加了一个button ID是IDC_button1
然后在mainframe的.h文件里面添加
afx_msg void OnButton1();
在cpp文件里面添加
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
以及实现代码
void CMainFrame::OnButton1()
{}
其实如此看来根本就不是什么问题,但是,当时还确实让我费了一点劲……就这么多吧
欢迎大家不吝赐教
在MSDN里面的介绍如下:
dialog bar is a toolbar — a kind of control bar that can contain any kind of control. Because it has the characteristics
of a modeless dialog box, aCDialogBar object provides a more powerful toolbar.
There are several key differences between a toolbar and a
CDialogBar object. A CDialogBar object is created from a dialog-template resource, which you can create with the Visual C++ dialog editor and which can contain any kind of Windows control. The user can tab from control to control.
And you can specify an alignment style to align the dialog bar with any part of the parent frame window or even to leave it in place if the parent is resized. The following figure shows a dialog bar with a variety of controls.
In other respects, working with a CDialogBar object is like working with a modeless dialog box. Use the dialog editor to design and create the dialog resource.
One of the virtues of dialog bars is that they can include controls other than buttons.
While it is normal to derive your own dialog classes from
CDialog, you do not typically derive your own class for a dialog bar.
Dialog bars are extensions to a main window and any dialog-bar control-notification messages, such as
BN_CLICKED or EN_CHANGE, will be sent to the parent of the dialog bar — the main window.
For more information about dialog bars, see classCDialogBar in the
Class Library Reference.
关键就是中间红色的部分,意思就是说,对于Dialog Bar上面的控件的消息响应需要交给他的父窗口来处理
所以,直接在Dialog bar上面添加控件,比如说button,然后双击button,添加消息处理函数,在运行程序后,button是灰色的,是不可以点击的,而如果想要处理这个消息,需要在mainframe里面处理消息响应。大体的思路就是这样了,实例代码如下:
首先在DialogBar上添加了一个button ID是IDC_button1
然后在mainframe的.h文件里面添加
afx_msg void OnButton1();
在cpp文件里面添加
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
以及实现代码
void CMainFrame::OnButton1()
{}
其实如此看来根本就不是什么问题,但是,当时还确实让我费了一点劲……就这么多吧
欢迎大家不吝赐教
相关文章推荐
- UINavigationController.navigationBar使用注意事项
- (4.1.43.3)design support library:Snackbar使用及其注意事项
- actionbar 与dialog 并用是注意事项
- Swift3.0之hidesBottomBarWhenPushed的使用和注意事项
- actionbar 与dialog 并用是注意事项
- Android ActionBar 使用注意事项
- Infragistics 控件 WebExplorerBar 使用 及发布注意事项
- BottomSheetDialog的使用及注意事项
- DotBar使用注意事项
- 强制类型转换使用时的注意事项
- 使用webpack打包.css文件时需要注意的事项
- 缓存 使用注意事项 淘汰策略
- Vue 2中ref属性的使用方法及注意事项
- 网络图片加载的第三方类:EGOImageView的使用方法及注意事项
- java 中Math.sqrt()使用注意事项 Type mismatch: cannot convert from double to float
- MySQL索引类型总结和使用技巧以及注意事项
- 双缓冲使用注意事项
- 单片机硬件==PCB的使用注意事项
- MySQL索引类型总结和使用技巧以及注意事项
- 服务器控件requiredfieldvalidator的使用及注意事项