summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2004-02-13 01:28:19 (GMT)
committerhobbs <hobbs>2004-02-13 01:28:19 (GMT)
commit60f6fecb3068f40ba0e52153975314ce2e24bda2 (patch)
tree0e49ce33e22ad55b5e6d62d9fe0cc68f4c8f4c19
parent5973733c0efb92e16e02347b7c0bcb77be07f3c7 (diff)
downloadtk-60f6fecb3068f40ba0e52153975314ce2e24bda2.zip
tk-60f6fecb3068f40ba0e52153975314ce2e24bda2.tar.gz
tk-60f6fecb3068f40ba0e52153975314ce2e24bda2.tar.bz2
* win/tkWinDialog.c (ChooseDirectoryValidateProc): create a pidl
for -initialdir if we have a UNC path because BFFM_SETSELECTION doesn't support UNC paths in strings.
-rw-r--r--ChangeLog6
-rw-r--r--win/tkWinDialog.c47
2 files changed, 46 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 4b05321..2bba247 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-02-12 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * win/tkWinDialog.c (ChooseDirectoryValidateProc): create a pidl
+ for -initialdir if we have a UNC path because BFFM_SETSELECTION
+ doesn't support UNC paths in strings.
+
2004-02-10 Donal K. Fellows <donal.k.fellows@man.ac.uk>
* library/msgs/eo.msg: Language support for Esperanto and Polish from
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 1ede6d5..ea08072 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinDialog.c,v 1.33 2004/01/13 02:06:01 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinDialog.c,v 1.34 2004/02/13 01:28:19 hobbs Exp $
*
*/
@@ -1999,25 +1999,58 @@ ChooseDirectoryValidateProc (
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) selDir);
// enable the OK button
SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
- //EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);
SetCurrentDirectory(selDir);
} else {
// disable the OK button
SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 0);
- //EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
}
UpdateWindow(hwnd);
return 1;
- case BFFM_INITIALIZED:
+ case BFFM_INITIALIZED: {
/*
* Directory browser intializing - tell it where to start from,
* user specified parameter.
*/
- SetCurrentDirectory((char *) lpData);
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpData);
- SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
+ char *initDir = chooseDirSharedData->utfInitDir;
+
+ SetCurrentDirectory(initDir);
+ if (*initDir == '\\') {
+ /*
+ * BFFM_SETSELECTION only understands UNC paths as pidls,
+ * so convert path to pidl using IShellFolder interface.
+ */
+ LPMALLOC pMalloc;
+ LPSHELLFOLDER psfFolder;
+
+ if (SUCCEEDED(SHGetMalloc(&pMalloc))) {
+ if (SUCCEEDED(SHGetDesktopFolder(&psfFolder))) {
+ LPITEMIDLIST pidlMain;
+ ULONG ulCount, ulAttr;
+ Tcl_DString ds;
+
+ Tcl_UtfToExternalDString(TkWinGetUnicodeEncoding(),
+ initDir, -1, &ds);
+ if (SUCCEEDED(psfFolder->lpVtbl->ParseDisplayName(
+ psfFolder, hwnd, NULL,
+ (WCHAR *) Tcl_DStringValue(&ds),
+ &ulCount, &pidlMain, &ulAttr))
+ && (pidlMain != NULL)) {
+ SendMessage(hwnd, BFFM_SETSELECTION, FALSE,
+ (LPARAM)pidlMain);
+ pMalloc->lpVtbl->Free(pMalloc, pidlMain);
+ }
+ psfFolder->lpVtbl->Release(psfFolder);
+ Tcl_DStringFree(&ds);
+ }
+ pMalloc->lpVtbl->Release(pMalloc);
+ }
+ } else {
+ SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)initDir);
+ }
+ SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
break;
+ }
}
return 0;