Hola a todos. Quiero agradecerles enormemente porque finalmente, Con la ayuda de Uds. porsupuesto, termine el componente que me propuse. Y aqui les dejo el codigo, espero su opinion, comentarios y sugerencias para que vayamos mejorandolo. Gracias.
Código Delphi
[-]
unit BRGFocusAdmin;
interface
uses
SysUtils, Classes, Graphics, StdCtrls, ComCtrls, Controls, Forms;
type
TBRGFocusAdmin = class(TComponent)
private
FColorconFoco:TColor;
FColorsinFoco:TColor;
FTomaFoco, FPierdeFoco, FTieneFoco:TComponent;
procedure ScreenActiveControlChange(Sender : TObject);
protected
public
Procedure AplicarColor(colorf:TColor;Componente:TComponent);
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
published
property Tag2:integer read FTag2 write FTag2;
property TagStr:string read FTagStr write FTagStr;
property ColorconFoco:TColor read FColorconFoco write FColorconFoco;
property ColorsinFoco:TColor read FColorsinFoco write FColorsinFoco;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('BRG', [TBRGFocusAdmin]);
end;
destructor TBRGFocusAdmin.Destroy;
begin
Screen.OnActiveControlChange := nil;
inherited;
end;
procedure TBRGFocusAdmin.ScreenActiveControlChange(Sender: TObject);
begin
if Screen.ActiveControl<>nil then
begin
Fpierdefoco:=FTieneFoco;
FtieneFoco:=Screen.ActiveControl;
if Fpierdefoco<>nil then
self.AplicarColor(FColorsinFoco, FPierdeFoco);
if FTieneFoco<>nil then
self.AplicarColor(FColorconFoco, FTieneFoco);
end;
end;
constructor TBRGFocusAdmin.Create(AOwner : TComponent);
begin
Screen.OnActiveControlChange := ScreenActiveControlChange;
inherited Create(AOwner);
end;
Procedure TBRGFocusAdmin.AplicarColor(colorf:TColor;Componente:TComponent);
begin
try
if (Componente is TEdit) then
(Componente as TEdit).Color:=colorf;
if (Componente is TComboBox) then
(Componente as TComboBox).Color:=colorf;
if (Componente is TDateTimePicker) then
(Componente as TDateTimePicker).Color:=colorf;
if (Componente is TMemo) then
(Componente as TMemo).Color:=colorf;
(Componente as TWinControl).Repaint;
except
end;
end;
end.
Solo tienen que soltarlo sobre su formulario principal y listo!!