MFC对话框加载工具栏和状态栏
2016-01-03 11:39
465 查看
状态栏
在头文件中定义一个状态栏还有一个状态栏ID的数组(状态栏分多少格就多长的数组)
void RepositionBars( UINT nIDFirst, UINTnIDLast, UINTnIDLeftOver, UINTnFlag =CWnd::reposDefault, LPRECTlpRectParam =NULL,
LPCRECTlpRectClient = NULL, BOOL bStretch = TRUE );
Called to reposition and resize control bars in the client area of a window.
The nIDFirst and nIDLast parameters define a range of control-bar IDs to be repositioned in the client area. ThenIDLeftOver parameter specifies the ID of the child window (normally the view) which is repositioned and resized
to fill the rest of the client area not filled by control bars.
工具栏:(加bmp图片)
在资源视图里面插入一个ToolBar 并且对工具栏上面按钮先初始化(给ID,后面会用到 nID数组 )
头文件定义:
实现:
在头文件中定义一个状态栏还有一个状态栏ID的数组(状态栏分多少格就多长的数组)
CStatusBar m_StatusBar; UINT m_nStatusBarID[2];变量的赋值和状态栏显示
//复制ID m_nStatusBarID[0] = 10240; m_nStatusBarID[1] = 10241; //创建 m_StatusBar.Create(this); m_StatusBar.SetIndicators(m_nStatusBarID, sizeof(m_nStatusBarID)/sizeof(UINT)); //设置每一格的宽 m_StatusBar.SetPaneInfo(0,m_nStatusBarID[0],0,m_rcClient.Width()/5*4); m_StatusBar.SetPaneInfo(1,m_nStatusBarID[1],0,m_rcClient.Width()/5); //显示内容 m_StatusBar.SetPaneText(0,"Ready"); m_StatusBar.SetPaneText(1,"1970-01-01 00:00:00"); //显示调节状态栏 RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);MSDN对RepositionBars的注解:
void RepositionBars( UINT nIDFirst, UINTnIDLast, UINTnIDLeftOver, UINTnFlag =CWnd::reposDefault, LPRECTlpRectParam =NULL,
LPCRECTlpRectClient = NULL, BOOL bStretch = TRUE );
Called to reposition and resize control bars in the client area of a window.
The nIDFirst and nIDLast parameters define a range of control-bar IDs to be repositioned in the client area. ThenIDLeftOver parameter specifies the ID of the child window (normally the view) which is repositioned and resized
to fill the rest of the client area not filled by control bars.
工具栏:(加bmp图片)
在资源视图里面插入一个ToolBar 并且对工具栏上面按钮先初始化(给ID,后面会用到 nID数组 )
头文件定义:
CToolBar m_ToolBar; //工具栏 CImageList m_ImgList; //图片列表
实现:
m_ToolBar.Create(this); m_ToolBar.SetBarStyle(CBRS_ALIGN_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_BORDER_3D);//类型 const UINT nID[5] = {ID_BUTTON_NEW, ID_BUTTON_OPEN, ID_BUTTON_SAVE, ID_BUTTON_SAVEAS, ID_BUTTON_IMPORT}; m_ToolBar.SetButtons(nID, 5); m_ToolBar.SetSizes(CSize(64,70), CSize(48,48));//设置大小 m_ToolBar.SetButtonText(0, "New"); //显示字 m_ToolBar.SetButtonText(1, "Open"); m_ToolBar.SetButtonText(2, "Save"); m_ToolBar.SetButtonText(3, "SaveAs"); m_ToolBar.SetButtonText(4, "Import"); m_ToolBar.GetToolBarCtrl().SetImageList(&m_ImgList); //设置图片 <span style="color:#FF9900;"> //必须注册,否则不显示 RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0); </span>
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- 关于指针的一些事情
- c++ primer 第五版 笔记前言
- share_ptr的几个注意点
- MooBox 基于Mootools的对话框插件
- Lua中调用C++函数示例
- Lua教程(一):在C++中嵌入Lua脚本
- Lua教程(二):C++和Lua相互传递数据示例
- 使用Google工具栏追踪 Blog 留言
- C#实现在前端网页弹出警告对话框(alert)的方法
- C++联合体转换成C#结构的实现方法
- Extjs学习笔记之四 工具栏和菜单
- Android开发必知 九种对话框的实现方法
- Android列表对话框用法实例分析
- C++高级程序员成长之路
- C++编写简单的打靶游戏
- C++ 自定义控件的移植问题
- C++变位词问题分析
- C/C++数据对齐详细解析
- C++基于栈实现铁轨问题