⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 实现delphi中的两种风格的弹出式进度条。
💻 TXT
字号:
制作弹出式进度对话框
作者 Chris Maunder                 

下载整个项目(38 k),下载类文件(5 k)选择英文原文
在很多情况下,你需要制作一个弹出式进度对话框以显示一个容长
工作的进程,在一个对话框中加入一个进度条控制和一个取消按
钮然后为每个项目加入控制的消息这样就会把进度对话框变的单调
杂乱,
CProgressWnd 是一个非常简单的窗口类它包括一个进度条控制
一个取消按钮和一个存贮消息的文本框,缺省情况下文本框可以
显示四行,但是这可以通过实用CProgressWnd::SetWindowSize() 
来改变
解释:CProgressWnd(); CProgressWnd(CWnd* pParent, LPCTSTR strTitle, BOOL 
bSmooth=FALSE); BOOL Create(CWnd* pParent, LPCTSTR strTitle, BOOL 
bSmooth=FALSE); 
"pParent" 是进度对话框的父窗口strTitle是窗口的标题bSmooth
"bSmooth"仅仅在你有IE3.0及其以上版本带的commctrl32.dll 时才有
效,它指定你的进度条是平滑的还是矮矮胖胖的
作用:
int SetPos(int nPos); //
int OffsetPos(int nPos); // Same as CProgressCtrl
int SetStep(int nStep); // Same as CProgressCtrl
int StepIt(); // Same as CProgressCtrl
void SetRange(int nLower, int nUpper, int nStep = 1);
//设定每步的最大最小尺寸
void Hide(); //隐藏窗口
void Clear(); //清除文本并重新设置进度条
void SetText(LPCTSTR fmt, ...);//在文本区域内设置文本 
BOOL Success()//检验是否创建成功
BOOL Cancelled()//检验是否按了取消按纽
void SetWindowSize(int nNumTextLines, int nWindowWidth = 390);
//设置文本的行数和窗口的尺寸
为了用这个控制你可以这样做
CProgressWnd wndProgress(this, "Progress");
wndProgress.SetRange(0,5000);
wndProgress.SetText("Processing..."); 
for (int i = 0; i <5000; i++) 
{ 
wndProgress.StepIt(); PeekAndPump(); 
if (wndProgress.Cancelled()) 

{
MessageBox("Progress Cancelled"); break;
} 
} 
你也可以这样
CProgressWnd wndProgress;
if (!wndProgress.Create(this, "Progress"))
return;
wndProgress.SetRange(0,5000);
wndProgress.SetText("Processing..."); 
在上面的事例中, PeekAndPump() 是一个很简的函数,它允许用户
同窗口交互,如果窗口尺寸变了,进度条的尺寸随之也要变 
       返回

       A Popup Progress Window 
           
This article was contributed by Chris Maunder.  

There are many occasions where it's nice to have a poopup window that
shows the progress of a lengthy operation. Incorporating a dialog 
resource with a progress control and cancel button, then linking up 
the control messages for every project you wish to have the progress 
window can get monotonous and messy.
The class CProgressWnd is a simple drop in window that contains 
a progress control, a cancel button and a text area for messages. 
The text area can display 4 lines of text as default, although this 
can be changed using CProgressWnd::SetWindowSize() (below)


Construction

CProgressWnd(); CProgressWnd(CWnd* pParent, LPCTSTR strTitle, BOOL 
bSmooth=FALSE); BOOL Create(CWnd* pParent, LPCTSTR strTitle, BOOL 
bSmooth=FALSE); Construction is either via the constructor or a two-step
process using the constructor and the "Create" function. "pParent" is 
the parent of the progress window, "strTitle" is the window caption 
title. "bSmooth" will only be effective if you have the header files and 
commctrl32.dll from IE 3.0 or above (no problems for MS VC 5.0). 
It specifies whether the progress bar will be smooth or chunky. 

Operations

    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 SetRange(int nLower, int nUpper, int nStep = 1);

          // Set min, max and step size

 (uses 32 bit range if available)

    void Hide();                        

// Hide the window

    void Show();                        

// Show the window

    void Clear();                       

// Clear the text and reset the progress bar



    void SetText(LPCTSTR fmt, ...);     

// Set the text in the text area

    BOOL Success()                      

// Was the creation successful?

    BOOL Cancelled()                    

// Has the cancel button been pressed?

    void SetWindowSize(int nNumTextLines, int nWindowWidth = 390);



// Sets the size of the window according to

// the number of text lines specifed and the

// desired window size in pixels.

To use the control, just do something like: 

    CProgressWnd wndProgress(this, "Progress");

    wndProgress.SetRange(0,5000);

    wndProgress.SetText("Processing...");         

    for (int i = 0; i  <5000; i++) 
     { 

        wndProgress.StepIt(); PeekAndPump(); 

        if (wndProgress.Cancelled()) 

        {

            MessageBox("Progress Cancelled"); break;

         } 

     } 

or it can be done two stage as: 

    CProgressWnd wndProgress;

       if (!wndProgress.Create(this, "Progress"))

        return;

    wndProgress.SetRange(0,5000);

    wndProgress.SetText("Processing...");         

In the above case, PeekAndPump() is a function which simply peeks 

and pumps messages, allowing user interaction with the window 

during a lengthy process. If the window size changes during the 

processing, the progress bar size will alsow change. 
 

 



源码之家
http://21tx.com

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -