4
votes

What MFC control should I use and how should I use it to display constantly changing text (like progress text) on a dialog?

For example, should I use the static text control? But can you change it programmatically?

1

1 Answers

3
votes

Yes, you can change the contents of a static control programmatically. Change the ID to something other than IDC_STATIC, then you can assign a member variable to it. You can set the text with your_var.SetWindowText().

Edit: how many changes are you making, and how fast? I did a quick test program with a timer (set to a duration of 0) that formats and writes a new string to the control when the time fires, so it's updating constantly. Here's what it looks like after running for a while:

Test program

And here's what Task Manager shows:

Task Manager

The spike a the right is (at least mostly) from taking the screen shot of the test program saving it, and so on. As soon as I quit doing things like that, CPU usage went back to do noise level (with the occasional blip). I left the program running -- a half hour or so later, it's still doing fine, with no noticeable CPU usage (in fast according to Task Manager, it hasn't used even one second of CPU time yet).