Einzelnen Beitrag anzeigen

HolgerX

Registriert seit: 10. Apr 2006
Ort: Leverkusen
961 Beiträge
 
Delphi 6 Professional
 
#6

AW: Anderes Programm verschieben und vergrößern

  Alt 4. Mai 2018, 13:45
Hmm...


Delphi-Quellcode:
function MoveNotepad(const Left, Top, Width, Height: Integer): Boolean;
var
  FindWindowRec: TFindWindowRec;
begin
  FindWindowRec.ModuleToFind := 'c:\windows\system32\notepad.exe';
  FindWindowRec.FoundHWnd := 0;
  EnumWindows(@EnumWindowsCallback, integer(@FindWindowRec));
  Result := FindWindowRec.FoundHWnd <> 0;

  if Result then
    SetWindowPos(FindWindowRec.FoundHWnd, 0, Left, Top, Width, Height, 0);
end;

Oder auch (etwas) Kürzer

Delphi-Quellcode:
function MoveNotepad(const Left, Top, Width, Height: Integer): Boolean;
var
  hWindow: HWND;
begin
  hWindow := FindWindow('notepad',nil);
  if hWindow > 0 then
    SetWindowPos(hWindow, 0, Left, Top, Width, Height, 0);
end;
  Mit Zitat antworten Zitat