?
Solved

problems on Invalidate()

Posted on 1998-08-20
2
Medium Priority
?
353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
trestan earned 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 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