Solved

problems on Invalidate()

Posted on 1998-08-20
2
345 Views
Last Modified: 2013-11-20
Hi,

  I have code structure like this in my program:

(inside a CView's subclass)

for(i=0;i<1000;i++) {
 do some calculations;
 Invalidate();
}

In my OnDraw() method, the drawing depends on some variable which will be changed by "do some calculations" part. So I expect to see my drawing being updated constantly. However, what I got is: First there was a long delay, then only my final results are drawn. It seems that WM_PAINT messages got blocked when there is intensive calculation, and they can only get to the destination after the calculations are finished. Am I right on this? Can anyone tell me what I should do in order to "force" the window to call OnDraw() BEFORE the next calculation is made?
  Thank you in advance.

sunjian
0
Comment
Question by:sunjian061197
2 Comments
 
LVL 8

Accepted Solution

by:
trestan earned 50 total points
ID: 1321082
Yes. You are right. If you want to display the calculation results at each step, you can create a CClientDC then use text out to display the value on the screen. Or you can create another thread and pass the pDC to the thread to display. Any questions?
0
 

Author Comment

by:sunjian061197
ID: 1321083
Hi trestan,
   Thanks for your answer. I used your first suggestion(create a CClientDC) and now the program works fine!

sunjian
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
paragon account problem 9 96
post4 challenge 28 81
canBalance challenge 34 65
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 …
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

13 Experts available now in Live!

Get 1:1 Help Now