Ver Mensaje Individual
  #1  
Antiguo 13-06-2012
Avatar de cesarsoftware
cesarsoftware cesarsoftware is offline
Miembro
 
Registrado: nov 2006
Posts: 241
Reputación: 18
cesarsoftware Va por buen camino
Saber si un control tiene asignado OnEnter

Hola compis.

He hecho la tipica funcion para resaltar los controles de entrada (TEdit, TmaskEdit, etc). Todo funciona bién.
Este es el código
Código Delphi [-]
procedure TFormProveedorFactura.FormCreate(Sender: TObject);
begin
  ControlesResaltados();
end;

procedure TFormProveedorFactura.ControlesResaltados();
var
  i: word;
begin
  for i := 0 to FormProveedorFactura.ComponentCount - 1 do
  begin
    if FormProveedorFactura.Components[i] is TWinControl then
    begin
      TFormProveedorFactura(Components[i]).OnEnter := ControlEnter;
      TFormProveedorFactura(Components[i]).OnExit := ControlExit;
    end;
  end;
end;

procedure TFormProveedorFactura.ControlEnter(Sender: TObject);
begin
  TWinControl(Sender).Brush.Color := clLime;
end;

procedure TFormProveedorFactura.ControlExit(Sender: TObject);
begin
  TWinControl(Sender).Brush.Color := clWindow;
end;
El tema es que algunos controles ya tienen las funciones onenter y onexit activadas, asi que las sustituyo.
Lo que no acierto es ha averiguar si el control ya tiene asignados los enventos para no incluirlos en esta funcion, y que sean esa funciones las que gestionen su entrada y salida algo si como
Código Delphi [-]
procedure TFormProveedorFactura.FechaVencimientoExit(Sender: TObject);
begin
  FechaVencimiento.Visible := False;
  TimerVencimientos.Enabled := False;
  ControlExit(Sender);
end;

procedure TFormProveedorFactura.ControlesResaltados();
var
  i: word;
begin
  for i := 0 to FormProveedorFactura.ComponentCount - 1 do
  begin
    if FormProveedorFactura.Components[i] is TWinControl then
    begin
      if TFormProveedorFactura(Components[i]).OnEnter = nil then
        TFormProveedorFactura(Components[i]).OnEnter := ControlEnter;
      if TFormProveedorFactura(Components[i]).OnExit = nil then
        TFormProveedorFactura(Components[i]).OnExit := ControlExit;
    end;
  end;
end;
Si no, despues de activar la funcion tengo re reescribir el codigo a cada control que tenga un onenter o un onextit
FechaVencimiento.onExit := FechaVencimientoExit

A ver si sabeis como hacerlo (y me lo contais, .)
Thanks
Responder Con Cita