Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Modernizing Windows [tk_chooseDirectory] dialog

106 views
Skip to first unread message

jeff_g...@pobox.com

unread,
Apr 22, 2009, 1:13:55 PM4/22/09
to
What would it take to modernize the current Windows version of
[tk_chooseDirectory]? Specifically, I'd like to see the addition of a
"New Folder" button, which is standard in many implementations.

I know it's a native dialog, but there are definitely more modern
versions available than the one offered by Tk.

Also, I know it's possible to *type* a non-existent folder name into
the dialog and then, once returned, have the calling app create the
missing folder. Unfortunately, that just doesn't seem natural to many
Windows Users, and specifically, has proven confusing to some of my
end-Users.

So, what would it take to add a "-newfolderbutton" option to the
dialog?

Thanks,

Jeff

Jeff Hobbs

unread,
Apr 22, 2009, 4:00:43 PM4/22/09
to

Figure out how to enable the new style choose directory dialogs at the
C level?

Jeff

jeff_g...@pobox.com

unread,
Apr 22, 2009, 6:07:46 PM4/22/09
to

OK, attempting to figure it out...

Ahhh, here's an excerpt from the following MSDN article...

http://msdn.microsoft.com/en-us/library/bb762115(VS.85).aspx

"The newer style provides a number of additional features, including
drag-and-drop capability within the dialog box, reordering, deletion,
shortcut menus, the ability to create new folders, and other shortcut
menu commands. Initially, it is larger than the older dialog box, but
the user can resize it. To specify a dialog box using the newer style,
set the BIF_USENEWUI flag in the ulFlags member of the BROWSEINFO
structure."

So, looking at the TK sources, it would seem that changing the
following in tkWinDialog.c

bInfo.ulFlags = BIF_EDITBOX | BIF_STATUSTEXT |
BIF_RETURNFSANCESTORS
| BIF_VALIDATE;

to...

bInfo.ulFlags = BIF_EDITBOX | BIF_STATUSTEXT |
BIF_RETURNFSANCESTORS
| BIF_VALIDATE | BIF_USENEWUI

... might just do it? I haven't even attempted to build Tcl/Tk from
sources in quite a number of years, so the above is completely
untested.

Assuming the above properly activates the new style, is there a reason
we wouldn't want to do it? The obvious one would be an
incompatibility with older shell DLL installations, though I have no
idea what version is required or what would happen if it weren't
available on a target system, etc...

Thoughts?

Jeff


George Petasis

unread,
Apr 22, 2009, 6:24:57 PM4/22/09
to jeff_g...@pobox.com
O/H jeff_g...@pobox.com έγραψε:

> Assuming the above properly activates the new style, is there a reason
> we wouldn't want to do it? The obvious one would be an
> incompatibility with older shell DLL installations, though I have no
> idea what version is required or what would happen if it weren't
> available on a target system, etc...

I think that in older systems it will be simply ignored, as it is only a
flag...

George

Damon Courtney

unread,
Apr 22, 2009, 7:05:35 PM4/22/09
to


Adding that flag on Windows XP just crashes for me. According to the
MSDN docs, it's supported for 5.0 (Windows 2000) and up. Not sure why
it's crashing. *shrug*

D

Damon Courtney

unread,
Apr 22, 2009, 7:20:42 PM4/22/09
to
> Adding that flag on Windows XP just crashes for me.  According to the
> MSDN docs, it's supported for 5.0 (Windows 2000) and up.  Not sure why
> it's crashing. *shrug*
>
> D

Crash looks to be in Tk's validate callback. Could be we could fix
this up right quick. I'll investigate tonight and see if I can work
up a patch. This is something I've personally wanted for a VERY long
time in Tk.

D

jeff_g...@pobox.com

unread,
Apr 22, 2009, 7:33:01 PM4/22/09
to

Damon,

Thanks for taking a look. Keep us posted on your trials...

Jeff

Georgios Petasis

unread,
Apr 23, 2009, 6:44:32 AM4/23/09
to Damon Courtney
O/H Damon Courtney έγραψε:

Dear Damon,

Have you called OleInitialize(0) before the call?

George

Larry W. Virden

unread,
Apr 23, 2009, 7:08:11 AM4/23/09
to
On Apr 22, 6:07 pm, jeff_godf...@pobox.com wrote:
> I have no
> idea what version is required or what would happen if it weren't
> available on a target system, etc...
>

I would be careful setting bits on systems which don't support the
feature. Perhaps the best bet is to conditionally include the bit?

dkf

unread,
Apr 23, 2009, 8:56:33 AM4/23/09
to
On 23 Apr, 13:08, "Larry W. Virden" <lvir...@gmail.com> wrote:
> I would be careful setting bits on systems which don't support the
> feature. Perhaps the best bet is to conditionally include the bit?

We no longer support (in 8.6 at least) pre-2K Windows anyway.

Donal.

Jeff Hobbs

unread,
Apr 23, 2009, 2:37:14 PM4/23/09
to

That actually goes already for 8.5, so I think this can be updated for
8.5.next and 8.6.

Jeff

jeff_g...@pobox.com

unread,
Apr 23, 2009, 3:27:52 PM4/23/09
to

That sounds great Jeff. Does the above imply...

- That someone has already created a working patch (I know Damon was
working on one), or
- That it seems like the info in this thread should work as expected,
but someone still needs to submit a patch, or
- Something else entirely?

As an aside, where can I find some guidelines on building Tcl/Tk from
source on Windows? I have MS Visual Studio 2005 available.

Thanks,

Jeff

Jeff Hobbs

unread,
Apr 23, 2009, 4:50:35 PM4/23/09
to
On Apr 23, 12:27 pm, jeff_godf...@pobox.com wrote:
> That sounds great Jeff.  Does the above imply...
>
> - That someone has already created a working patch (I know Damon was
> working on one), or
> - That it seems like the info in this thread should work as expected,
> but someone still needs to submit a patch, or
> - Something else entirely?

I have a patch from Damon, but I am enhancing it for more future-
proofness. It will go into 8.5.8 and 8.6.

> As an aside, where can I find some guidelines on building Tcl/Tk from
> source on Windows?  I have MS Visual Studio 2005 available.

Then it should be just run nmake with the Makefile.vc. Build
instructions come with the sources.

Jeff

jeff_g...@pobox.com

unread,
Apr 23, 2009, 4:54:17 PM4/23/09
to
On Apr 23, 3:50 pm, Jeff Hobbs <jeff.ho...@gmail.com> wrote:
> On Apr 23, 12:27 pm, jeff_godf...@pobox.com wrote:
>
> > That sounds great Jeff.  Does the above imply...
>
> > - That someone has already created a working patch (I know Damon was
> > working on one), or
> > - That it seems like the info in this thread should work as expected,
> > but someone still needs to submit a patch, or
> > - Something else entirely?
>
> I have a patch from Damon, but I am enhancing it for more future-
> proofness.  It will go into 8.5.8 and 8.6.

Sweet. Thanks. And, thanks to Damon.

>
> > As an aside, where can I find some guidelines on building Tcl/Tk from
> > source on Windows?  I have MS Visual Studio 2005 available.
>
> Then it should be just run nmake with the Makefile.vc.  Build
> instructions come with the sources.

Well, I said I *have* it, not that I know how to use it... ;^)

I'd assume I can figure it out from the above - thanks.

Jeff

jeff_g...@pobox.com

unread,
Apr 23, 2009, 6:11:52 PM4/23/09
to

Well, that was pretty painless. I just built/installed 8.5.7 from the
sources. Now that I'm over that hurdle (which was much lower than I
expected - kudos to those involved), can I get my hands on this patch
(even if it's not yet production ready)?

Thanks,

Jeff

Jeff Hobbs

unread,
Apr 23, 2009, 6:30:56 PM4/23/09
to

ZuLuuuuuu

unread,
Apr 23, 2009, 7:04:44 PM4/23/09
to

1) Download MinGW:

https://sourceforge.net/project/showfiles.php?group_id=2435&package_id=240780&release_id=595197

2) Download MSYS:

https://sourceforge.net/project/showfiles.php?group_id=2435&package_id=24963

(Note: Select "MSYS-1.0.10.exe" from the near to the bottom of the
page for easy installation.)

3) Install MinGW and then MSYS.

4) Download "tcl857-src.zip" and "tk857-src.zip":

http://www.tcl.tk/software/tcltk/download.html

5) Unzip the zip packages into "C:\msys\1.0\home\YourUserName"

6) Open "C:\msys\1.0\msys.bat". You can use this terminal like the
terminals on Linux. So change directory to "tcl8.5.7/win". Then enter:

./configue
make
make install (Note: no need for su)

7) Change directory to "tk8.5.7/win". Then enter:

./configue
make
make install

8) Congratulations, Tcl and Tk is compiled and installed.

You can use prefixes when configuring so that the installation files
are placed into a folder you specify and so that you can easily move
the files to whereever you want and use Tcl from the default Command
Prompt instead of MSYS terminal.

jeff_g...@pobox.com

unread,
Apr 23, 2009, 7:12:53 PM4/23/09
to
> https://sourceforge.net/tracker/index.php?func=detail&aid=2779910&gro...

>
> It is already committed to 8.5 and 8.6 as well.
>
> Jeff

Thanks Jeff.

Downloaded, patched, rebuilt, and.... Beautiful! Nice work guys!

Wait, something seems a bit strange. When I click the "New Folder"
button, a folder named "New Folder" is created in the tree. That all
seems normal. But, say that's not really what I wanted. Typically,
you can select the newly created folder and just delete it from the
directory chooser dialog. Attempting this through the new Tk dialog,
I get

"Cannot delete New Folder: It is being used by another process or
program."

Looking at the folder using Unlocker, I see that it's tied up by the
wish process itself. As long as the "New Folder" node is selected,
it's tied up and can't be deleted, which makes it impossible to delete
from within the dialog itself.

Checking a few other implementations of the dialog, this appears to be
unique to Tk.

Thoughts?

Thanks,

Jeff

jeff_g...@pobox.com

unread,
Apr 23, 2009, 11:25:55 PM4/23/09
to

In case it's helpful, something I've noticed... If instead of
attempting to delete the original "New Folder" node in the tree, I
first rename the folder to anything else (via F2), it can then be
successfully deleted.

Jeff

George Petasis

unread,
Apr 24, 2009, 11:57:25 AM4/24/09
to Jeff Hobbs
O/H Jeff Hobbs έγραψε:

It seems I am the only one whose tk build system fails? :D

I get a (parse from nmake) error in the tk's makefile.vc, where the
SYMBOLS variable is used (its only in two places). I have to comment
them (along with the check to source vcvars32.bat) to get it to work.
The tcl makefile.vc (which has the same exact code in it) worked without
a problem. Also, a compiler flag seems to give some warnings in tk.
All these under VC++ 9.0...

George

Jeff Hobbs

unread,
Apr 24, 2009, 12:08:57 PM4/24/09
to

This may have to do with how we Get/Set the cwd inside the choosedir
validation proc (see tkWinDialog.c:ChooseDirectoryValidateProc). I
don't see why that BFFM_SELCHANGED needs the SetCurrentDirectory
anymore. Prior to SHBrowseForFolder, more magic was necessary. Try
to comment out that line (1984 of 8.5.head) and see if everything
still works as expected, plus fixes the above.

Jeff

jeff_g...@pobox.com

unread,
Apr 24, 2009, 12:31:21 PM4/24/09
to

Jeff,

Line 1984 doesn't quite coincide with my source file (8.5.7), but I
assume you're referring to the final line below.

if (SHGetPathFromIDList((LPITEMIDLIST) lParam, selDir)) {
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) selDir);
// enable the OK button
SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
//SetCurrentDirectory(selDir);

If that's correct, then "Yes", commenting it out does seem to correct
the issue I mentioned above, and all else still seems to function as
expected. That said, I haven't exhaustively exercised the various
options...

Thanks,

Jeff

jeff_g...@pobox.com

unread,
May 1, 2009, 9:52:30 AM5/1/09
to

Jeff H,

Did the above minor modification ever get committed? I don't see any
update to the originally committed patch. Since I'd really like to
see this in an ActiveTcl release, I just want to make sure the above
wasn't missed.

Thanks,

Jeff

Jeff Hobbs

unread,
May 1, 2009, 11:35:27 AM5/1/09
to
On May 1, 6:52 am, jeff_godf...@pobox.com wrote:

> On Apr 24, 11:31 am, jeff_godf...@pobox.com wrote:
> > Line 1984 doesn't quite coincide with my source file (8.5.7), but I
> > assume you're referring to the final line below.
>
> >         if (SHGetPathFromIDList((LPITEMIDLIST) lParam, selDir)) {
> >             SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) selDir);
> >             // enable the OK button
> >             SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
> >             //SetCurrentDirectory(selDir);
>
> > If that's correct, then "Yes", commenting it out does seem to correct
> > the issue I mentioned above, and all else still seems to function as
> > expected.  That said, I haven't exhaustively exercised the various
> > options...

> Did the above minor modification ever get committed?  I don't see any


> update to the originally committed patch.  Since I'd really like to
> see this in an ActiveTcl release, I just want to make sure the above
> wasn't missed.

Yes, it was committed to all branches.

Jeff

jeff_g...@pobox.com

unread,
May 1, 2009, 1:58:50 PM5/1/09
to


Thanks Jeff.

0 new messages