I'm trying to get a program to produce some line drawings. I've chosen to use TImage. I've followed some information on the Web, but just can't get the first trial line to appear. Hopefully, I'm doing something very stupid which will be easily rectified. The code is shown below. Can someone provide me with the missing link to get this working.
With many thanks, Neville
========================================================================
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
TheImage: TImage;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
var Bitmap:TBitmap;
procedure TForm1.FormCreate(Sender: TObject);
begin
TheImage.left := 10;
TheImage.top := 10;
TheImage.width:=TheImage.Width - 20;
TheImage.height:=TheImage.Height - 20;
Bitmap := TBitMap.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TheImage.Picture.Bitmap.canvas.pen.color := clBlack;
TheImage.Picture.Bitmap.canvas.moveto(20,20);
TheImage.Picture.Bitmap.canvas.lineto(100,50);
TheImage.Picture.Graphic := Bitmap;
end;
end.