Update Window Position And Size - Delphi

DarkCoderSc
Jean-Pierre LESUEUR
var ATargetWindow := FindWindow(nil, 'Untitled - Notepad');
if ATargetWindow = 0 then
Exit();
var ANewRect : TRect; // Or := Rect(..,..,..,..)
ANewRect.Left := 10;
ANewRect.Top := 10;
ANewRect.Width := 400;
ANewRect.Height := 200;
// Just Move Window
SetWindowPos(ATargetWindow, 0, ANewRect.Left, ANewRect.Top, 0, 0, SWP_NOZORDER or SWP_NOSIZE);
// Just Resize Window
SetWindowPos(ATargetWindow, 0, 0, 0, ANewRect.Width, ANewRect.Height, SWP_NOZORDER or SWP_NOMOVE);
// Both
SetWindowPos(ATargetWindow, 0, ANewRect.Left, ANewRect.Top, ANewRect.Width, ANewRect.Height, SWP_NOZORDER);
Creating and researching code snippets takes time and effort. You’re welcome to share them through your own platforms, but please don’t forget to credit the original author, here: Jean-Pierre LESUEUR.
Implemented By Technique
Featured Windows API
Created
April 24, 2025
Last Revised
April 24, 2025