在mfc中创建对话框时,如何自动为进度条设置动画 [英] How do I automatically animate the progress bar when the dialog box created in mfc
问题描述
我在我的mfc应用程序中设计了一个带有进度条控件的对话框。还有一个导入文件夹功能。我想显示带有动画进度条的对话框,它会告诉对话框打开后剩余多少时间(没有任何onButtonclick)。
我写了一个函数正在这样做,但问题是我必须触发与对话框类相关的事件(如按钮单击)以显示动画进度条。我怎么能这样做?
如果我在onInitDialog函数中编写该代码,它将不会显示动画,而是显示进度条的最后状态(即onInitDoalog显示对话框返回true时。
我尝试过的事情:
我也尝试在对话框类中创建一个函数:
I have a dialogbox designed in my mfc application with a progress bar control. Also a import folder function. I want to show the dialog box with animated progress bar which will tells how much time left once the dialog box opened (without any onButtonclick).
I write a function which is doing it but the problem is I have to trigger an event (like button click ) related to dialog box class to show animated progress bar. How could I do that??
If I write that code in onInitDialog function, it won't display the animation but the last state of progress bar (i.e onInitDoalog display the dialogbox when it returns true).
What I have tried:
I also tried to make a function in dialog box class :
void viewProgrssBar();
in该函数:
and in that function:
for ( int pp=0; pp<expp.size(); pp++){
string fnm = expp.at(pp).substr(expp.at(pp).find_last_of("/")+1,expp.at(pp).size());
CWnd *label = GetDlgItem(IDC_STATIC1);
wstring w = wstring(fnm.begin(), fnm.end());
m_importProgress.StepIt();
label->SetWindowText(w.c_str());
}
并在我声明对话框类的对象之后调用该函数,并引用该对话框
and calling that function right after where I declare an object of dialog box class with reference of that dialog box
推荐答案
要实现它,你应该使用wm_timer事件或线程。
To implement it, you should probably use wm_timer events or thread.
这篇关于在mfc中创建对话框时,如何自动为进度条设置动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!