Canvas does not allow drawing.

From: Skybuck Flying (nospam_at_hotmail.com)
Date: 12/31/04


Date: Fri, 31 Dec 2004 07:20:01 +0100

Hi,

Start a new application and place an Timage on the form and load a little
picture into it.

Then place a timer on the form and set the interval to 50 or so.

Then paste this code into the timer event handler.

Then simply let it run a while. (It will draw the little picture onto the
desktop)

After a while it will "crash" Debugger notification exception (?) and say:
"Canvas does not allow drawing".. etc.

Why does this happen and what is the solution (if any ;)) ?

procedure TForm1.Timer1Timer(Sender: TObject);
var
 DesktopCanvas : TCanvas;
begin
 DesktopCanvas := TCanvas.Create;

 DesktopCanvas.Handle := GetDC(0);

 DesktopCanvas.Draw( 50, 50, Image1.Picture.Graphic );

 DesktopCanvas.Destroy;
end;

Bye,
  Skybuck



Relevant Pages

  • Re: Custom AC power switch
    ... upon which I'd paste a picture for her. ... >microwave, as I'm sure she could handle the popcorn picture just fine. ... Some ovens are very easy to ... timing mechanism with a timer for say 2 minutes maximum. ...
    (sci.electronics.design)
  • Re: Timer intervall to set form invisible
    ... I just tried to use a picture as ... pasted the controls and used the mousemove and click events of the picture ... what I do not understand is why the events of the frmMain (the one without ... >> events - if so and then do something within the time set by the timer ...
    (microsoft.public.access.formscoding)
  • Re: Scrolling text in a stationary label help needed
    ... Actually it's not working properly John. ... I assume that you're setting the ScaleMode of both the Form and the Picture Box to vbPixels. ... The other thing, which is very important, is the fact that your code is still not actually running in the Timer, at least not in the way it is meant to. ... You do this *just once* inside the Timer event. ...
    (microsoft.public.vb.general.discussion)
  • GUIs and Timers
    ... picture. ... I've been trying to use a timer to redraw the video ... function it puts the frame in a new window. ... have the same problem using guide-created code): ...
    (comp.soft-sys.matlab)