|
virtual BOOL Create(
CWnd* pParentWnd,
DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP,
UINT nID = AFX_IDW_TOOLBAR
);
- pParentWnd
Pointer to the window that is the toolbar's parent.(指向父窗口的窗口指针)
- dwStyle (工具条样式)
The toolbar style. Additional toolbar styles supported are: CBRS_TOP Control bar is at top of the frame window.(工具条在窗口的上面) CBRS_BOTTOM Control bar is at bottom of the frame window.(工具条在窗口的下面) CBRS_NOALIGN Control bar is not repositioned when the parent is resized.(父窗口的大小时,工具条不改变) CBRS_TOOLTIPS Control bar displays tool tips.(当鼠标放在工具条上的按钮上方时,显示提示信息) CBRS_SIZE_DYNAMIC Control bar is dynamic. CBRS_SIZE_FIXED Control bar is fixed.(工具条固定) CBRS_FLOATING Control bar is floating.(工具条是浮动的) CBRS_FLYBY Status bar displays information about the button. (状态栏显示按钮信息) CBRS_HIDE_INPLACE Control bar is not displayed to the user.(隐藏工具条)
- nID
The toolbar's child-window ID.
2、LoadToolBar
函数原型为:
BOOL LoadToolBar(
UINT nIDResource
);
nIDResource Resource ID of the toolbar to be loaded(资源ID)
|
3、工具条的样式可以在创建时指定(Create函数)也可以用SetBarStyle函数单独指定
SetBarStyle是继承的父类的方法,样式同Create函数的第二个参数。
举例:
MainFrm.h中
// 自定义工具栏
CToolBar m_wndToolBar1;
public: afx_msg void OnRecordStart();
public: afx_msg void OnRecordStop(); };
在MainFrm.cpp中