unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure proc_wsp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer); //wpis z klawiatury

  private
    { Private declarations }
    obr: TImage;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//proc.obslugi zdarzenia OnMouseDown wpisywana z klawiatury
procedure TForm1.FormDestroy(Sender: TObject);
begin
   obr.Free;
end;

procedure TForm1.proc_wsp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Label1.Caption:=InttoStr(X)+','+InttoStr(Y);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  obr:=TImage.Create(Self);
  obr.Parent:=Form1;
  obr.Left:=10; obr.Top:=120;
  obr.Width:=140;
  obr.Height:=100; obr.Stretch:=true;
 obr.Picture.LoadFromFile('kolory_test.bmp');
 obr.OnMouseDown:=proc_wsp;
end;

end.
