Showing progress bar in a status bar pane

2023-05-16

This article was contributed by Brad Mann.

This code creates a progress bar anywhere in the status window and the control is created only once.

1. From the View menu, choose Resource Symbols. Press the New button and assign the symbol a name. (In this example we’ll be using ID_INDICATOR_PROGRESS_PANE) It’s probably best if you let the computer assign a value for it.

2. In MainFrm.cpp, find the indicators array (located under the message map section) and type the ID of the resource (ID_INDICATOR_PROGRESS_PANE) in the section. Put it under all the rest of the ID’s, unless you don’t want the bar in the far right corner. (placing the ID at the beginning of the array puts the pane in the far left where the program messages usually go)

3. Open the string table in the resource editor, and from the Insert menu, choose New String.

4. Double click the string and select the ID. For the message, just type a bunch of spaces. (the more spaces the larger the progress bar)

Now that we’ve created the pane, it’s time to put a progress bar in it.

1. Declare a public variable in MainFrm.h of type CProgressCtrl. (In this example we’ll call it m_Progress)

2. Declare a protected variable in MainFrm.h of type BOOL. (In this example we’ll call it m_bCreated)

3. In the OnCreate() function in MainFrm.cpp, initialize m_bCreated to FALSE:


	m_bCreated = FALSE;

4. Now, when we need to use the progress bar, we check to see if it’s created, and if it isn’t, we make a new one:


CMainFrame::OnSomeLongProcess(){	RECT MyRect;	// substitute 4 with the zero-based index of your status bar pane. 	// For example, if you put your pane first in the indicators array, 	// you’d put 0, second you’d put 1, etc.	m_wndStatusBar.GetItemRect(4, &MyRect);  	if (m_bCreated == FALSE)	{		//Create the progress control		m_Progress.Create(WS_VISIBLE|WS_CHILD, MyRect, &wndStatusBar, 1); 		m_Progress.SetRange(0,100); //Set the range to between 0 and 100		m_Progress.SetStep(1); // Set the step amount		m_bCreated = TRUE;	}	// Now we’ll simulate a long process:	for (int I = 0; I < 100; I++)	{			Sleep(20);			m_Progress.StepIt();	}}

If the window is resized while the progress bar is created, the progress control doesn’t reposition correctly, so we have to override the WM_SIZE event of class CMainFrame:


void CMainFrame::OnSize(UINT nType, int cx, int cy) {	CMDIFrameWnd::OnSize(nType, cx, cy);	RECT rc;	m_wndStatusBar.GetItemRect(4, &rc);	// Reposition the progress control correctly!	m_Progress.SetWindowPos(&wndTop, rc.left, rc.top, rc.right - rc.left,		rc.bottom - rc.top, 0); 		}

That’s the way to implement a progress control into a status bar pane! Although the process is long, it is relatively simple.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Showing progress bar in a status bar pane 的相关文章

  • docker 状态Removal In Progress,rm提示无法删除

    docker 无法删除场景 docker 进入Removal In Progress状态 xff0c 无法直接删除 1 docker rm f 容器 提示文件无权限操作 2 xxxx 表示上图的文件路径 需要登录到宿主机上 xff0c 执行
  • 【ElementUI】进度条 el-progress—进度圆环颜色、自定义文字

    圆环不显示 大概率是因为宽度没有设置 el progress width 100 圆圈背景色 lt el progress type 61 34 circle 34 percentage 61 34 20 34 class 61 34 pe
  • Android Ble 连接设备失败 onConnectionStateChange status 返回133

    Android Ble 连接设备失败时回调函数 onConnectionStateChange status 返回133 开始找问题 各种mac地址 权限 线程 找了个遍 结果就是返回纹丝不动 又因为 mBluetoothGatt mBlu
  • jQuery ajax 中有进度更新事件吗?

    我有一个长时间运行的任务 使用 jquery ajax 调用 我正在使用阻止 ui 插件显示 加载中 无论如何 我可以将进度消息发送回客户端以显示进度 并在块 ui 插件消息上更新该进度 所以它会显示这一点 当服务器完成其工作时 正在加载第
  • 基于 AJAX/PHP 的大文件上传,带有进度条

    我一直在尝试创建一个非 Flash 上传面板 它也显示进度条 我们的服务器上有 PHP 5 3 暂时无法升级到 5 4 因此无法使用新的上传进度功能 gt http php net manual en session upload prog
  • 加载 Comet/服务器推送 iframe 时停止浏览器“厄运的悸动”

    当使用 Comet 或 Ajax Long Pull 技术时 通常使用 iframe 当 iframe 等待长连接关闭时 浏览器正在旋转其 throbber 进度 加载指示器 一些网站 例如 etherpad com 设法让它停止 他们是如
  • Google 云端硬盘上传进度条

    有没有办法为上传到 Google Drive 创建进度条 我正在使用适用于 Javascript 的 Google Drive SDK 我在他们的文档中根本找不到任何内容 真的很感谢它的一点帮助 我查阅了很多代码 几乎是我这几周在谷歌上找到
  • 我可以报告 openmp 任务的进度吗?

    想象一个经典的 OMP 任务 对 0 0 1 0 范围内的双精度型大向量求和 Live On Coliru http coliru stacked crooked com a 6167c106392d7020 using namespace
  • 用户在线离线状态-离线状态问题

    首先这是相关问题PHP 在线离线状态 https stackoverflow com questions 13201579 php online offline status 13201617 comment17974371 1320161
  • 如何在 Android 中将文件上传到 Cloudinary 时显示进度?

    我实现了将文件上传到Cloudinary的功能 Cloudinary cloudinary new Cloudinary Constants CLOUDINARY URL try FileInputStream is new FileInp
  • 是否可以检查 URLconnection.getInputStream() 的进度?

    我想通过 URL 连接检查下载文件的进度 是否可能或者我应该使用另一个库 这是我的 urlconnection 函数 public static String sendPostRequest String httpURL String da
  • Android通知大图标,有没有办法去掉右下角的小图标?

    我有一条显示大图标的通知 有什么方法可以从此视图中删除蜂窝及以上设备中的较小图标 显然还是保留了顶部状态栏的小图标 NotificationCompat Builder builder new NotificationCompat Buil
  • 如何设置机器人的状态

    所以我试图让我的机器人流媒体与抑郁症 但我已经尝试了多种方法 但它们不起作用 我尝试过这些方法 client user setPresence game name with depression status online bot user
  • setProgressDrawable 填充整个seekBar

    正如我在标题中所说 当我使用 setProgressDrawable 时 它 会填充整个 SeekBar 如果进度为 34 则进度显示 100 但拇指显示正确的百分比为 34 我不明白可能是什么问题 done setProgressDraw
  • 客户我的帐户订单历史记录中不显示自定义订单状态

    在 WooCommerce 中 我制作了 2 个自定义订单状态 第一个是 运输状态 另一个是 批准状态 在我将一些订单状态更改为这两个新状态 分别是shipping or approved 客户无法在其订单历史记录页面查看此订单 这是我的代
  • 通过 request 在 Node.js 中获取下载进度

    我正在创建一个使用 Node 模块下载应用程序文件的更新程序request 我该如何使用chunk length估计剩余文件大小 这是我的代码的一部分 var file url http foo com bar zip var out fs
  • iPhone 开发 - 限制用户与应用程序的交互并显示进度指示器

    我有一个案例 我从服务器获取信息 我的应用程序有一个选项卡栏和导航按钮 我希望应用程序显示进度指示器并禁用所有其他控件 以便用户在从服务器提取数据时无法跳转 我怎样才能做到这一点 我想到的一种方法是显示带有进度窗口的透明视图 很像消息警报窗
  • 检查显示器是否已连接

    我必须制作一个简单的程序 向服务器报告显示器的状态 是开 关还是只是未连接 到目前为止 我正在使用在另一个讨论中找到的这种方法 但它每次都会返回 true 即使我已经断开了显示器的连接 public static Boolean isMon
  • 如何在 git checkout 中使用八进制字符?

    我有一个音乐文件的 git 存储库 最近我发现有些文件被删除了 我想我不小心删除了它们 但现在我只是短暂地陶醉于我有先见之明的事实 使用 git 存储库 因此我当前的 git 状态验证它们已被删除 以下是一些清单 deleted Steve
  • 检查线程状态,同时使其处于等待状态

    我想知道是否可以检查线程的状态 该线程可能处于可等待状态 但不一定如此 如果它处于可等待状态 我想将其保留在该状态 基本上 如何在不更改线程 可等待 状态的情况下检查线程的状态 通过等待 我的意思是如果我调用 wait pid 它会正确返回

随机推荐

  • 24.eslint

    eslint是约束代码写法的插件 xff0c 比如组件的命名必须要用驼峰命名这种 eslint官网 检测并修复 JavaScript 代码中的问题 ESLint 插件化的 JavaScript 代码检查工具 目录 1 vue cli的esl
  • CocoaPods的使用——pod install pod install --repo-update pod update pod update --repo-update

    Podfile文件中 xff0c 使用某个库时 不指定版本 xff0c 表示希望使用最新版本 xff0c 如 pod SDWebImage 指定明确版本 xff0c 表示只想要这个版本 xff0c 如 xff1a pod 39 SDWebI
  • SceneDelegate有什么作用?删除有什么影响

    自从Xcode11发布以来 xff0c 当你使用新XCode创建一个新的iOS项目时 xff0c SceneDelegate会被默认创建 xff0c 它到底有什么用呢 xff1f 在iOS 13 xff08 及以后版本 xff09 上 xf
  • UICollectionViewCell自适应宽度

    如图所示效果 xff0c 根据字符长度自适应UICollectionViewCell的大小 xff0c 同时进行左对齐处理 如何实现 继承UICollectionViewFlowLayout创建子类 xff0c 并实现相关的方法 xff0c
  • 微信小程序开发——JS中字符和数组的操作

    字符的操作 span class token keyword var span word span class token operator 61 span span class token string 34 hello world 34
  • 微信小程序开发——字体样式设置

    font style文字样式 normal 正常字体italic 斜体字oblique 倾斜字体 font weight文字粗细 取值范围 100 900normal 相当于400bold 粗体 相当于700bolderlighter fo
  • 异常处理——richview不显示cloud路径的图片

    图片上传后 xff0c 得到的文件路径为cloud xxx png格式 xff0c 使用image组件时 xff0c 正常显示 xff0c 但使用richview富文本组件时 xff0c 未显示出来 此时 xff0c 需要通过使用wx cl
  • 编译错误“Too many arguments to function call....”

    运行编译过程中出现错误 xff0c 并提示 Too many arguments to functions call expected 的信息 xff0c 如图一 遇到这种情况时 xff0c 该如何解决呢 xff1f 解决方法是将属性 En
  • CocoaPods的使用——cocoapods的升级更新

    最近使用cocoa pods时提示版本过低需要升级才能正常使用 但是在升级过程中又出现了问题 首先我是直接使用语句 xff1a sudo gem install cocoapods 进行更新升级的 xff0c 没想到又报错了 接着我在想是不
  • http请求方法(GET、POST、HEAD、OPTIONS、PUT、DELETE、TRACE、CONNECT)

    根据HTTP标准 xff0c HTTP请求可以使用多种请求方法 HTTP的1 0版本中只有三种请求方法 xff1a GET POST 和 HEAD方法 到了1 1版本时 xff0c 新增加了五种请求方法 xff1a OPTIONS PUT
  • MongoDB可视化工具 Studio 3T

    告别终端使用可视化工具Studio 3T对MongoDB进行数据库的操作 简单的使用步骤介绍 1 启动MongoDB服务器 xff08 方法见MongoDB介绍与安装中的介绍 xff09 2 连接MongoDB服务器 3 操作数据库
  • 微信小程序开发——form表单

    WeChat小程序交流 xff08 QQ群 xff1a 769977169 xff09 效果图 代码示例 1 xxx wxml lt form bindsubmit 61 39 submitClick 39 bindreset 61 39
  • 苹果电脑(Mac mini或Macbook或iMac)恢复出厂设置

    苹果电脑 xff08 Mac mini或Macbook或iMac xff09 恢复出厂设置 xff0c 首先要做好如下的准备 xff1a 第一 xff1a 数据的备份 xff1b 第二 xff1a 保证正常的wifi连接 xff1b 第三
  • VSLAM基础(一)————常见特征点提取算法及匹配优化

    过年期间闲来无事 xff0c 就想来把这半年学习的一些视觉知识 xff08 视觉slam相关 xff09 做个梳理 xff0c 就以这篇图像特征点提取与匹配作为开头吧 一 关键点与描述子 关键点 xff1a 图像上某些特殊的 具有代表的点
  • 【2017CS231n】第十五讲:神经网络模型压缩和加速(硬件、算法层面)

    一 算法 1 剪枝 不是所有的神经网络连接都有用 减少连接 xff0c 但不降低准确性 尝试性 xff1a 剪枝 xff0c 训练不断重复 xff0c 找到对准确性影响最高的那一部分连接 2 参数共享 1 98 2 09 1 92 1 87
  • 程序员面试等通知一般多久?

    最近面试的人比较多 xff0c 毕竟是金三银四嘛 xff0c 竞争也挺大的 xff0c 很多人在面试之后 xff0c 久久没有收到入职通知 xff0c 等待是一件非常痛苦的事情 那么程序员面试等通知一般多久 xff1f 多久没有发通知就等于
  • 程序员简历项目经验怎么写?

    我是一个典型的互联网公司程序员 xff0c 也见过无数的程序员简历 xff0c 包括很多优秀的程序员简历 xff0c 看了可以让人眼前一亮 xff0c 优美简洁的简历模板 xff0c 项目经验工作重点突出 也见过更多的写得不好的简历 程序员
  • OpenRAVE

    机器人的高级功能 机械手臂控制 软件方面 在ros里 有moveit 研究的过程中 扩展到了openrave专业包 Welcome to OpenRAVE Latest Official Release 0 8 2 OpenRAVE pro
  • C++——STL初识

    一 为什么需要STL xff1f 目的 xff1a 为了建立一套重复利用的东西 使用STL可以避免从事大量重复的工作 为建立数据结构的一套标准 xff0c 诞生了STL 二 基本概念 STL是标准模板库 STL从广义上分为 xff1a 容器
  • Showing progress bar in a status bar pane

    This article was contributed by Brad Mann This code creates a progress bar anywhere in the status window and the control