Tk Source Code

Artifact [8db10047]
Login

Artifact 8db10047b58052284db7a744312e482f4765e279:

Attachment "uni-choosedir-1913750-8.6b1.2.patch" to ticket [1913750f] added by bitwalk 2010-08-13 13:24:17.
--- tkWinDialog.c	2010-05-18 15:01:26.000000000 +0900
+++ tkWinDialog.c.new	2010-08-13 14:43:15.758325585 +0900
@@ -1902,6 +1902,7 @@
     TCHAR saveDir[MAX_PATH];
     Tcl_DString titleString;	/* UTF Title */
     Tcl_DString initDirString;	/* Initial directory */
+    Tcl_Encoding unicodeEncoding = TkWinGetUnicodeEncoding();
     Tcl_Obj *objPtr;
     static const char *const optionStrings[] = {
 	"-initialdir", "-mustexist",  "-parent",  "-title", NULL
@@ -2048,13 +2049,13 @@
 	 */
 
 	if (pidl != NULL) {
-	    if (!SHGetPathFromIDList(pidl, path)) {
+	    if (!SHGetPathFromIDListW(pidl, path)) {
 		Tcl_SetResult(interp, "Error: Not a file system folder\n",
 			TCL_VOLATILE);
 	    };
 	    pMalloc->lpVtbl->Free(pMalloc, (void *) pidl);
-	} else if (lstrlen(cdCBData.utfRetDir) > 0) {
-	    lstrcpy(path, cdCBData.utfRetDir);
+	} else if (lstrlenW(cdCBData.utfRetDir) > 0) {
+	    lstrcpyW(path, cdCBData.utfRetDir);
 	}
 	pMalloc->lpVtbl->Release(pMalloc);
     }
@@ -2078,7 +2079,7 @@
     if (*path) {
 	Tcl_DString ds;
 
-	Tcl_AppendResult(interp, ConvertExternalFilename(NULL, (char *) path,
+	Tcl_AppendResult(interp, ConvertExternalFilename(unicodeEncoding, (char *) path,
 		&ds), NULL);
 	Tcl_DStringFree(&ds);
     }
@@ -2194,10 +2195,11 @@
 	 * Not called when user changes edit box directly.
 	 */
 
-	if (SHGetPathFromIDList((LPITEMIDLIST) lParam, selDir)) {
+	if (SHGetPathFromIDListW((LPITEMIDLIST) lParam, selDir)) {
 	    SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) selDir);
 	    // enable the OK button
 	    SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
+	    SetCurrentDirectoryW(selDir);
 	} else {
 	    // disable the OK button
 	    SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 0);