zoukankan      html  css  js  c++  java
  • Showing progress bar in a status bar pane

    在工具卡显示进度条,原文链接:http://www.codeproject.com/Articles/35/Showing-progress-bar-in-a-status-bar-pane

    1.构造函数

    CProgressBar(); 
    CProgressBar(LPCTSTR strMessage, int nSize=100, int MaxValue=100, BOOL bSmooth=FALSE, int nPane=0);
    BOOL Create(LPCTSTR strMessage, int nSize=100, int MaxValue=100, BOOL bSmooth=FALSE, int nPane=0);

    参数说明:

    strMessage//bar字符串
    nSize//占比
    MaxValue//bar最大值(0~MaxValue)
    bSmooth//是否平滑
    nPane//状态栏第几子项

    2.方法函数

    BOOL Success()                      // Construction successful?
    
    COLORREF SetBarColour(COLORREF clrBar);  // Set Bar colour, returns previous
    COLORREF SetBkColour(COLORREF clrBar);   // Set background colour, returns previous
    
    int  SetPos(int nPos);              // Same as CProgressCtrl
    int  OffsetPos(int nPos);           // Same as CProgressCtrl
    int  SetStep(int nStep);            // Same as CProgressCtrl
    int  StepIt();                      // Same as CProgressCtrl
    void Clear();                       // Clear the status bar
    void SetRange(int nLower, int nUpper, int nStep = 1);
                                        // Set min, max and step size
    void SetText(LPCTSTR strMessage);   // Set the message
    void SetSize(int nSize);            // Set the bar size

    3.应用

    CProgressBar Bar("Testing", 40, 1000);
    
    for (int i = 0;  i <  1000; i++)
    {
        // perform operation
        Bar.StepIt();
    }
    或者
    CProgressBar bar;
    
    bar.Create("Processing", 40, 1000);
    for (int i = 0; i < 1000; i++)
    {
        //    perform operation
        bar.StepIt();
    }
    bar.SetText("Writing");
    for  (int i = 0;  i <  1000; i++)
    {
        // perform operation
        bar.StepIt();
        PeekAndPump();    // Message pump
    }
    bar.Clear();

    PeekAndPump()函数的作用是进行,消息循环,使之进度条走时,可进行操作响应,如最大最小化等等

    BOOL PeekAndPump()
    {
        static MSG msg;
    
        while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) {
            if (!AfxGetApp()->PumpMessage()) {
                ::PostQuitMessage(0);
                return FALSE;
            }    
        }
    
        return TRUE;
    }

    运行结果如下:

    image

    代码下载地址:http://download.csdn.net/detail/wuyuan2011woaini/9595419

  • 相关阅读:
    【博弈论】囚徒困境
    【LTE与5G】
    【现代通信技术】绪论
    【操作系统】 逻辑结构
    【密码学】
    【计算机网络】网络应用
    部署docker仓库-Harbor
    ELK+filebeat收集K8S平台日志
    istio-http流量管理
    K8S集群部署istio
  • 原文地址:https://www.cnblogs.com/wuyuan2011woaini/p/5732113.html
Copyright © 2011-2022 走看看