BrowseFolderDialog - how to allow creating new directories?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

BrowseFolderDialog - how to allow creating new directories?

Frank Sergeant
I would like to present the user with a dialog for selecting a directory
wherein the user has the ability to create a new directory and to navigate
upward from the starting directory.  The obvious first choice is a
BrowseFolderDialog but it doesn't seem to allow creating a new directory nor
navigating upward from the starting directory.  FileOpenDialog does allow
those two items, but, of course, does not allow the selection of a
directory.

Any suggestions as to how to add folder creation and/or upward navigation to
BrowseFolderDialog or any thoughts about alternative approaches?


-- Frank


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Louis Sumberg-2
Frank,

> Any suggestions as to how to add folder creation and/or upward navigation
to
> BrowseFolderDialog or any thoughts about alternative approaches?

Taking a quick look at MSDN (Look up BROWSEINFO), the following should work
on Win2000 and up -- I can't test it because I've got Win98 :(

dlg := BrowseFolderDialog  new.
dlg winStruct title: 'Hello'.
dlg winStruct uFlags: dlg winStruct defaultStyle | 16r0040
"BIF_NEWDIALOGSTYLE".
dlg showModal

It you try it, let us know if it works.

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Costas
In reply to this post by Frank Sergeant
try

FileOpenDialog  show.

costas

On Fri, 19 Jul 2002 12:08:00 -0600, "Frank Sergeant"
<[hidden email]> wrote:

>I would like to present the user with a dialog for selecting a directory
>wherein the user has the ability to create a new directory and to navigate
>upward from the starting directory.  The obvious first choice is a
>BrowseFolderDialog but it doesn't seem to allow creating a new directory nor
>navigating upward from the starting directory.  FileOpenDialog does allow
>those two items, but, of course, does not allow the selection of a
>directory.
>
>Any suggestions as to how to add folder creation and/or upward navigation to
>BrowseFolderDialog or any thoughts about alternative approaches?
>
>
>-- Frank
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Costas
Sorry I meant:

 FileOpenDialog showModal.


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Andy Bower
In reply to this post by Frank Sergeant
Frank,

> I would like to present the user with a dialog for selecting a directory
> wherein the user has the ability to create a new directory and to navigate
> upward from the starting directory.  The obvious first choice is a
> BrowseFolderDialog but it doesn't seem to allow creating a new directory
nor
> navigating upward from the starting directory.  FileOpenDialog does allow
> those two items, but, of course, does not allow the selection of a
> directory.
>
> Any suggestions as to how to add folder creation and/or upward navigation
to
> BrowseFolderDialog or any thoughts about alternative approaches?

Okay. The general solution for this sort of thing (i.e. when you suspect
that a Windows facility is available but Dolphin doesn't yet support it) is
to consult MSDN online. Take a look at this page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
tform/Shell/reference/structures/browseinfo.asp

First of all to set the starting directory you just need to set the model of
the BrowseFolderDialog. Try:

bfd := BrowseFolderDialog new.
bfd value: 'C:\'.
bfd showModal "Display it"

The next task is to allow creation of directories. Providing you are
intending to run on a system that has a common controls library of 5.0 or
later then you can do what you want. It appears that the older style dialog
doesn't have a folder creation button but the new style one does. Add
BIF_NEWDIALOGSTYLE to Win32Constants with a value of 64 (decimal). Now add
this bit into the style:

bfd := BrowseFolderDialog new.
bfd value: 'C:\'.
bfd style: (bfd style | BIF_NEWDIALOGSTYLE).

You will have to add Win32Constants as a pool of the workspace you are
using. Don't show the dialog yet otherwise you will get an error and you may
crash your image. The new style dialog, it seems, sends an additional
callback message to the dialog which the Dolphin class is not set up to
handle. Add BFFM_IUNKNOWN=5  to ShellConstants and then file in the
following methods:

!BrowseFolderDialog class methodsFor!
initialize
    "Private - Initialize the receiver's class variables.
        self initialize
    "
    Handlers := Array new: 5.
    Handlers
        at: BFFM_INITIALIZED put: #initialized:lParam:;
        at: BFFM_SELCHANGED put: #selChanged:lParam:;
        at: BFFM_VALIDATEFAILEDA put: #validateFailed:lParam:;
        at: BFFM_IUNKNOWN put: #iunknown:lParam:.

        InitializedMask := 16r1.! !
!BrowseFolderDialog class categoriesFor: #initialize!initializing!private! !

!BrowseFolderDialog methodsFor!
iunknown: hWnd lParam: lParam
    "Private - Handler for BFFM_IUNKNOWN message sent through callback.
    lParam is the IUnknown*interface."
! !
!BrowseFolderDialog categoriesFor: #iunknown:lParam:!event handling!private!
!

Execute the class initiialize method to set up the new callback map. Now you
can call #showModal to display the new style dialog with the create folder
button. We'll add this modification for the next patch release.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com
---
Are you trying too hard?
http://www.object-arts.com/Relax.htm
---




bfd showModal "Display it"


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Frank Sergeant
"Andy Bower" <[hidden email]> wrote in message
news:ahbshf$rneao$[hidden email]...
> Okay. The general solution for this sort of thing (i.e. when you suspect
> that a Windows facility is available but Dolphin doesn't yet support it)
is
> to consult MSDN online. Take a look at this page:
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
> tform/Shell/reference/structures/browseinfo.asp

Ok.  I did find that page after Louis's suggestion to search for BROWSEINFO.
I was glad he and you supplied the value of the BIF_NEWDIALOGSTYLE flag.  I
tried searching on msdn to see if I could find where you had found its
value.  I wasn't able to find it.  The closest I came was the hint that it
was defined in the header file shlobj.h but I wasn't able to locate that
header file on msdn.  (I have an old MSDN subscription and an old MSVC++.
Perhaps I could have installed those and located the header file there.)

Oh, I forgot to mention in my first post that I'm running version 5.01
Professional on a W2K Professional machine (but the target computers will
include W95, W98, etc.).

> First of all to set the starting directory you just need to set the model
of
> the BrowseFolderDialog. Try:
>
> bfd := BrowseFolderDialog new.
> bfd value: 'C:\'.
> bfd showModal "Display it"

Thanks.  I see the difference now.  I had been using
  bfd root: 'C:\xxx\yyy\'  rather than
  bfd value: 'C:\xxx\yyy\'.

> The next task is to allow creation of directories. Providing you are
> intending to run on a system that has a common controls library of 5.0 or
> later then you can do what you want.

Well, I'll plan on requiring 5.0 as of now.  If clients have trouble running
it, I guess I'll suggest upgrading to a later version of IE.  Is that still
the recommended general approach?

Thanks for the further details.  I added the 2 new constants, changed the
class #initialize method, and added the #iunknown... method.  It all works
GREAT on my W2K machine.  That's just what I needed.  I'll probably get to
try it on an older W95 machine later this weekend.

Here is my application method in case it helps anyone else:

chooseJobDirectory

"Pop up a folder picker so user can specify the directory to be used for
this job."

    | dlg dir |

    dlg := BrowseFolderDialog new.

    dlg    caption: 'Choose Job Directory ';

            style: (dlg style | BIF_NEWDIALOGSTYLE);

            value: SessionManager current installationDirectory.

    dir := dlg showModal.

    jobDir value: dir "may be nil"


-- Frank


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Frank Sergeant
In reply to this post by Costas
"Costas" <[hidden email]> wrote in message
news:[hidden email]...
> try
>
> FileOpenDialog  show.

Thanks for the suggestion.  (I did try it, as I mentioned, but as far as I
could tell, the user must select a file rather than a directory).


-- Frank


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Frank Sergeant
In reply to this post by Louis Sumberg-2
"Louis Sumberg" <[hidden email]> wrote in message
news:3d38c64f@tobjects....

> Taking a quick look at MSDN (Look up BROWSEINFO), the following should
work
> on Win2000 and up -- I can't test it because I've got Win98 :(

> dlg := BrowseFolderDialog  new.
> dlg winStruct title: 'Hello'.
> dlg winStruct uFlags: dlg winStruct defaultStyle | 16r0040
> "BIF_NEWDIALOGSTYLE".
> dlg showModal

Thanks.  After changing a few things such as 'uFlags:' to 'ulFlags:' and
'dlg winStruct defaultStyle' to 'dlg defaultStyle' it ran but essentially
the same as before (that is, new directories could not be created).  Maybe
it was the added callback method (see Andy's message) that makes the
difference there.  After making Andy's changes everything worked fine on my
W2K machine and I gathered from his message that it should work on your W98
machine also (providing you have the version 5 common controls).

Thanks for the search tip.  Where did you find the value for the
BIF_NEWDIALOGSTYLE flag?  Did you find a header file on MSDN on the web or
had you installed the header files on your machine or ... ?


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Louis Sumberg-2
Frank,

> ...it was the added callback method (see Andy's message) that makes the
> difference there.  After making Andy's changes everything worked fine on
my
> W2K machine and I gathered from his message that it should work on your
W98
> machine also (providing you have the version 5 common controls).

I'm glad Andy provided the correct answer to your question *s*.  The bad
news is that I'm pretty sure it won't work on Win95/98.  Even if your
Win95/98 target machines have the new IE installed, I believe the common
controls (Shell32.dll in particular) are upgraded to 4.71 (or 4.72 or
thereabouts), not 5.0.

> Thanks for the search tip.  Where did you find the value for the
> BIF_NEWDIALOGSTYLE flag?  Did you find a header file on MSDN on the web or
> had you installed the header files on your machine or ... ?

I used Google to search for BIF_NEWDIALOGSTYLE and skipped the Microsoft
pages.  Usually there'll be someone who's posted some code with the constant
definitions included.  MSDN seems to be useless for this, never mentioning
the constants' values.  For "older" constants I use a tool from a copy of VB
that I have.

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: BrowseFolderDialog - how to allow creating new directories?

Frank Sergeant
"Louis Sumberg" <[hidden email]> wrote in message
news:3d39f554$1@tobjects....

> The bad news is that I'm pretty sure it won't work on Win95/98.  Even if
your
> Win95/98 target machines have the new IE installed, I believe the common
> controls (Shell32.dll in particular) are upgraded to 4.71 (or 4.72 or
> thereabouts), not 5.0.

Thanks for the warning.  I finally got the folder dialog tested on a W95
machine and, indeed, the new style does not work there (does not have a
create folder button), even though it has IE version 5.5.

> > Thanks for the search tip.  Where did you find the value for the
> I used Google to search for BIF_NEWDIALOGSTYLE and skipped the Microsoft
> pages.  Usually there'll be someone who's posted some code with the
constant

Ah, thanks.


-- Frank