Solved

problems on Invalidate()

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

929 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

11 Experts available now in Live!

Get 1:1 Help Now