如何实现目录对话框。急!

candy_wang 2004-08-11 07:25:20
我要实现在窗口A中点击一个按钮,就可以打开目录对话框,选择相应目录后,回到原窗口
A,原窗口A的edit中可以获取相应的路径。试过使用文件对话框,但是选择的是文件,用directorylistbox建立另一个窗口,又会存在窗口A调用窗口B,然后窗口B调用窗口A,系统报错。可以怎么实现这个目录选择对话框?各位帮帮忙,给源码亚
...全文
116 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuojohn 2004-08-11
  • 打赏
  • 举报
回复
please choose...

Project ----> Import Type Library--->Microsoft Shell Controls and Automations(version 1.0)---> click 'Install' button to install TShell


Example1

1. Drop TButton componet to Form1
2. Drop TShell component from 'ActiveX' table to Form1
3. --------------------------------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, shlobj, Shell32_TLB;

type
TForm1 = class(TForm)
Shell1: TShell;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Shell1.BrowseForFolder(self.Handle, 'Choose directory to search', BIF_EDITBOX, ssfDESKTOP);
end;

end.

jacky_shen 2004-08-11
  • 打赏
  • 举报
回复
uses
FileCtrl;

procedure TForm1.Button1Click(Sender: TObject);
var
Directory: string;
begin
if SelectDirectory('选择目录', '', Directory) then
Edit1.Text := Directory;
end;

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧