• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

problems on Invalidate()


  I have code structure like this in my program:

(inside a CView's subclass)

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

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.

1 Solution
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?
sunjian061197Author Commented:
Hi trestan,
   Thanks for your answer. I used your first suggestion(create a CClientDC) and now the program works fine!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now