Solved

problems on Invalidate()

Posted on 1998-08-20
2
348 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 92
mixString challenge 36 120
Tab names are off by one 5 54
Way to decrease size of apk file 9 65
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

18 Experts available now in Live!

Get 1:1 Help Now