//通过程序标题查到程序句柄
function TfmPrintSet2.FindWindowByTitle(WindowTitle: string): Hwnd;
var
NextHandle: Hwnd;
NextTitle: array[0..260] of char;
begin
// 获取第一个
NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
while NextHandle > 0 do
begin
// 获取标题
GetWindowText(NextHandle, NextTitle, 255);
if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
begin
Result := NextHandle;
Exit;
end
else
// 获取下一个
NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
end;
Result := 0;
end;

//最大化窗体
procedure TfmPrintSet2.MaxExWindow(TitleName: string);
var
Indicador: Hwnd;
begin
// 获取window通过程序标题名字
Indicador := FindWindowByTitle(TitleName);
// if finded
if (Indicador <> 0) then
begin
// Minimize
ShowWindow(Indicador, SW_MINIMIZE);
ShowWindow(Indicador, SW_MAXIMIZE); //SW_MINIMIZE
end;
end;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案