zoukankan      html  css  js  c++  java
  • C++语言 使状态栏随对话框的改变而改变

    BOOL CSizeStatusbarDlg::OnInitDialog()
    {
        CDialog::OnInitDialog();
    
        // Add "About..." menu item to system menu.
    
        // IDM_ABOUTBOX must be in the system command range.
        ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
        ASSERT(IDM_ABOUTBOX < 0xF000);
    
        CMenu* pSysMenu = GetSystemMenu(FALSE);
        if (pSysMenu != NULL)
        {
            CString strAboutMenu;
            strAboutMenu.LoadString(IDS_ABOUTBOX);
            if (!strAboutMenu.IsEmpty())
            {
                pSysMenu->AppendMenu(MF_SEPARATOR);
                pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
            }
        }
    
        // Set the icon for this dialog.  The framework does this automatically
        //  when the application's main window is not a dialog
        SetIcon(m_hIcon, TRUE);            // Set big icon
        SetIcon(m_hIcon, FALSE);        // Set small icon
        
        // TODO: Add extra initialization here
        
        m_StatusBar.CreateEx(this,SBARS_SIZEGRIP);
        UINT panels[6];
    
        CRect rect;
        GetClientRect(rect);
        int width = rect.Width()/6;
        m_StatusBar.SetIndicators(panels,6);
        for (int i = 0 ; i<6; i++)
        {
            m_StatusBar.SetPaneInfo(i,1000+i,0,width);
        }    
    
        m_StatusBar.SetPaneText(0,"提示:");
    
        m_StatusBar.SetPaneText(2,"当前用户:");
    
        m_StatusBar.SetPaneText(4,"当前时间:");
    
        RepositionBars(AFX_IDW_CONTROLBAR_FIRSTw,AFX_IDW_CONTROLBAR_LAST,0);
    
    
        return TRUE;  // return TRUE  unless you set the focus to a control
    }
    void CSizeStatusbarDlg::OnSize(UINT nType, int cx, int cy) 
    {
        CDialog::OnSize(nType, cx, cy);
        if (IsWindow(m_StatusBar.m_hWnd)) //判断状态栏是否被创建
        {
            CRect rect;
            GetClientRect(rect);
            int width = rect.Width()/6;
            for (int i = 0 ; i<6; i++)
            {
                m_StatusBar.SetPaneInfo(i,1000+i,0,width);
            }
            RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);    
        }
    }
  • 相关阅读:
    pat甲级 1155 Heap Paths (30 分)
    pat甲级 1152 Google Recruitment (20 分)
    蓝桥杯 基础练习 特殊回文数
    蓝桥杯 基础练习 十进制转十六进制
    蓝桥杯 基础练习 十六进制转十进制
    蓝桥杯 基础练习 十六进制转八进制
    51nod 1347 旋转字符串
    蓝桥杯 入门训练 圆的面积
    蓝桥杯 入门训练 Fibonacci数列
    链表相关
  • 原文地址:https://www.cnblogs.com/pythonschool/p/2789269.html
Copyright © 2011-2022 走看看