Recent

Author Topic: SOLVED-Drawing bmp or Jpg to forms  (Read 1856 times)

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
SOLVED-Drawing bmp or Jpg to forms
« on: January 11, 2013, 12:38:13 am »
Ok here is my problem, I have a bluerose.bmp that im trying to draw to the form
without using tImage component.  The purpose is so my other controls will not be behind
the image, but rather float on top of the painted image.

This complies with no errors but my image does not draw to the forms canvas.

Also note I am using a debian linux based distro i386
FPC 2.6, and Lazarus 1.04

Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;

type

  { TForm1 }

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure FormDestroy(Sender: TObject);

  private
    { private declarations }
  public
    { public declarations }
     backgroundImage : TBitmap;
  end;


var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  backgroundImage := TBitmap.Create;
  backgroundImage.LoadFromFile('/home/technet/bluerose.bmp');
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  Canvas.Draw( 0,0, backgroundImage );
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
 backgroundImage.Free;
end;

end.           

I figured it out :)
It was not working because on the properties under onpaint event was not selected form paint
« Last Edit: January 11, 2013, 01:08:19 am by wjackson153 »
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

 

TinyPortal © 2005-2018