主题 |
1. 创建状态栏 并显示 2. 3. 4. 5. |
代码::创建状态栏 并显示 |
//手动添加3个ICON ///////////////////////////////////////////////////////////////////////////// // CProject01Dlg dialog // // class CProject01Dlg : public // { // // Construction // public: // CProject01Dlg(CWnd* pParent = NULL); CStatusBar m_statusBar; // BOOL CProject01Dlg::OnInitDialog() // TODO: Add extra initialization BOOL bRec = m_statusBar.Create( this ); UINT nIDS[ 3 ] = bRec = m_statusBar.SetIndicators(nIDS, 9 ); m_statusBar.SetPaneInfo( 0 ,nIDS[ 0 ],SBPS_NORMAL, 100 ); m_statusBar.SetPaneInfo( 1 ,nIDS[ 1 ],SBPS_NORMAL, 200 ); m_statusBar.SetPaneInfo( 2 ,nIDS[ 2 ],SBPS_NORMAL, 32565 ); m_statusBar.SetPaneText( 0 , "提示:" ); RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, 0 ); //添加OnSize消息 void CProject01Dlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, 0 ); } //即时显示鼠标所放在菜单的的文字 //在类向导中添加 1 个WindowProc消息 LRESULT { // TODO: Add your specialized code here and/or call if (message == WM_MENUSELECT) { // OnHotMenu(LOWORD(wParam)); CMenu if { CString pMenu m_statusBar.SetPaneText( 1 ,strText); } } return CDialog::WindowProc(message, wParam, lParam); } 效果图: |
Code:: MDI文档显示和隐藏状态栏 |
//Show void CMainFrame::OnShow() { if(!m_wndStatusBar.IsWindowVisible()) { m_wndStatusBar.ModifyStyle(0, WS_VISIBLE,SWP_FRAMECHANGED); } //使状态栏状态生效 SendMessage(WM_SIZE); } //Hide void CMainFrame::OnHide() { if(m_wndStatusBar.IsWindowVisible()) { m_wndStatusBar.ModifyStyle(WS_VISIBLE, 0,SWP_FRAMECHANGED); } //使状态栏状态生效 SendMessage(WM_SIZE); } 效果图: |
C++ Code_StatusBar,布布扣,bubuko.com