diff options
author | hobbs <hobbs@noemail.net> | 2004-02-13 01:26:39 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 2004-02-13 01:26:39 (GMT) |
commit | 76123d44346e7a612ccc334905b0c9d2d4e8d5c5 (patch) | |
tree | 9a7a5cfdbfd35c872e9a2dfc8f2be0f225836a1d /win/tkWinDialog.c | |
parent | eaa9a1d64f6fcf52dc8c90adb7cb7d6adc12dc27 (diff) | |
download | tk-76123d44346e7a612ccc334905b0c9d2d4e8d5c5.zip tk-76123d44346e7a612ccc334905b0c9d2d4e8d5c5.tar.gz tk-76123d44346e7a612ccc334905b0c9d2d4e8d5c5.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.
FossilOrigin-Name: 00434343715135b0baba0a0a273b6305c62241c9
Diffstat (limited to 'win/tkWinDialog.c')
-rw-r--r-- | win/tkWinDialog.c | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 7d6c443..2b18d45 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.30.2.1 2003/07/18 19:51:35 hobbs Exp $ + * RCS: @(#) $Id: tkWinDialog.c,v 1.30.2.2 2004/02/13 01:26:41 hobbs Exp $ * */ @@ -1942,25 +1942,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; |