刚开始代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
Panel: TPanel;
begin
Panel := TPanel.Create(Form1);
Panel.Name := 'pnlPreVideo';
Panel.Parent := Form1;
Panel.OnClick := Panel1Click;
MoveWindow(Panel.Handle, , , , , True);
end; procedure TForm1.Panel1Click(Sender: TObject);
begin
if (Sender as TPanel).Name ='pnlPreVideo' then
(Sender as TPanel).Color := clGreen;
end;
单击时,颜色不变,问网友,原来是一个BUG,更正后代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
Panel: TPanel;
begin
Panel := TPanel.Create(Form1);
Panel.Name := 'pnlPreVideo';
Panel.ParentBackground := False;
Panel.Parent := Form1;
Panel.OnClick := Panel1Click;
MoveWindow(Panel.Handle, , , , , True);
end; procedure TForm1.Panel1Click(Sender: TObject);
begin
if (Sender as TPanel).Name ='pnlPreVideo' then
(Sender as TPanel).Color := clGreen;
end;