Solved

Refreshing the dialog's appearance

Posted on 2002-07-19
3
225 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
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 100 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ffmpeg - "rtsp://...... Operation not permitted" 4 89
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 116
Message not shown 5 85
Work with App store 7 94
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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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