Link to home
Start Free TrialLog in
Avatar of jeurk
jeurk

asked on

shbrowseforfolder in my folder

Hi,
Herre follows my function that let's me
browse for a folder on the disk.
My problem is that I want to start the
browsing in a specified directory.
How can I add that ?
I don't want to browse ONLY starting
from that dir. I want to browse the whole
computer, but when the dialog opens I
want my folder to be already selected.
Working code would be nice.
Stay simple, I have the rxlib that comes
with a nice component that does all the
stuff. But it is doing too much. Maybe
we can do it by only adding one or two lines.

I know that we have to send a message
to the dialog with
procedure TBrowseFolderDlg.SetSelPath(const Path: string);
begin
  if FHandle <> 0 then
    SendMessage(FHandle, BFFM_SETSELECTION, 1, Longint(PChar(Path)));
end;

But I don't know where to call it.
If you know how to do add the following
things :
-start browse with my dir selected
-enable the ok button only if a dir is
selected.

Thanks in advance.



-------------------------------
procedure TSelectFolder.Execute;
var
  pMAlloc: IMalloc;
begin
  wBrowseInfo.hwndOwner := TCustomForm(GetOwner).Handle;
  wBrowseInfo.pidlRoot := nil;
  wBrowseInfo.pszDisplayName := wPath;
  wBrowseInfo.lpszTitle := PChar('Tri2 Tool');
  wBrowseInfo.ulFlags := 0;
  wBrowseInfo.lpfn := nil;
  wBrowseInfo.lParam := 0;
  wBrowseInfo.iImage := 0;

  try
    CoGetMalloc(MEMCTX_TASK, pMAlloc);
    GetMem(wPath, MAX_PATH);

    wItemIDList := SHBrowseForFolder(wBrowseInfo);

    if wItemIDList <> nil then
      if SHGetPathFromIDList(wItemIDList, wPath) then
        FPath := wPath
      else
        FPath := ''
    else
      FPath := '';
  finally
    FreeMem(wPath);
    pMalloc._Release;
  end; // try
end;
ASKER CERTIFIED SOLUTION
Avatar of Lischke
Lischke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of inthe
inthe

well its possible see this comp (wrapper around shbrowse.. with source):

http://www.delphifreestuff.com/cgi-bin/dfs_components.cgi?browsedr

might help some..
whoops a bit slow :-)
Avatar of jeurk

ASKER

Hi,
works fine, just what I wanted. thanks.

inthe : I was aware of that componant
thanks. But i just wanted to add the
minimum code to do my stuff, thanks
anyway...

regards.
Avatar of jeurk

ASKER

Inthe : happens everyday ;)
I missed some 1000 yesterday ;)
:-)))
yep i noticed :-)
dont worry it happens to us all