Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to center a TOpenDialog on a form Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
20-Oct-02
Category
Dialogs
Language
Delphi 2.x
Views
85
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to center a TOpenDialog on a form

Answer:

1   { ... }
2   type
3     TForm1 = class(TForm)
4       Button1: TButton;
5       OpenDialog1: TOpenDialog;
6       procedure Button1Click(Sender: TObject);
7       procedure OpenDialog1Show(Sender: TObject);
8     private
9       { Private declarations }
10      procedure MoveDialog(var Msg: TMessage); message WM_USER;
11    public
12      { Public declarations }
13    end;
14  
15  var
16    Form1: TForm1;
17  
18  implementation
19  
20  {$R *.DFM}
21  
22  procedure TForm1.Button1Click(Sender: TObject);
23  begin
24    OpenDialog1.Execute;
25  end;
26  
27  procedure TForm1.OpenDialog1Show(Sender: TObject);
28  begin
29    PostMessage(Self.Handle, WM_USER, 0, 0);
30  end;
31  
32  procedure TForm1.MoveDialog(var Msg: TMessage);
33  var
34    rec: TRect;
35    wh: HWND;
36    l, t, r, b: Integer;
37  begin
38    if ofOldStyleDialog in OpenDialog1.Options then
39      wh := OpenDialog1.Handle
40    else
41      wh := Windows.GetParent(OpenDialog1.Handle);
42    if IsWindow(wh) then
43      if GetWindowRect(wh, rec) then
44      begin
45        l := (Width - (rec.Right - rec.Left)) div 2 + Left;
46        t := (Height - (rec.Bottom - rec.Top)) div 2 + Top;
47        r := rec.Right - rec.Left;
48        b := rec.Bottom - rec.Top;
49        MoveWindow(wh, l, t, r, b, True);
50      end;
51  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC