//通过程序标题查到程序句柄
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;
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步