Entwickler-Ecke

Grafische Benutzeroberflächen (VCL & FireMonkey) - Am Fensterhandle Caption eines Fensters herausfinden


hallo - Di 20.07.04 14:09
Titel: Am Fensterhandle Caption eines Fensters herausfinden
Hi,

wie kann ich wenn ich das Handle eines Fensters hab, die Caption dazu rausfinden?

PS Hab schon im Forum gesucht, aber nichts gefunden


Viper - Di 20.07.04 14:15

Das geht mit der function GetWindowText.
hier ein Auszug aus der PSDK:
Zitat:

Syntax

int GetWindowText(
HWND hWnd,
LPTSTR lpString,
int nMaxCount
);

Parameters
hWnd
[in] Handle to the window or control containing the text.
lpString
[out] Pointer to the buffer that will receive the text. If the string is as long or longer than the buffer, the string is truncated and terminated with a NULL character.
nMaxCount
[in] Specifies the maximum number of characters to copy to the buffer, including the NULL character. If the text exceeds this limit, it is truncated.

Return Value
If the function succeeds, the return value is the length, in characters, of the copied string, not including the terminating NULL character. If the window has no title bar or text, if the title bar is empty, or if the window or control handle is invalid, the return value is zero. To get extended error information, call GetLastError.
This function cannot retrieve the text of an edit control in another application.



maxk - Di 20.07.04 14:15


Delphi-Quelltext
1:
2:
3:
4:
var Buf:array[0..1024of Char;
begin
 GetWindowText(Handle,Buf,SizeOf(Buf));
 ShowMessage(StrPas(Buf));


//Edit: Verdammt schon wieder zu langsam :cry:


Viper - Di 20.07.04 14:22

mach dir nix raus, dafür hat er jetzt sogar noch ein Beispiel!


hallo - Mi 21.07.04 14:12

DANKE FÜR DIE ANTWORTEN!

Das war ja ein ganz kurzer Code! ;-)
Ich hab gedacht der wäre länger!
ALSO NOCHMALS VIELEN DANK!