| Код | { FindWindowByTitle returns the handle of a window that contains a certain "WindowTitle".
Function is Case SENSITIVE. }
function FindWindowByTitle(WindowTitle: string): Hwnd; var NextHandle: Hwnd; NextTitle: array[0..260] of char; begin // Get the first window NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST); while NextHandle > 0 do begin // retrieve its text GetWindowText(NextHandle, NextTitle, 255); if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then begin Result := NextHandle; Exit; end else // Get the next window NextHandle := GetWindow(NextHandle, GW_HWNDNEXT); end; Result := 0; end;
procedure TForm1.FormCreate(Sender: TObject); var target : HWND; begin target := FindWindowByTitle('Notepad'); ShowWindow(target, SW_SHOW); end;
|
|