Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

GetFocus [D7, Win2k, WinXP]


Farel ©   (2007-07-12 20:28:00) 

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


oxffff   (2007-07-13 10:54:00) [1]


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


Посмотри Remarks


Zagaevskiy   (2007-07-13 10:16:00) [2]

А почему не GetWindowText?


oxffff   (2007-07-12 21:19:00) [3]

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


oxffff   (2007-07-12 21:11:00) [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


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

С помощью 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.


Farel   (2007-07-12 20:42:00) [6]

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


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

WM_GETTEXT


Наверх

Титульная страница Поиск, карта сайта Написать письмо