Mercurial > dwindows
annotate win/XBrowseForFolder.cpp @ 1620:32b5fba0b00a
Must convert from UTF8 for the raw HTML on Windows regardless of the
ANSI/UNICODE mode. This fixes incorrect encoding on raw HTML widgets.
Also need to use the ANSI version of GetModuleFileName when converting
the command line parameters, or maybe convert to UTF8?
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 27 Mar 2012 15:09:52 +0000 |
parents | f8d1da63fb77 |
children | d39f4f9bed26 |
rev | line source |
---|---|
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1 // XBrowseForFolder.cpp Version 1.2 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3 // Author: Hans Dietrich |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4 // hdietrich@gmail.com |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6 // Description: |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7 // XBrowseForFolder.cpp implements XBrowseForFolder(), a function that |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8 // wraps SHBrowseForFolder(). |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
9 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
10 // History |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
11 // Version 1.2 - 2008 February 29 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
12 // - Changed API to allow for initial CSIDL. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
13 // - Added option to set dialog caption, suggested by SimpleDivX. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
14 // - Added option to set root, suggested by Jean-Michel Reghem. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
15 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
16 // Version 1.1 - 2003 September 29 (not released) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
17 // - Added support for edit box |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
18 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
19 // Version 1.0 - 2003 September 25 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
20 // - Initial public release |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
21 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
22 // License: |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
23 // This software is released into the public domain. You are free to use |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
24 // it in any way you like, except that you may not sell this source code. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
25 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
26 // This software is provided "as is" with no expressed or implied warranty. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
27 // I accept no liability for any damage or loss of business that this |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
28 // software may cause. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
29 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
30 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
31 |
1362
412af8059331
Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
632
diff
changeset
|
32 /* Make sure we get the right version */ |
412af8059331
Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
632
diff
changeset
|
33 #define _WIN32_IE 0x0500 |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
34 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
35 #ifndef __AFX_H__ |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
36 #include <windows.h> |
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
37 #include <tchar.h> |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
38 #endif |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
39 |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
40 #include <Shlobj.h> |
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
41 #include <io.h> |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
42 #include "XBrowseForFolder.h" |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
43 |
1362
412af8059331
Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
632
diff
changeset
|
44 #ifndef __MINGW32__ |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
45 #pragma warning(disable: 4127) // conditional expression is constant (_ASSERTE) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
46 #pragma warning(disable : 4996) // disable bogus deprecation warning |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
47 #endif |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
48 |
1362
412af8059331
Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
632
diff
changeset
|
49 /* MingW does not have this */ |
412af8059331
Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
632
diff
changeset
|
50 #if !defined(BIF_NONEWFOLDERBUTTON) |
412af8059331
Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
632
diff
changeset
|
51 # define BIF_NONEWFOLDERBUTTON 0x200 |
412af8059331
Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
632
diff
changeset
|
52 #endif |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
53 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
54 //============================================================================= |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
55 // struct to pass to callback function |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
56 //============================================================================= |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
57 struct FOLDER_PROPS |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
58 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
59 LPCTSTR lpszTitle; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
60 LPCTSTR lpszInitialFolder; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
61 UINT ulFlags; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
62 }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
63 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
64 #ifndef __AFX_H__ |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
65 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
66 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
67 // CRect - a minimal CRect class |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
68 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
69 class CRect : public tagRECT |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
70 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
71 public: |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
72 //CRect() { } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
73 CRect(int l = 0, int t = 0, int r = 0, int b = 0) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
74 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
75 left = l; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
76 top = t; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
77 right = r; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
78 bottom = b; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
79 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
80 int Width() const { return right - left; } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
81 int Height() const { return bottom - top; } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
82 void SwapLeftRight() { SwapLeftRight(LPRECT(this)); } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
83 static void SwapLeftRight(LPRECT lpRect) { LONG temp = lpRect->left; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
84 lpRect->left = lpRect->right; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
85 lpRect->right = temp; } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
86 operator LPRECT() { return this; } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
87 }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
88 #endif |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
89 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
90 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
91 // ScreenToClientX - helper function in case non-MFC |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
92 static void ScreenToClientX(HWND hWnd, LPRECT lpRect) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
93 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
94 ::ScreenToClient(hWnd, (LPPOINT)lpRect); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
95 ::ScreenToClient(hWnd, ((LPPOINT)lpRect)+1); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
96 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
97 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
98 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
99 // MoveWindowX - helper function in case non-MFC |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
100 static void MoveWindowX(HWND hWnd, CRect& rect, BOOL bRepaint) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
101 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
102 ::MoveWindow(hWnd, rect.left, rect.top, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
103 rect.Width(), rect.Height(), bRepaint); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
104 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
105 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
106 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
107 // SizeBrowseDialog - resize dialog, move controls |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
108 static void SizeBrowseDialog(HWND hWnd, FOLDER_PROPS *fp) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
109 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
110 // find the folder tree and make dialog larger |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
111 HWND hwndTree = FindWindowEx(hWnd, NULL, TEXT("SysTreeView32"), NULL); |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
112 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
113 if (!hwndTree) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
114 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
115 // ... this usually means that BIF_NEWDIALOGSTYLE is enabled. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
116 // Then the class name is as used in the code below. |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
117 hwndTree = FindWindowEx(hWnd, NULL, TEXT("SHBrowseForFolder ShellNameSpace Control"), NULL); |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
118 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
119 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
120 CRect rectDlg; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
121 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
122 if (hwndTree) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
123 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
124 // check if edit box |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
125 int nEditHeight = 0; |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
126 HWND hwndEdit = FindWindowEx(hWnd, NULL, TEXT("Edit"), NULL); |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
127 CRect rectEdit; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
128 if (hwndEdit && (fp->ulFlags & BIF_EDITBOX)) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
129 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
130 ::GetWindowRect(hwndEdit, &rectEdit); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
131 ScreenToClientX(hWnd, &rectEdit); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
132 nEditHeight = rectEdit.Height(); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
133 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
134 else if (hwndEdit) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
135 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
136 ::MoveWindow(hwndEdit, 20000, 20000, 10, 10, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
137 ::ShowWindow(hwndEdit, SW_HIDE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
138 hwndEdit = 0; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
139 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
140 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
141 // make the dialog larger |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
142 ::GetWindowRect(hWnd, &rectDlg); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
143 rectDlg.right += 40; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
144 rectDlg.bottom += 30; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
145 if (hwndEdit) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
146 rectDlg.bottom += nEditHeight + 5; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
147 MoveWindowX(hWnd, rectDlg, TRUE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
148 ::GetClientRect(hWnd, &rectDlg); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
149 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
150 int hMargin = 10; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
151 int vMargin = 10; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
152 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
153 // check if new dialog style - this means that there will be a resizing |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
154 // grabber in lower right corner |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
155 if (fp->ulFlags & BIF_NEWDIALOGSTYLE) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
156 hMargin = ::GetSystemMetrics(SM_CXVSCROLL); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
157 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
158 // move the Cancel button |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
159 CRect rectCancel; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
160 HWND hwndCancel = ::GetDlgItem(hWnd, IDCANCEL); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
161 if (hwndCancel) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
162 ::GetWindowRect(hwndCancel, &rectCancel); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
163 ScreenToClientX(hWnd, &rectCancel); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
164 int h = rectCancel.Height(); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
165 int w = rectCancel.Width(); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
166 rectCancel.bottom = rectDlg.bottom - vMargin;//nMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
167 rectCancel.top = rectCancel.bottom - h; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
168 rectCancel.right = rectDlg.right - hMargin; //(scrollWidth + 2*borderWidth); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
169 rectCancel.left = rectCancel.right - w; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
170 if (hwndCancel) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
171 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
172 MoveWindowX(hwndCancel, rectCancel, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
173 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
174 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
175 // move the OK button |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
176 CRect rectOK(0, 0, 0, 0); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
177 HWND hwndOK = ::GetDlgItem(hWnd, IDOK); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
178 if (hwndOK) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
179 ::GetWindowRect(hwndOK, &rectOK); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
180 ScreenToClientX(hWnd, &rectOK); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
181 rectOK.bottom = rectCancel.bottom; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
182 rectOK.top = rectCancel.top; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
183 rectOK.right = rectCancel.left - 10; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
184 rectOK.left = rectOK.right - w; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
185 if (hwndOK) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
186 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
187 MoveWindowX(hwndOK, rectOK, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
188 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
189 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
190 // expand the folder tree to fill the dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
191 CRect rectTree; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
192 ::GetWindowRect(hwndTree, &rectTree); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
193 ScreenToClientX(hWnd, &rectTree); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
194 if (hwndEdit) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
195 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
196 rectEdit.left = hMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
197 rectEdit.right = rectDlg.right - hMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
198 rectEdit.top = vMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
199 rectEdit.bottom = rectEdit.top + nEditHeight; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
200 MoveWindowX(hwndEdit, rectEdit, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
201 rectTree.top = rectEdit.bottom + 5; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
202 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
203 else |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
204 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
205 rectTree.top = vMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
206 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
207 rectTree.left = hMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
208 rectTree.bottom = rectOK.top - 10;//nMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
209 rectTree.right = rectDlg.right - hMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
210 MoveWindowX(hwndTree, rectTree, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
211 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
212 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
213 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
214 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
215 // BrowseCallbackProc - SHBrowseForFolder callback function |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
216 static int CALLBACK BrowseCallbackProc(HWND hWnd, // Window handle to the browse dialog box |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
217 UINT uMsg, // Value identifying the event |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
218 LPARAM lParam, // Value dependent upon the message |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
219 LPARAM lpData) // Application-defined value that was |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
220 // specified in the lParam member of the |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
221 // BROWSEINFO structure |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
222 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
223 switch (uMsg) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
224 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
225 case BFFM_INITIALIZED: // sent when the browse dialog box has finished initializing. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
226 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
227 // remove context help button from dialog caption |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
228 LONG lStyle = ::GetWindowLong(hWnd, GWL_STYLE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
229 lStyle &= ~DS_CONTEXTHELP; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
230 ::SetWindowLong(hWnd, GWL_STYLE, lStyle); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
231 lStyle = ::GetWindowLong(hWnd, GWL_EXSTYLE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
232 lStyle &= ~WS_EX_CONTEXTHELP; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
233 ::SetWindowLong(hWnd, GWL_EXSTYLE, lStyle); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
234 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
235 FOLDER_PROPS *fp = (FOLDER_PROPS *) lpData; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
236 if (fp) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
237 { |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
238 if (fp->lpszInitialFolder && fp->lpszInitialFolder[0]) |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
239 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
240 // set initial directory |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
241 ::SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)fp->lpszInitialFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
242 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
243 |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
244 if (fp->lpszTitle && fp->lpszTitle[0]) |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
245 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
246 // set window caption |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
247 ::SetWindowText(hWnd, fp->lpszTitle); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
248 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
249 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
250 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
251 SizeBrowseDialog(hWnd, fp); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
252 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
253 break; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
254 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
255 case BFFM_SELCHANGED: // sent when the selection has changed |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
256 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
257 TCHAR szDir[MAX_PATH*2] = { 0 }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
258 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
259 // fail if non-filesystem |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
260 BOOL bRet = SHGetPathFromIDList((LPITEMIDLIST) lParam, szDir); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
261 if (bRet) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
262 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
263 // fail if folder not accessible |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
264 if (_taccess(szDir, 00) != 0) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
265 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
266 bRet = FALSE; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
267 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
268 else |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
269 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
270 SHFILEINFO sfi; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
271 ::SHGetFileInfo((LPCTSTR)lParam, 0, &sfi, sizeof(sfi), |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
272 SHGFI_PIDL | SHGFI_ATTRIBUTES); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
273 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
274 // fail if pidl is a link |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
275 if (sfi.dwAttributes & SFGAO_LINK) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
276 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
277 bRet = FALSE; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
278 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
279 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
280 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
281 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
282 // if invalid selection, disable the OK button |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
283 if (!bRet) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
284 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
285 ::EnableWindow(GetDlgItem(hWnd, IDOK), FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
286 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
287 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
288 break; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
289 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
290 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
291 return 0; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
292 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
293 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
294 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
295 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
296 // XBrowseForFolder() |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
297 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
298 // Purpose: Invoke the SHBrowseForFolder API. If lpszInitialFolder is |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
299 // supplied, it will be the folder initially selected in the tree |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
300 // folder list. Otherwise, the initial folder will be set to the |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
301 // current directory. The selected folder will be returned in |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
302 // lpszBuf. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
303 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
304 // Parameters: hWnd - handle to the owner window for the dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
305 // lpszInitialFolder - initial folder in tree; if NULL, the initial |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
306 // folder will be the current directory; if |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
307 // if this is a CSIDL, must be a real folder. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
308 // nRootFolder - optional CSIDL of root folder for tree; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
309 // -1 = use default. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
310 // lpszCaption - optional caption for folder dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
311 // lpszBuf - buffer for the returned folder path |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
312 // dwBufSize - size of lpszBuf in TCHARs |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
313 // bEditBox - TRUE = include edit box in dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
314 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
315 // Returns: BOOL - TRUE = success; FALSE = user hit Cancel |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
316 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
317 BOOL _cdecl XBrowseForFolder(HWND hWnd, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
318 LPCTSTR lpszInitialFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
319 int nRootFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
320 LPCTSTR lpszCaption, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
321 LPTSTR lpszBuf, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
322 DWORD dwBufSize, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
323 BOOL bEditBox /*= FALSE*/) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
324 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
325 if (lpszBuf == NULL || dwBufSize < MAX_PATH) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
326 return FALSE; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
327 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
328 ZeroMemory(lpszBuf, dwBufSize*sizeof(TCHAR)); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
329 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
330 BROWSEINFO bi = { 0 }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
331 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
332 // check if there is a special root folder |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
333 LPITEMIDLIST pidlRoot = NULL; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
334 if (nRootFolder != -1) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
335 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
336 if (SUCCEEDED(SHGetSpecialFolderLocation(hWnd, nRootFolder, &pidlRoot))) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
337 bi.pidlRoot = pidlRoot; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
338 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
339 |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
340 TCHAR szInitialPath[MAX_PATH*2] = { 0 }; |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
341 if (lpszInitialFolder) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
342 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
343 // is this a folder path string or a csidl? |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
344 if (HIWORD(lpszInitialFolder) == 0) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
345 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
346 // csidl |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
347 int nFolder = LOWORD((UINT)(UINT_PTR)lpszInitialFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
348 SHGetSpecialFolderPath(hWnd, szInitialPath, nFolder, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
349 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
350 else |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
351 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
352 // string |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
353 _tcsncpy(szInitialPath, lpszInitialFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
354 sizeof(szInitialPath)/sizeof(TCHAR)-2); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
355 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
356 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
357 |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
358 if (!szInitialPath[0] && !bi.pidlRoot) |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
359 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
360 // no initial folder and no root, set to current directory |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
361 ::GetCurrentDirectory(sizeof(szInitialPath)/sizeof(TCHAR)-2, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
362 szInitialPath); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
363 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
364 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
365 FOLDER_PROPS fp; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
366 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
367 bi.hwndOwner = hWnd; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
368 bi.ulFlags = BIF_RETURNONLYFSDIRS; // do NOT use BIF_NEWDIALOGSTYLE, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
369 // or BIF_STATUSTEXT |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
370 if (bEditBox) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
371 bi.ulFlags |= BIF_EDITBOX; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
372 bi.ulFlags |= BIF_NONEWFOLDERBUTTON; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
373 bi.lpfn = BrowseCallbackProc; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
374 bi.lParam = (LPARAM) &fp; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
375 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
376 fp.lpszInitialFolder = szInitialPath; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
377 fp.lpszTitle = lpszCaption; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
378 fp.ulFlags = bi.ulFlags; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
379 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
380 BOOL bRet = FALSE; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
381 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
382 LPITEMIDLIST pidlFolder = SHBrowseForFolder(&bi); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
383 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
384 if (pidlFolder) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
385 { |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
386 TCHAR szBuffer[MAX_PATH*2] = { 0 }; |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
387 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
388 if (SHGetPathFromIDList(pidlFolder, szBuffer)) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
389 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
390 _tcsncpy(lpszBuf, szBuffer, dwBufSize-1); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
391 bRet = TRUE; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
392 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
393 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
394 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
395 // free up pidls |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
396 IMalloc *pMalloc = NULL; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
397 if (SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
398 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
399 if (pidlFolder) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
400 pMalloc->Free(pidlFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
401 if (pidlRoot) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
402 pMalloc->Free(pidlRoot); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
403 pMalloc->Release(); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
404 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
405 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
406 return bRet; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
407 } |