Получить заголовок элемента управления под мышкой

Материал из DRKB

Получить заголовок элемента управления под мышкой[править | править код]

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;


Source: Взято с сайта: http://www.swissdelphicenter.ch
ID: 01601