Click to See Complete Forum and Search --> : using RectVisible in OnDraw


Sean
April 15th, 1999, 12:23 AM
In my MFC MDI I have come encountered the following problem:
Firstly, my program opens image files, process the data and display it, one row at a time - i.e it processes one row of data and then displays it on screen before processing the next row. The data processing is complex so displaying the whole image takes quiet a bit of time. So as to process only the rows of the image that will be displayed on screen I use RectVisible before processing each row. This saves some time when scrolling up and down, but when I scroll horizontally, all of the image rows visible on the screen need to be redrawn, even though it is only necessary to draw a little bit of the row. So the solution that I'm trying to implement now, is.... (btw, when processing the data, I have to process a whole row at a time, but I can print as much or as little as I like) ..... in OnDraw, I do a RectVisible on the whole row. If I find that the row needs to be redrawn I process the row data, and then I do RectVisible on smaller sections of this row and redraw only the necessary parts.
Could somebody tell me if this is an efficient method? Or could you tell me of another better way?
Thank you,
Sean.

Karl
April 15th, 1999, 03:22 AM
You may use CDC::GetClipBox( LPRECT lpRect ) to konw the clipping rectangle. Don't draw outside this rectangle, because it will be clipped. More, if this method returns NULLREGION, don't do anything.
You may also you a Memory DC (see the article about CMemDC on this site).

HTH

K.


Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.

Sean
April 15th, 1999, 03:44 AM
Firstly thanks for the reply.

So, do you mean that if Idraw a row of image data to the screen, then when I scroll to the right or left I should use GetClipBox to tell me if a particular part of the row of data was covered(in which case I should redraw it) or uncovered( I should do nothing), or if it stayed the same (I should also do nothing)???

Karl
April 15th, 1999, 04:01 AM
It is a generalway of drawing, doesn't matter you was scrolling before. The system tells you what part you should draw. And sometimes, OnDraw is called when nothing is to be drawn. So, don't draw in this case.

K.

Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.