Re: TOpenDialog position

Giganews Newsgroups
Subject: Re: TOpenDialog position
Posted by:  David (david.mark…
Date: Sun, 25 Feb 2007

>>Which version of Delphi are you using?<<
D7, but what I forgot to mention was that the application was running under
Vista (the only dual monitor setup I had), following your comments I tried
it on XP with the same monitor set up and the dialogs are shown on the
correct monitor.

>> In Delphi 6+, the dialog is centered in whichever monitor has the TForm
specified in the
Screen.ActiveForm property, falling back to the MainForm if no ActiveForm is
In my tests the whole application is running on a second monitor, all my
forms are centred on the MainForm correctly but the TOpenDialog and
TSaveDialog always default to the primary monitor under Vista.

However, if I open a TOpenDialog, reposition it to be on the correct monitor
then open a TSaveDialog the TSaveDialog is shown in the same place as the
TOpenDialog was, so they seem to have a common set of positions.

>>Use the OnShow event to move the dialog's HWND manually via
Unfortunately that seems a big too early in the creation process, any
repositioning in OnShow is ignored.
I ended up adding a one shot TTimer to the calling form and reseting the
position Timer.interval after OnShow is fired.

procedure TPackageViewer_Win.DlgTimerTimer(Sender: TObject);
  with sender as TTimer do
    case tag of
      OpenDlgID: CentreDialog(OpenDialog1.Title,self);
      SaveDlgID: CentreDialog(SaveDialog1.Title,self);

procedure TPackageViewer_Win.OpenDialog1Show(Sender: TObject);



In response to

Re: TOpenDialog position posted by Remy Lebeau (TeamB) on Sat, 24 Feb 2007