Link to home
Start Free TrialLog in
Avatar of trabar
trabar

asked on

Refreshing the dialog's appearance

I have a very standard dialog box.  The InitDialog posts a WM_USER +1 message before returning, the WM_USER +1 message is handled bya function that goes around in a loop, at the end of which CDialog::OnCancel is called to dispose the dialog box altogether.

During each cycle of the loop I want the dialog box to refresh its look (i.e. process WM_PAINT properly), I can't get this to happen, though.

Any suggestions?

Avatar of fl0yd
fl0yd

Think about what's happening here:
* the dialog is created and initialized
* WM_USER + 1 -msg is posted
* WM_USER + 1 -msg is handled in function fxn
* fxn runs in a loop before
* destroying the dialog
Even if you called InvalidateRect( NULL, FALSE ); and thus posted WM_PAINT-messages to the dialog message queue you are unable to handle them until fxn has returned. When it does, though, the dialog has already been destroyed.

You have two solutions: Either use multithreading which I would discourage in this case or redesign this awkward approach. Whenever something seems too complex it is probably wrong. Without knowing too much about this specific situation I would assume that your approach isn't exactly what I'd call feasable.
ASKER CERTIFIED SOLUTION
Avatar of mblat
mblat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just wondering why did you grade this B?