The initial code is as follows:
procedureTform1.button1click (sender:tobject);varPanel:tpanel;beginPanel:= Tpanel.Create(FORM1); Panel.name:='Pnlprevideo'; Panel.parent:=Form1; Panel.onclick:=Panel1click; MoveWindow (Panel.handle,Ten,Ten, -, -, True);End;procedureTform1.panel1click (sender:tobject);begin if(Sender asTpanel). Name ='Pnlprevideo' Then(Sender asTpanel). Color: =Clgreen;End;
When clicked, the color does not change, ask Netizen, originally is a bug, correct after code as follows:
procedureTform1.button1click (sender:tobject);varPanel:tpanel;beginPanel:= Tpanel.Create(FORM1); Panel.name:='Pnlprevideo'; Panel.parentbackground:=False; Panel.parent:=Form1; Panel.onclick:=Panel1click; MoveWindow (Panel.handle,Ten,Ten, -, -, True);End;procedureTform1.panel1click (sender:tobject);begin if(Sender asTpanel). Name ='Pnlprevideo' Then(Sender asTpanel). Color: =Clgreen;End;
Http://www.cnblogs.com/jxgxy/p/3248408.html
A panel dynamically created in Delphi cannot change color resolution (to set the panel's parentbackground to false)