[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple bitmap question



Yep, you need to use on-paint. Try this:

(define bm-canvas%
   (class canvas%
     (inherit get-dc)
     (define/override (on-paint)
       (send (get-dc) draw-bitmap bitmap 0 0))
     (super-instantiate ())))

and then instantiate that instead of canvas% (and leave off the last 
two lines).

Robby

At 12:41 AM +0100 2/22/02, Jens Axel Søgaard wrote:
>The behaviour of the following program surprises me.
>It loads a bitmap from disk and displays it in a canvas.
>Executing it, one can briefly see the image, but almost
>immediately, the canvas is cleared.
>
>Why is the canvas cleared? Have I overlooked something
>(on-paint perhaps) ?
>
>(version 200alpha12, windows XP)
>
>(define frame (make-object frame% "Foo"))
>
>(define bitmap (make-object bitmap% "Foo.jpg" 'jpeg))
>(define h (send bitmap get-height))
>(define w (send bitmap get-width))
>
>(define canvas (instantiate canvas% ()
>                  (parent frame) (min-width w) (min-height h)))
>(send frame show #t)
>
>(define dc (send canvas get-dc))
>(send dc draw-bitmap bitmap 0 0 )
>
>
>Yours,
>--
>Jens Axel