如何在使用C ++从MFC基于对话框的应用程序中读取文件时实现进度条控制? [英] How to implement progress bar control while reading from a file in an MFC dialog-based application using C++?

查看:82
本文介绍了如何在使用C ++从MFC基于对话框的应用程序中读取文件时实现进度条控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在开发一个项目,我需要读取一个文件并显示它的进度。完成后,它应该发出一条消息,说明提取成功。我正在使用c ++开发代码。我创建了一个带有进度条的对话框,并分配了一个控制变量m_Progress来管理进度条控件。

我还创建了另一个对话框,其中包含要读取的文件的路径/名称。我不确定如何使用给定文件的读取操作映射进度条。

任何帮助将不胜感激。



我尝试了什么:



我已经尝试逐行读取文件,直到达到eof我会调用StepIt() m_Progress的方法。但它根本没有显示进度。

Hello,
I'm developing a project where I'm required to read a file and display it's progress. Once completed, it should give out a message stating that the extraction was successful. I'm developing the code using c++. I've created a dialog box with a progress bar and assigned a control variable m_Progress to manage the progress bar control.
I've also created another dialog box which takes the path/name of the file to be read. I'm not sure how to map the progress bar with the read operation of the given file.
Any help would be greatly appreciated.

What I have tried:

I've tried reading the file line by line and until it reaches eof I would call StepIt() method of m_Progress. But it doesnt show the progress at all.

推荐答案

首先计算要处理的数据量,即100%的值。然后,当您读取数据时,您可以按处理文件的任何百分比移动进度条。您可以在数据传输的基础上执行此操作,也可以使用计时器以固定的时间间隔进行更新。
You start by calculating the amount of data to be processed, which is your 100% value. Then, as you read the data you move the progress bar by whatever percentage of the file has been processed. You can do this on a data transferred basis, or by using a timer to update at fixed intervals.


这篇关于如何在使用C ++从MFC基于对话框的应用程序中读取文件时实现进度条控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆