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 remove the 'Create new folder' button of a TOpenDialog 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
21-Oct-02
Category
Dialogs
Language
Delphi 2.x
Views
153
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to remove the 'Create new folder' button of a TOpenDialog

Answer:

Here is how you can remove the 'Create new folder' button on a TOpenDialog. Look at 
the lines at the bottom this procedure. But note that although the button is no 
longer present, it's still possible to create a new folder in the dialog, as well 
as all other kinds of file/ directory manipulation.

1   { ... }
2   type
3     TForm1 = class(TForm)
4       OpenDialog1: TOpenDialog;
5     private
6       { Private declarations }
7       procedure MoveDialog(var Msg: TMessage); message WM_USER;
8     public
9       { Public declarations }
10    end;
11  
12  var
13    Form1: TForm1;
14  
15  implementation
16  
17  {$R *.DFM}
18  
19  procedure TForm1.MoveDialog(var Msg: TMessage);
20  var
21    rec: TRect;
22    wh: HWND;
23    l, t, r, b: Integer;
24  begin
25    {Center OpenDialog over form}
26    if ofOldStyleDialog in OpenDialog1.Options then
27      wh := OpenDialog1.Handle
28    else
29      wh := Windows.GetParent(OpenDialog1.Handle);
30    if IsWindow(wh) then
31      if GetWindowRect(wh, rec) then
32      begin
33        l := (Width - (rec.Right - rec.Left)) div 2 + Left;
34        t := (Height - (rec.Bottom - rec.Top)) div 2 + Top;
35        r := rec.Right - rec.Left;
36        b := rec.Bottom - rec.Top;
37        MoveWindow(wh, l, t, r, b, True);
38      end;
39    if not (ofOldStyleDialog in OpenDialog1.Options) then
40    begin
41      {Remove the 'Create new folder' toolbutton}
42      wh := Windows.GetParent(OpenDialog1.Handle);
43      wh := FindWindowEx(wh, 0, 'ToolbarWindow32', nil);
44      if wh <> 0 then
45        SendMessage(wh, TB_DELETEBUTTON, 5, 0); {uses Commctrl}
46      {Warning: 5 is the ID-number of the 'Create new folder' toolbutton. 
47  		It may possibly change on different Windows versions.}
48    end;
49  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