...get the caption of the control under the mouse cursor?
Author: Twister
function GetCaptionAtPoint(CrPos: TPoint): string;
var
textlength: Integer;
Text: PChar;
Handle: HWND;
begin
Result := 'Empty';
Handle := WindowFromPoint(CrPos);
if Handle = 0 then Exit;
textlength := SendMessage(Handle, WM_GETTEXTLENGTH, 0, 0);
if textlength <> 0 then
begin
getmem(Text, textlength + 1);
SendMessage(Handle, WM_GETTEXT, textlength + 1, Integer(Text));
Result := Text;
freemem(Text);
end;
end;
printed from
www.swissdelphicenter.ch
developers knowledge base