Yes, you can add a OnClick event to a TCustomControl. You can also add
mouse and keyboard events, popup menu and a series of other things.
On 1/29/07, Gustavo Enrique Jimenez <[EMAIL PROTECTED]> wrote:
Felipe:
You help me a lot with drawing in a TCustomControl, thank you very much.
But I have a new question : it is possible to add a OnCLick event to a
TCustomControl ?
Thanks in advance. I only need a hint on where to start. I have no
problem on reading source code.
Thank you again !
Gustavo
2006/12/20, Felipe Monteiro de Carvalho <[EMAIL PROTECTED]>:
> On 12/20/06, Gustavo Enrique Jimenez <[EMAIL PROTECTED]> wrote:
> > Do you know how to LoadFromFile a picture to your TTela ?
>
> You need to modify TTela to allow this. A quick idea is doing this:
>
> type
> TTela = class(TCustomControl)
> public
> bmpTela: TBitmap;
> procedure Paint; override;
> end;
>
> TForm1 = class(TForm)
> Timer1: TTimer;
> procedure FormCreate(Sender: TObject);
> procedure FormDestroy(Sender: TObject);
> procedure Timer1Timer(Sender: TObject);
> private
> Tela: TTela
> ----
>
> procedure TTela.Paint;
> var
> x, y: Integer;
> Bitmap: TBitmap;
> begin
> Bitmap := TBitmap.Create;
> try
> Bitmap.Height := Height;
> Bitmap.Width := Width;
>
> Bitmap.Canvas.Pen.Color := clWhite;
> Bitmap.Canvas.Rectangle(0, 0, Width, Height);
>
> if Assigned(bmpTela) then Bitmap.Draw(0, 0, bmpTela);
>
> Canvas.Draw(0, 0, Bitmap);
> finally
> Bitmap.Free;
> end;
>
> inherited Paint;
> end;
>
> procedure TForm1.FormCreate(Sender: TObject);
> begin
> Tela := TTela.Create(Self);
> Tela.Height := 400;
> Tela.Width := 500;
> Tela.Parent := Self;
> Tela.DoubleBuffered := True; // Required to avoid flickering on Windows
>
> Tela.bmpTela := TBitmap.Create;
> Tela.bmpTela.LoadFromFile("filename");
> end;
>
> procedure TForm1.FormDestroy(Sender: TObject);
> begin
> Tela.bmpTela.Free;
> Tela.Free;
> end;
>
> procedure TForm1.Timer1Timer(Sender: TObject);
> begin
> Tela.Invalidade;
> end;
>
> > ps: congratulations for all of your contributions.
>
> You are welcome =)
>
> --
> Felipe Monteiro de Carvalho
>
--
Felipe Monteiro de Carvalho
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives