TScreen 类 - 判断当前焦点在哪个窗体上


unit Unit1;



interface



uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, ExtCtrls, StdCtrls;



type

  TForm1 = class(TForm)

    Timer1: TTimer;

    Button1: TButton;

    procedure Timer1Timer(Sender: TObject);

    procedure Button1Click(Sender: TObject);

  end;



var

  Form1: TForm1;



implementation



{$R *.dfm}



uses Unit2; {本例还包含另一个窗体 Form2}





//标题显示当前窗体的类名

procedure TForm1.Timer1Timer(Sender: TObject);

begin

  Text := Screen.ActiveForm.ClassName;

end;



//激活另一个窗体一试

procedure TForm1.Button1Click(Sender: TObject);

begin

  Form2.Show;

end;



end.


 
   

你可能感兴趣的:(screen)