



Você pode criar um Timer para ir atualizando um Label, por exemplo. Então
conforma a janela ativa, o label irá mostrar o título da mesma.
É necessário estar declarado SysUtils e Windows na seção uses,
em versões unicode declare System.SysUtils e Winapi.Windows.
Segue o código fonte da função:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function GetTituloAtivo: string; var Handle: THandle; Len: LongInt; Title: string; begin Result := ''; Handle := GetForegroundWindow; if Handle <> 0 then begin Len := GetWindowTextLength(Handle) + 1; SetLength(Title, Len); GetWindowText(Handle, PChar(Title), Len); Result := TrimRight(Title); end; end; |
Exemplo de uso:
1 2 3 4 5 6 7 | procedure TForm1.Button1Click(Sender: TObject); var s : String; begin s := GetTituloAtivo; ShowMessage(s); end; |