CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: OnDraw

  1. #1
    Join Date
    Apr 1999
    Posts
    12

    OnDraw

    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


  2. #2
    Join Date
    Apr 1999
    Posts
    306

    Re: OnDraw

    Try overriding the OnSize() function. It will be called every time your window is resized.


  3. #3
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: OnDraw

    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?



    --
    Jason Teagle
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured