delphiwindowminimize

Minimize an external application with Delphi


Is there a way to Minimize an external application that I don't have control over from with-in my Delphi application?

for example notepad.exe, except the application I want to minimize will only ever have one instance.


Solution

  • You can use FindWindow to find the application handle and ShowWindow to minimize it.

    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;