Forms Delphi

Title: Drawing on the MDI Parent Form (Correct)
Question: How to correct paint something on MDI Parent Form
Code based on article #1144
Answer:
type
tform1 = class(tform)
image1 : timage ; // load the background image here,
// and set the visible property to false
procedure formcreate(sender : tobject); // for initialize canvas
procedure formdestroy(sender : tobject); // must be destroy canvas
// two events for refresh
procedure formpaint(sender : tobject); // the correct event for paint
procedure formresize(Sender : tobject); // the correct event for paint
private
background_canvas : tcanvas ; // pointer to MDI canvas
end ;
procedure tform1.formcreate(sender : tobject) ;
begin
background_canvas := tcanvas.create;
background_canvas.handle:=getdc(clienthandle);
end ;
procedure tform1.formdestroy(sender : tobject);
begin
releasedc(clienthandle,background_canvas.handle);
background_canvas.free;
end ;
procedure Tf_main.FormPaint(Sender: TObject);
begin
// on this event you can draw
background_canvas.draw(0,0,image1.Picture.Graphic) ;
end;
procedure tform1.formresize(sender: tobject);
begin
// on this event you can draw
background_canvas.draw(0,0,image1.Picture.Graphic) ;
end;