Re: Using Images for Backgrounds on a Form ?

Posted by Lionel Joyner on February 02, 2006

In Reply to Re: Using Images for Backgrounds on a Form ? posted by Andrew on January 29, 2006

: I was thinking of using canvas.copyrect. It worked fine for me on timage.canvas, but for some reason doesn't work in form1.canvas. So maybe there could be a solution to that.

I tried using the timage.canvas and was not able to get it to work also I found a procedure online that I tried, but could not get it to work. I would still like to use an image for a background on a form but either I am making it too complicated or I don't understand the process. If you have an example code that works, I would appreciate a look at it.
Listed below is what I was trying to use.
--------------------------------------------

interface
//--------------------------------------
 uses
 Windows, SysUtils, Classes, Graphics, Forms;
 
 type
   TForm1 = class(TForm)
     procedure FormCreate(Sender: TObject);
     procedure FormPaint(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
 
 private
     { Private declarations }
   public
     { Public declarations }
     BMPbackground : TBitmap;
 end;
 
 var
 Form1: TForm1;
 
 implementation
 
 {$R *.DFM}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
  BMPbackground := TBitmap.Create;
  BMPbackground.LoadFromFile('Logo1.bmp');
end;
 
procedure TForm1.FormPaint(Sender: TObject);
begin
  Canvas.Draw( 0, 0, BMPbackground );
end;
 
procedure TForm1.FormDestroy(Sender: TObject);
begin
  BMPbackground.Free;
end;
//-----------------------------------------------
end.
 

Related Articles and Replies