delphi中最小化其他程序及所有程序窗口最小化


本文整理自网络,侵删。

 
1.所有程序最小化


uses ComObj;

var
   shell : OleVariant;
begin
   shell := CreateOleObject('Shell.Application');
  shell.minimizeAll;
end;
2.最小化其他程序
 spy++ 查找要最小化的程序classname
var  
  Indicador :Integer;
begin 
  // Find the window by Classname
  Indicador := FindWindow(PChar('notepad'), nil);
  // if finded
  if (Indicador <> 0) then begin
    // Minimize
    ShowWindow(Indicador,SW_MINIMIZE);
  end;
end;

3.根据程序标题最小化程序
  
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 hideExWindow()
var Indicador:Hwnd;
begin
    // Find the window by Classname
    Indicador := FindWindowByTitle('MyApp'); 
    // if finded
    if (Indicador <> 0) then
    begin
        // Minimize
        ShowWindow(Indicador,SW_HIDE); //SW_MINIMIZE
    end;
end;

相关阅读 >>

Delphi 字符串处理单元

Delphi 操作键盘按下和释放操作

Delphi firedac fdconnection 事务

Delphi的组件选项卡(component palette)

Delphi 判断进程名是否存在,如果存在则结束进程

Delphi 获取webbrowser中的图片

Delphi tgauge类的定义在哪个单元中定义的?

Delphi fdquery获取字段类型

Delphi 10.3 控件遮挡 webbrowser

Delphi exec error 错误处理

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...