You can accomplish this without using a TOpenDialog component. First, add FileCtrl to the Uses. Now the SelectDirectory function can be used. Drop a TButton component on your Form. Place the following code in the button's onClick event to get a demonstration of how this function works:

~~~~~
procedure TForm1.Button1Click(Sender: TObject) ;
const
     SELDIRHELP = 1000;
var
   dir: String;
begin
   dir := 'C:';
   if SelectDirectory(
        dir,
        [sdAllowCreate,
        sdPerformCreate,
        sdPrompt],
        SELDIRHELP
      ) then
     Button1.Caption := dir;
end;
~~~~~

Last modification:August 16th, 2009 at 12:30 pm
如果觉得我的文章对你有用,请随意赞赏