Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Refreshing the dialog's appearance

Posted on 2002-07-19
3
Medium Priority
?
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Expert Comment

by:fl0yd
ID: 7166111
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 300 total points
ID: 7166126
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
ID: 7167192
Just wondering why did you grade this B?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 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