Search results for 'WM_GETTEXT'. 1 post(s) found.

  1. 2007/09/20 Get text from the control at pos x,y on screen
2007/09/20 08:32

Get text from the control at pos x,y on screen


This form has 3 labels and a timer component:

unit unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure FormCreate(Sender: TObject) ;
    procedure Timer1Timer(Sender: TObject) ;
  private
  procedure ShowHwndAndClassName(CrPos: TPoint) ;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ShowHwndAndClassName(CrPos: TPoint) ;
var
  hWnd: THandle;
  aName,
  Text : array [0..255] of char;
begin
  hWnd := WindowFromPoint(CrPos) ;
  Label1.Caption := 'Handle : ' + IntToStr(hWnd) ;

  if boolean(GetClassName(hWnd, aName, 256)) then
    Label2.Caption := 'ClassName : ' + string(aName)
  else
    Label2.Caption := 'ClassName : not found';
  SendMessage(hWnd, WM_GETTEXT,
              SizeOf(Text), integer(@Text)) ;
  Label3.Caption := 'Text :' + Text;
end;

procedure TForm1.FormCreate(Sender: TObject) ;
begin
  Form1.FormStyle := fsStayOnTop;
  Timer1.Interval := 50;
end;

procedure TForm1.Timer1Timer(Sender: TObject) ;
var
  rPos: TPoint;
begin
  if boolean(GetCursorPos(rPos))
  then ShowHwndAndClassName(rPos) ;
end;
end.
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 01:38 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 09:45 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:40 delete

    moneyideas