Re: My window doesn't re-display itself



Generally, when you start thinking about putting PeekMessage calls in, this is strongly
suggestive of the wrong approach to the design entirely. If there is a long computation
it should be done in a background thread.
joe

On Mon, 21 Jul 2008 08:10:30 -0700 (PDT), Mikel <mikel.luri@xxxxxxxxx> wrote:

On 21 jul, 16:15, Mike Silva <snarflem...@xxxxxxxxx> wrote:
Hi,

I have written some utilities as MFC dialog apps.  They will typically
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 at
www.flounder.com/workerthreads.htm

It seems more complicated (and it is) but things work fine if done
right.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: My window doesnt re-display itself
    ... You are locking up the message pump, while your loop is running the apps ... Or you can pump messages during your loop. ... If, while my utility app is processing files, I select another app, ...
    (microsoft.public.vc.mfc)
  • Re: Copy file!
    ... write small utility app that runs on handheld ... stops main app ... restarts main app ... b)start utility app ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Determine window of program that launched my program
    ... > When I click a certain button in one app, ... > launch a utility app. ... original app or perhaps have the original app pass some value to the ...
    (comp.programming)
  • Re: display array in a frame wnd
    ... you have to create an app that is suitable for displaying an image. ... There would never be a need to create a frame window; it is not at all clear why such code ... I have to display results. ... Why is this not in an OnPaint handler? ...
    (microsoft.public.vc.mfc)
  • Re: OODesign - OPF, design pattern
    ... I developed a Pocket PC app last year using the compact framework. ... Maybe my design is just very simple then, ... and its in the application layer not the business ...
    (borland.public.delphi.non-technical)