Tk Source Code

View Ticket
Login
Ticket UUID: 4939f815b9ae1c4b76fd102d0ab48fb194ab45c9
Title: Problem (bug?) with tk_chooseDirectory in 8.5.13 and 8.6.0
Type: Bug Version: 8.6.0
Submitter: anonymous Created on: 2013-07-09 15:34:06
Subsystem: 36. [tk_chooseDirectory] Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Cosmetic
Status: Closed Last Modified: 2026-10-22 17:22:36
Resolution: Fixed Closed By: serhiy.storchaka
    Closed on: 2026-09-25 08:14:41
Description:
In tk 8.5.7, when given an initial directory name, tk_chooseDirectory will locate the directory on the GUI. And when selecting the directory, the directory full path will be shown on the top of the dialog box.  For 8.5.13 and 8.6.0, all these are gone.

I was able to copy the source code of 8.5.7 into 8.5.13 and restore the behavior. But not anymore  in 8.6.0.

Is there any way I can get these nice feature back ?
User Comments: serhiy.storchaka added on 2026-09-25 08:14:41:

Fixed in 8.6.3 by [92b2061e1b]: on Vista and later tk_chooseDirectory uses the IFileDialog folder picker, which opens at -initialdir and shows the full path. Checked on Windows 11 with 8.6.18 and 9.1. Closing.


jan.nijtmans added on 2013-07-12 11:03:46:

So, you are saying that after this line:

http://core.tcl.tk/tk/artifact/f40e3ce7d8?ln=1681

should be added something like:

SendMessageW(hwnd, TVM_ENSUREVISIBLE, 0, (LPARAM) ???);

Any idea how to get the "handle to the item" (LPARAM) ???

The workaround you mention, using ::tk::winChooseDirFlags still appears to work, that should fix the second "defect" you mention.

Thanks!


anonymous (claiming to be Colin McDonald) added on 2013-07-11 23:22:15:
This change dates back to checkin 400e342b2a on 2009-04-23.  The new style choosedir dialog was enabled, which according to Microsoft "provides the user with a larger dialog box that can be resized. The dialog box has several new capabilities, including: drag-and-drop capability within the dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands".

There is an undocumented magic Tcl variable which can be used to give the old style dialog.

set ::tk::winChooseDirFlags 0x3C

The flag values are given in MSDN at:

http://msdn.microsoft.com/en-us/library/bb773205%28VS.85%29.aspx

See the ulFlags description.  By default Tk now sets the BIF_NEWDIALOGSTYLE bit (0x00000040): setting 0x3C omits it and gives the old style.

The failure to scroll to the given initial directory with BIF_NEWDIALOGSTYLE on Windows 7 appears to be a Windows bug.  See "BFFM_SETSELECTION does not work with SHBrowseForFolder on Windows 7" at:

http://connect.microsoft.com/VisualStudio/feedback/details/518103/bffm-setselection-does-not-work-with-shbrowseforfolder-on-windows-7

plus other similar reports.  There is a suggested work-around there, sending a TVM_ENSUREVISIBLE to the directory tree.

jan.nijtmans added on 2013-07-10 15:14:54:

Please attach a screen-shot how it should look like. Where is "on the top of the dialog box" located? Thanks!

A bisect on "trunk" would help too, in order to find out which of the following 3 bug-fixes caused the regressions:

[3500545]: tk_getOpenFile -multiple 1 wrong on windows.
[3416492]: Crash in open/save file dialog in Windows 7 libraries.
[3095112]: crash when selecting file from Win7 Library.


Attachments: