Delphi でFormを MainForm 以外の中央に表示
Delphi でFormを MainForm 以外の中央に表示
親になるフォーム位置、サイズを GetWindowRect で取得して中央を計算する
procedure MoveFormCenter(AForm, AParentForm: TForm);
var
Rect: TRect;
begin
GetWindowRect(AParentForm.Handle, Rect);
AForm.Top := Rect.Top + (Rect.Bottom - Rect.Top - AForm.Height) div 2;
AForm.Left := Rect.Left + (Rect.Right - Rect.Left - AForm.Width) div 2;
end;
(MessageDlg をフォームの中央に表示はこちら)
コメント