如题

解决方案 »

  1.   

    Screen.ActiveForm.Caption := '改';
      

  2.   

    var
        hw : THandel;
    begin
        hw :=GetActiveWindow();
        if hw>0 then 
        SetWindowText(hw,'新标题');
    end;
      

  3.   

    form的OnActivate事件self.catption:='激活的';form的OnDeActivate事件
    self.caption:='未激活';
      

  4.   

    的确,用ONACTIVATE 和 OnDeActive 事件比较好
      

  5.   

    在WinXP测试,以上方法只对程序本身创建的窗体有效。
      

  6.   

    GetActiveWindow 并不能获得其它程序的窗体句柄。
      

  7.   

    改成GetForegroundWindow()就可以了。如下var
        hw : THandle;
    begin
        hw :=GetForegroundWindow();
        if hw>0 then
        begin
          SetWindowText(hw,'新标题');
          SpinEdit1.Value := SpinEdit1.Value + 1;
        end;
    end;
      

  8.   

    procedure TForm1.tmrChangeCapTimer(Sender: TObject);
    var
       TheWindowText: array[0..255] of char;
       TheForegroundWindow: HWND;
    begin
       {get a handle to the foreground window}
       TheForegroundWindow:=GetForegroundWindow;   GetWindowText(TheForegroundWindow, TheWindowText, 255);   {display the foreground window's caption}
       self.Label1.Caption:='Foreground Window Text: '+TheWindowText;
       windows.SetWindowText(TheForegroundWindow, 'helloworld')
    end;