unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
var h:HWnd;
i:integer;
WText : array [0..255] of char;
begin
    h:=GetActiveWindow();
     GetWindowText(h,WText,255);
  edit1.Text:= WText;
end;end.
以上代码,在这个程序为当前程序时能看到edit1中的内容,当为非活动时,edit1就为空了,这是为什么?

解决方案 »

  1.   

    非活动状态,一般是收不到WM_TIMER这个消息的,所以才导致Timer1Timer过程不能被执行。
      

  2.   

    非活动状态,一般是收不到WM_TIMER这个消息的,所以才导致Timer1Timer过程不能被执行。
    _______________________________
    那怎样才能在非活动时执行上述功能呢?
      

  3.   

    在非活动状态可以用timer取得所有的进程,为什么不能取得活动窗口呢?????
      

  4.   

    GetActiveWindow 表示你自己程序的活动窗口
    GetForegroundWindow 表示系统的活动窗口你再试试
      

  5.   

    hangguojun(布丁),万分感谢!!!!!!!!