On 21 jul, 16:15, Mike Silva <snarflem...@yahoo.com> wrote:
Hi,
I have written some utilities as MFC dialog apps. They will typicall=
loop through some list doing things to various files, and listing
their progress in static text windows (info such as current file name,
number of files processed, number of files remaining). The apps do
what they're supposed to and everything is fine, and the status
displays work properly, except...
If, while my utility app is processing files, I select another app,
e.g. check my email or browse the web, and then select the utility app
again, the display does not refresh - all I get is a completely blank
dialog box. The windows and controls inside the dialog box only
refresh when the utility is finished running. If I never navigate
away from the utility app, the display keeps updating as expected and
designed.
So, what do I need to do (perhaps after each file is processed) to
assure that my display is responsive and everything will re-display
when the app window goes from inactive to active? Thanks.
Mike
Well, the quick n' dirty way would be to do something like the
following after each file (or after every N files):
while (::PeekMessage(&msg, NULL,0,0,PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
However, the *right* way would be to create a worker thread to process
the files. Thus, the UI won't freeze.
Take a look at Joseph M. Newcomer's essay on worker threads atwww.flounde=
Thanks for the article link. Definitely sounds like something I
should learn and utilize.