darkbits,
Revisa este código:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
uses
Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := 'DEVUELTO';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Label1.Caption := 'NO DEVUELTO';
end;
procedure TForm1.Button3Click(Sender: TObject);
var
NameControl : String;
begin
NameControl := 'Label1';
If StatusCaption(Form1,NameControl) then
ShowMessage('Estatus Devuelto')
else
ShowMessage('Estatus No Devuelto')
end;
end.
Código Delphi
[-]
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Function StatusCaption(f : TForm; NameControl : String) : Boolean;
implementation
Function StatusCaption(f : TForm; NameControl : String) : Boolean;
var
Control : TComponent;
begin
Control := f.FindComponent(NameControl);
With Control as TLabel Do
begin
if Caption='DEVUELTO' then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
end;
end.
Al pasar el formulario y el nombre del control a verificar perteneciente a ese formulario (En el ejemplo Label1) por medio de la función StatusCaption, puedes centralizar en una sola rutina la verificación del estatus del control sin importar el número de formularios donde la realices.
Espero sea útil
Nelson.