Forms Delphi

Title: Move window of winexec program
Question: Developed this routine to center the calculator to the middle of the screen, instead of the upper left
Answer:
procedure ExecuteAndMoveWindow(programexename : string; windowname : string);
var
TheWindow : HWND;
lpRect : TRect;
NewX, NewY : integer;
begin
winexec(programexename, SW_Hide);
TheWindow := FindWindow(nil,windowname);
NewX := Form1.Left + (Form1.Width - Screen.Width div 2);
NewY := Form1.Top + (Form1.Height - Screen.Height div 2);
GetWindowRect(TheWindow, lpRect);
MoveWindow(TheWindow, NewX, NewY, lpRect.right - lpRect.left, lpRect.bottom - lpRect.top, True);
ShowWindow(TheWindow, SW_Normal);
end;
for windows calculator:
ExecuteAndMoveWindow('calc', 'Calculator');