[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

dialogbox position

I use the standard dialogboxes to open files, save files, ...

Is it possible to change the position where the dialogboxes will become visible?  I want that they become visible in the middle of my application windows.  At this moment they become visible at the position where they last closed.

Thanks.
0
ka1a
Asked:
ka1a
1 Solution
 
CalvinDayCommented:
Put this in on the OnShow event.

procedure TForm1.OpenDialog1Show(Sender: TObject);
var
  Rect: TRect;
  Wnd: THandle;
begin
  Wnd:=GetParent(OpenDialog1.Handle);
  GetWindowRect(Wnd, Rect);
  SetWindowPos(Wnd, 0, (Screen.Width - Rect.Right + Rect.Left) div 2,
    (Screen.Height - Rect.Bottom + Rect.Top) div 2,
    0, 0, SWP_NOACTIVATE or SWP_NOSIZE or SWP_NOZORDER);
end;
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now