Mercurial > projects > dynamin
comparison dynamin/gui/windows_directory_dialog.d @ 21:d0ce1db78819
Directories can now be preselected on Windows
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Fri, 24 Jul 2009 15:14:01 -0500 |
parents | 63cbfb167240 |
children |
comparison
equal
deleted
inserted
replaced
20:63cbfb167240 | 21:d0ce1db78819 |
---|---|
26 module dynamin.gui.windows_directory_dialog; | 26 module dynamin.gui.windows_directory_dialog; |
27 | 27 |
28 public import Utf = tango.text.convert.Utf; | 28 public import Utf = tango.text.convert.Utf; |
29 | 29 |
30 template DirectoryDialogBackend() { | 30 template DirectoryDialogBackend() { |
31 extern(Windows) static int setSelectedDirectory(HWND hwnd, | |
32 UINT uMsg, LPARAM lParam, LPARAM lpData) { | |
33 if(uMsg == BFFM_INITIALIZED) | |
34 SendMessage(hwnd, BFFM_SETSELECTION, true, lpData); | |
35 return 0; | |
36 } | |
37 | |
31 DialogResult backend_showDialog() { | 38 DialogResult backend_showDialog() { |
32 BROWSEINFO bi; | 39 BROWSEINFO bi; |
33 //bi.hwndOwner = ; | 40 //bi.hwndOwner = ; |
34 bi.lpszTitle = "Choose a folder:"; | 41 bi.lpszTitle = "Choose a folder:"; |
35 bi.ulFlags |= BIF_RETURNONLYFSDIRS; | 42 bi.ulFlags |= BIF_RETURNONLYFSDIRS; |
36 bi.ulFlags |= BIF_USENEWUI; | 43 bi.ulFlags |= BIF_USENEWUI; |
37 | 44 if(directory) { |
38 //IShellFolder shf; | 45 bi.lpfn = &setSelectedDirectory; |
39 //SHGetDesktopFolder(&shf); | 46 bi.lParam = cast(LPARAM)toWcharPtr(directory); |
40 //ITEMIDLIST* pidlInit; | 47 } |
41 //shf.ParseDisplayName(null, null, toWcharPtr(directory), null, &pidlInit, null); | |
42 //shf.Release(); | |
43 //bi.pidlRoot = pidlInit; | |
44 | 48 |
45 ITEMIDLIST* pidl = SHBrowseForFolder(&bi); | 49 ITEMIDLIST* pidl = SHBrowseForFolder(&bi); |
46 //CoTaskMemFree(pidlInit); | |
47 if(!pidl) | 50 if(!pidl) |
48 return DialogResult.Cancel; | 51 return DialogResult.Cancel; |
49 wchar[MAX_PATH+1] dirBuffer; // MAX_PATH is 260 | 52 wchar[MAX_PATH+1] dirBuffer; // MAX_PATH is 260 |
50 if(!SHGetPathFromIDList(pidl, dirBuffer.ptr)) { | 53 if(!SHGetPathFromIDList(pidl, dirBuffer.ptr)) { |
51 Stdout("GetPathFromIDList() failed").newline; | 54 Stdout("GetPathFromIDList() failed").newline; |