?
Solved

Refreshing the dialog's appearance

Posted on 2002-07-19
3
Medium Priority
?
229 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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