• C++ Code_StatusBar


    主题

    1. 创建状态栏 并显示

    2. 在状态栏中显示进度条

    3. MDI文档显示和隐藏状态栏

    4.

    5.

     
     

    代码::创建状态栏 并显示

     //手动添加3个ICON

    /////////////////////////////////////////////////////////////////////////////
    // CProject01Dlg dialog
    //
    // class CProject01Dlg : public CDialog
    // {
    // // Construction
    // public:
    // CProject01Dlg(CWnd* pParent = NULL); // standard constructor
        CStatusBar m_statusBar;
     
     
    // BOOL CProject01Dlg::OnInitDialog()
    // TODO: Add extra initialization here     
    BOOL bRec = m_statusBar.Create( this );
    UINT nIDS[ 3 ] = {0x1001,0x1002,0x1003};
    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_LAST0 );
     
     
    //添加OnSize消息
    void CProject01Dlg::OnSize(UINT nType, int cx, int cy)
    {
        CDialog::OnSize(nType, cx, cy);
        
        // TODO: Add your message handler code here
        RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, 0 );
    }
     
    //即时显示鼠标所放在菜单的的文字
    //在类向导中添加 1 个WindowProc消息
    LRESULT CProject01Dlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    {
        // TODO: Add your specialized code here and/or call the base class
        if (message == WM_MENUSELECT)
    {
            // OnHotMenu(LOWORD(wParam));
            CMenu * pMenu = GetMenu();
            if (pMenu != NULL)
            {
                CString strText;
                pMenu - > GetMenuString(( int )LOWORD(wParam),strText,MF_BYCOMMAND);
                m_statusBar.SetPaneText( 1 ,strText);
            }
            
    }
        return CDialog::WindowProc(message, wParam, lParam);
    }
     

     

    效果图:

     
     
     
        

    Code:: MDI文档显示和隐藏状态栏

    //Show
    void CMainFrame::OnShow() 
    {
        if(!m_wndStatusBar.IsWindowVisible())
        {
            m_wndStatusBar.ModifyStyle(0WS_VISIBLE,SWP_FRAMECHANGED);
        }
        //使状态栏状态生效
        SendMessage(WM_SIZE);
    }
        
    //Hide
    void CMainFrame::OnHide() 
    {
        if(m_wndStatusBar.IsWindowVisible())
        {
            m_wndStatusBar.ModifyStyle(WS_VISIBLE0,SWP_FRAMECHANGED);
        }
        //使状态栏状态生效
        SendMessage(WM_SIZE);
    }

    效果图:

     
     




  • 相关阅读:
    Python 命令详解
    redhat 6 / centos 6 搭建Django环境
    Linux rsync 命令详解
    Python 文件处理
    [网络流24题]最长不下降子序列问题
    [网络流24题]圆桌问题
    BZOJ 4675(点分治)
    LOJ 2183 / SDOI2015 序列统计 (DP+矩阵快速幂)
    BZOJ 3931 (网络流+最短路)
    [网络流24题]魔术球问题
  • 原文地址:https://www.cnblogs.com/xe2011/p/3885727.html
Copyright © 2020-2023  润新知