Solved

Refreshing the dialog's appearance

Posted on 2002-07-19
3
221 Views
Last Modified: 2013-11-20
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?

0
Comment
Question by:trabar
  • 2
3 Comments
 
LVL 8

Expert Comment

by:fl0yd
Comment Utility
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.
0
 
LVL 4

Accepted Solution

by:
mblat earned 100 total points
Comment Utility
Or as an alternative you can try to force-process messages inside you loop.

put something like this here

while(bMyBeryLongLoop)
{
     MSG rMsg;
     while (::PeekMessage(&rMsg,0,0,0,PM_NOREMOVE)){
        AfxGetApp()->PumpMessage();
   
     // and do you stuff here....
  }
}

I don't really like this type of coding, but it works...
Hope it helps...
0
 
LVL 4

Expert Comment

by:mblat
Comment Utility
Just wondering why did you grade this B?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now