Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.08.12;
Скачать: CL | DM;

Вниз

GetFocus   Найти похожие ветки 

 
Farel ©   (2007-07-12 20:28) [0]

Всем привет!
У меня программа получает Handle активного окна.
Подскажите пожалуйста как по полученному Handle можно считать из объекта текст, получить Caption активного окна.


 
Юрий Зотов ©   (2007-07-12 20:37) [1]

WM_GETTEXT


 
Farel ©   (2007-07-12 20:42) [2]

А с примерчиком не поможете?


 
Farel ©   (2007-07-12 21:00) [3]

С помощью WM_GETTEXT я получаю значение типа integer, вот мой кусочек кода программы. Что-то не так? Подскажите.

type
 TForm1 = class(TForm)
   Timer1: TTimer;
   Label1: TLabel;
   Label2: TLabel;
   Label3: TLabel;
   Label4: TLabel;
   procedure Timer1Timer(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var
dwTargetOwner :DWORD;
dwThreadID :DWORD;//указатель на текущий процесс
Result:longbool;

{ProcessHandle : THandle;
TheWindow : HWND;
Classname,WindowTitle : string;
ProcessID: Integer;}

dc:hdc;
begin

{В первой метке отображается Handle активного окна}
Label1.Caption:=IntToStr(GetForegroundWindow);
dwTargetOwner := GetWindowThreadProcessId(GetForegroundWindow,nil);
dwThreadID := GetCurrentThreadId();//указатель на текущий процесс

if (dwTargetOwner <>dwThreadID) then // если не один и тот же процесс
Result := AttachThreadInput(dwThreadID, dwTargetOwner, TRUE);

{отображается Handle объекта "в фокусе" в активном окне}
Label2.Caption:=IntToStr(GetFocus);

Label4.Caption :=inttostr(WM_GETTEXT);//~~~

dc := GetDC(GetFocus);
Rectangle (dc, 10, 10, 110, 110);
ReleaseDC (Handle, dc);
DeleteDC (DC);

if (Result) then
AttachThreadInput(dwThreadID, dwTargetOwner, FALSE);//отключение

end;

end.


 
oxffff ©   (2007-07-12 21:11) [4]

WM_GETTEXT

This message is sent by an application to copy the text that corresponds to a window into a buffer provided by the caller.

WM_GETTEXT wParam = (WPARAM) cchTextMax;
 lParam = (LPARAM) lpszText;
Parameters
cchTextMax
Specifies the maximum number of characters to be copied, including the terminating null character.

lpszText Long pointer to the buffer that is to receive the text.


и он в LPARAM


 
oxffff ©   (2007-07-12 21:19) [5]

var a:array[1..100] of char;
begin
SendMessage(handle,WM_GETTEXT,sizeof(a),DWORD(@a));
showmessage(pchar(@a));


 
Zagaevskiy ©   (2007-07-13 10:16) [6]

А почему не GetWindowText?


 
oxffff ©   (2007-07-13 10:54) [7]


> Zagaevskiy ©   (13.07.07 10:16) [6]
> А почему не GetWindowText?


Посмотри Remarks



Страницы: 1 вся ветка

Текущий архив: 2007.08.12;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.025 c
2-1184413664
ououoy
2007-07-14 15:47
2007.08.12
вопрос про константы


8-1163045712
Lilu
2006-11-09 07:15
2007.08.12
DirectDraw и вывод текста под углом


2-1184835818
pathfinder
2007-07-19 13:03
2007.08.12
Переделка компонентов..


3-1177506771
Jacks
2007-04-25 17:12
2007.08.12
Select


11-1167219392
Galkov
2006-12-27 14:36
2007.08.12
Расскажите пожалуйта, что такое Applet