powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Поиск окна
2 сообщений из 2, страница 1 из 1
Поиск окна
    #32114982
Sergmal
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Нужно найти DOS-овское окно. Использую FindWindow(Classname, WindowTitle);
WindowTitle - не известно.
Вопрос какой Classname у DOS-овского окна?
...
Рейтинг: 0 / 0
Поиск окна
    #32115385
Фотография hDrummer
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Using FindWindow won't necessarily get you a window that belongs to the
process you created. A more reliable method would be to use EnumWindows,
using the return value from GetWindowThreadProcessId to check for a match
with the values set in your TProcessInfo record above.


Try this:

type
PFindProcessWindowStruct = ^TFindProcessWindowStruct;
TFindProcessWindowStruct = record
Process: DWord;
Title: PChar;
Window: hWnd;
end;

function fpwCallback(wnd: hWnd; Param: lParam): Bool; stdcall;
var
fpws: PFindProcessWindowStruct;
ProcID: DWord;
len: Integer;
ptitle: PChar;
begin
Result := True;
fpws := PFindProcessWindowStruct(Param);
GetWindowThreadProcessId(wnd, @ProcID);
if ProcID = fpws.Process then begin
if Assigned(fpws.Title) then begin
len := GetWindowTextLength(wnd) + 1;
ptitle := StrAlloc(len);
try
GetWindowText(wnd, ptitle, len);
if StrComp(ptitle, fpws.Title) <> 0 then exit;
finally
StrDispose(ptitle);
end;
end;
Result := False;
fpws.Window := wnd;
end;
end;

// AProcess: The process ID for the window you're looking for
// ATitle: The title of the window you're looking for. Specify nil to search
for any name
// Result: Handle to the window or 0 if the window wasn't found.
function FindProcessWindow(const AProcess: DWord; const ATitle: PChar):
hWnd;
var
fpws: TFindProcessWindowStruct;
begin
fpws.Process := AProcess;
fpws.Title := ATitle;
fpws.Window := 0;
EnumWindows(fpwCallback, lParam(@fpws));
Result := fpws.Window;
end;

code by Rob Kennedy (rkennedy@cs.wisc.edu)
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Поиск окна
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]