Galera tentando fazer aqui acho que consegui de uma olhada em como fico o código: vou postar o código inteiro da unit para outros que também quiser implementar. unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ScrollBox1: TScrollBox;
procedure PanelClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Panel_teste : array [1..100] of TPanel;
implementation
{$R *.dfm}
procedure TForm1.PanelClick(Sender: TObject);
var I : Integer;
begin
for I := 1 to 100 do
begin
if Panel_teste[I].MouseInClient then
begin
Panel_teste[I].Color := clYellow;
Break;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var I, Panel_left, Panel_top : Integer;
begin
Panel_left := 5;
Panel_top := 5;
for I := 1 to 100 do
begin
Panel_teste[I]:= TPanel.Create(ScrollBox1);
with Panel_teste[I] do begin
Visible := true;
Left := Panel_left;
Top := Panel_top;
Width := 179;
Height := 100;
BevelOuter := bvNone;
Caption := '';
Color := cl3DLight;
TabOrder := 1;
Name := 'Panel_'+IntToStr(I);
OnClick := PanelClick;
ParentBackground := False;
Parent := ScrollBox1;
end;
Panel_left := Panel_left + 190;
if Panel_left > Screen.Width then
begin
Panel_left := 5;
Panel_top := Panel_top + 112;
end;
end;
end;
end. Então este código passo a dar certo depois que coloquei o array só não sei dizer se esta foi a melhor solução pois como vocês podem ver ele vai ter que percorrer um laço que vai de 1 a 100 para testar em qual panel esta, em alguns casos este laço pode ser até maio.