加载状态栏
2016-04-15 10:30
465 查看
1.定义结构体:
2.加载指示器
3.添加相关文本
单文档和多文档程序默认加载状态栏
修改
static UINT BASED_CODE indicators[] = { ID_SEPARATOR, // status line Indicator ID_INDICATOR_POS, // Cursor Position Indicator ID_INDICATOR_OBJSIZE, // Cursor Position Indicator ID_INDICATOR_CAPS, // Caps Lock Indicator ID_INDICATOR_NUM, // Num Lock Indicator ID_INDICATOR_SCRL, // Scroll Lock Indicator ID_INDICATOR_CLOCK, // Clock Indicator ID_INDICATOR_PAPER_SIZE,//page size };
2.加载指示器
CStatusBar m_wndStatusBar; m_wndStatusBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_TOOLTIPS); m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT));
3.添加相关文本
CRect RectTemp; GetClientRect(RectTemp); int nLength; nLength=0; nLength=abs(RectTemp.right-RectTemp.left); for(int k=0; k<=7; k++) { UINT nID,nStyle; int nWidth; m_wndStatusBar.GetPaneInfo(k, nID, nStyle, nWidth); m_wndStatusBar.SetPaneInfo(k, nID, nStyle, nLength/8); m_wndStatusBar.SetPaneText(k,"Test"); } RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); m_wndStatusBar.ShowWindow(SW_SHOW);
单文档和多文档程序默认加载状态栏
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("未能创建工具栏\n"); return -1; // 未能创建 } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("未能创建状态栏\n"); return -1; // 未能创建 } // TODO: 如果不需要工具栏可停靠,则删除这三行 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return 0; }
修改
void CDrawView::OnMouseMove(UINT nFlags, CPoint point) { CString CursorPos; CString tmpstr = "X= -XXX Y= -YYY"; CPoint curPoint(point); ClientToDoc(curPoint); CursorPos.Format("x= %-4d y= %-4d", curPoint.x, curPoint.y); CStatusBar *pStatusBar = (CStatusBar *)((CMainFrame *)(AfxGetApp()->m_pMainWnd))->GetDescendantWindow(AFX_IDW_STATUS_BAR); if (pStatusBar == NULL) return; UINT nIDPos; UINT nStylePos; int nWidth; CClientDC dc(pStatusBar); CFont* pOldFont = dc.SelectObject(pStatusBar->GetFont()); CSize szExtent = dc.GetTextExtent(tmpstr); dc.SelectObject(pOldFont); int nIndexPos = pStatusBar->CommandToIndex(ID_INDICATOR_POS); pStatusBar->GetPaneInfo(nIndexPos, nIDPos, nStylePos, nWidth); pStatusBar->SetPaneInfo(nIndexPos, nIDPos, nStylePos, szExtent.cx); pStatusBar->SetPaneText(nIndexPos,CursorPos); }
相关文章推荐
- 个人对webdriver的理解(一)
- SGU 125 Shtirlits(dfs)
- 六尺巷——张英
- 树莓派瞎玩~9~dns服务器
- 用栈判断表达式中的括号是否匹配
- android 屏幕适配
- 复利计算再升级
- 复利计算结对
- html 等页面防止中文出现乱码的终极解决方案
- easyui实现鼠标移到某一行,就会弹出一个提示信息效果
- Swift笔记:函数
- Java学习·String
- 浅谈Jquery中的bind(),live(),delegate(),on()绑定事件方式
- 单例模式
- Galaxy ZOO银河星空图的识别分类
- 线性表之顺序存储结构
- linux 如何设置进程所能打开的最大文件描述符个数
- iOS arc(自动释放)和mrc(手动释放)下重写set方法
- leetcode26题 题解 翻译 C语言版 Python版
- kernel的红色波浪线