一个包含bar和取消而且不需要资源弹出窗口

1.构造函数

CProgressWnd();
CProgressWnd(CWnd* pParent, LPCTSTR strTitle, BOOL bSmooth=FALSE);
BOOL Create(CWnd* pParent, LPCTSTR strTitle, BOOL bSmooth=FALSE);

参数说明:

pParent//父窗口
strTitle//窗口标题
bSmooth//是否平滑

2.方法属性

BOOL GoModal(LPCTSTR strTitle = _T("Progress"), BOOL bSmooth=FALSE);
// Make window modal 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 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 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. void PeekAndPump(BOOL bCancelOnESCkey = TRUE);
// Message pumping, with options of
// allowing Cancel on ESC key.

SetWindowSize()默认显示四行

PeekAndPump()防止消息阻塞,在走进度过程中,相关操作可以继续执行,如esc取消,鼠标点击等等

3例子

通过GoModal()显示

CProgressWnd wndProgress(this, "Progress");

// wndProgress.GoModal(); // Call this if you want a modal window
wndProgress.SetRange(0,5000);
wndProgress.SetText("Processing..."); for (int i = 0; i < 5000; i++) {
wndProgress.StepIt();
wndProgress.PeekAndPump(); if (wndProgress.Cancelled()) {
MessageBox("Progress Cancelled");
break;
}
}

或者Create()

CProgressWnd wndProgress;

if (!wndProgress.Create(this, "Progress"))
return; wndProgress.SetRange(0,5000);
wndProgress.SetText("Processing...");

源代码链接地址:http://download.csdn.net/detail/wuyuan2011woaini/9594242

最新文章

  1. 阿里云服务器Linux CentOS安装配置(二)yum安装svn
  2. Mac iTerm2命令行快捷操作
  3. SQL中利用DMV进行数据库性能分析
  4. Git undo 操作
  5. django若干问题
  6. fdtd simulation, plotting with gnuplot, writting in perl
  7. Lucene4.3开发之分词器总结
  8. js的传值,table中tr的遍历,js中动态创建数组
  9. 谈谈C#中的接口
  10. Referenced file contains errors (http://tiles.apache.org/dtds/tiles-config_3_0.dtd)
  11. RH133读书笔记(7)-Lab 7 Advanced Filesystem Mangement
  12. the c programing language 学习过程5
  13. [Python爬虫]使用Selenium操作浏览器订购火车票
  14. Java 资源本地化与国际化
  15. linux mysql 定时备份
  16. python class中__init__函数、self
  17. shell 网络状态查询 ping curl telnet
  18. 2018.09.18 atcoder Best Representation(kmp)
  19. lamp 5.6.36 bug记录
  20. linux下如何查看所有的用户和组信息?

热门文章

  1. 轻松认识JVM运行时数据区域(使用思维导图)
  2. 三分 --- CSU 1548: Design road
  3. SQL 批量字符串替换
  4. 收集了50道基础的java面试题
  5. WPF后台设置xaml控件的样式System.Windows.Style
  6. 开源的javascript实现页面打印功能,兼容所有的浏览器(情况属实)
  7. 变废为宝,将Discuz废弃的cache机制引入到memory体系中
  8. 【BZOJ 4551】【TJOI2016】【HEOI2016】树
  9. memcache与memcached扩展的区别
  10. rabbitmq队列中消息过期配置