Click to See Complete Forum and Search --> : OnDraw


vikram deshmukh
June 9th, 1999, 03:46 AM
Hallo everybody ,

I knows OnDraw() is responsible for drawing the picure on Device
Context when the resizing of window takes place .

In my application , in the view-class implementation file , i'm displaying
a picture ,using a function other than OnDraw(). In that function i'm
getting a pathname from some other dialog .

In such a way i'm displaying many small pictures in the same DC . But in
case if i resize the window , then previous picturs goes out .

Is there any mechanism such that previous contents on the DC gets
restored , even after resizing the window ?

Please ...

Thanks in advance !

vikram

ric
June 9th, 1999, 04:10 AM
Try overriding the OnSize() function. It will be called every time your window is resized.

Jason Teagle
June 9th, 1999, 06:25 AM
Not that I'm aware of. As with anything you put onto the DC, it will be erased unless you repaint it all. Rather than drawing the images onto the DC independently of OnDraw(), you should instead set flags to indicate that the pictures should be drawn, and then call InvalidateRect() on the view to cause the view to be repainted. This is what the document is for - for storing data which the view will paint.

An example of how to implement dynamically drawn pictures is to have an array (in your document) of picture 'objects', which describe where on the screen they appear and what to draw (resource ID of a bitmap, for example). Initially this array would be empty, so the view would not draw anything.

When you need to show a new picture in the window, add its position and details to the document's array. Now, when the view repaints itself, it has some data to paint.

Does this make sense?