osmeg,
Cita:
Empezado por osmeg
...No se puede cambiar color a TPanel creado en tiempo de ejecución...
|
Revisa este código:
Código Delphi
[-]
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
procedure FormCreate(Sender: TObject);
procedure PanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormMouseLeave(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Panel1.ParentBackground := False;
Panel2.ParentBackground := False;
Panel3.ParentBackground := False;
Panel4.ParentBackground := False;
end;
procedure TForm1.PanelMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if TPanel(Sender).Name = 'Panel1' then
Panel1.Color := clSkyBlue;
if TPanel(Sender).Name = 'Panel2' then
Panel2.Color := clGreen;
if TPanel(Sender).Name = 'Panel3' then
Panel3.Color := clYellow;
if TPanel(Sender).Name = 'Panel4' then
Panel4.Color := clRed;
end;
procedure TForm1.FormMouseLeave(Sender: TObject);
begin
if TPanel(Sender).Name = 'Panel1' then
Panel1.Color := clBtnFace;
if TPanel(Sender).Name = 'Panel2' then
Panel2.Color := clBtnFace;
if TPanel(Sender).Name = 'Panel3' then
Panel3.Color := clBtnFace;
if TPanel(Sender).Name = 'Panel4' then
Panel4.Color := clBtnFace;
end;
end.
El código anterior en Delphi XE7 sobre Windows 7 Professional x32,
Permite cambiar el color de un TPanel en tiempo de ejecución, como se muestra en la siguiente imagen:
Espero sea útil
Nelson.