Mercurial > dwindows
annotate win/XBrowseForFolder.cpp @ 2793:24977a1ec6fc
iOS: Rewrite dw_window_redraw() so it actually works.
The existing code essentially did nothing, it just set the redraw and shown
state without actually doing anything. This new code works and Interface
Builder now displays correctly without needing to rotate the tablet.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 14 Jul 2022 06:22:19 +0000 |
parents | 2e804b4db81e |
children | 0e47ca67aab0 |
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 |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
214 #ifdef AEROGLASS |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
215 extern "C" { |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
216 /* Include necessary variables and prototypes from dw.c */ |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
217 extern int _DW_DARK_MODE_SUPPORTED; |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
218 extern int _DW_DARK_MODE_ENABLED; |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2141
diff
changeset
|
219 extern BOOL (WINAPI * _dw_should_apps_use_dark_mode)(VOID); |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
220 |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2141
diff
changeset
|
221 BOOL _dw_is_high_contrast(VOID); |
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2141
diff
changeset
|
222 BOOL _dw_is_color_scheme_change_message(LPARAM lParam); |
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2141
diff
changeset
|
223 void _dw_refresh_titlebar_theme_color(HWND window); |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
224 BOOL CALLBACK _dw_set_child_window_theme(HWND window, LPARAM lParam); |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
225 } |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
226 #endif |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
227 |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
228 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
229 // BrowseCallbackProc - SHBrowseForFolder callback function |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
230 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
|
231 UINT uMsg, // Value identifying the event |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
232 LPARAM lParam, // Value dependent upon the message |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
233 LPARAM lpData) // Application-defined value that was |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
234 // specified in the lParam member of the |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
235 // BROWSEINFO structure |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
236 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
237 switch (uMsg) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
238 { |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
239 #ifdef AEROGLASS |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
240 case WM_SETTINGCHANGE: |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
241 { |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2141
diff
changeset
|
242 if(_DW_DARK_MODE_SUPPORTED && _dw_is_color_scheme_change_message(lpData)) |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
243 { |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2141
diff
changeset
|
244 _DW_DARK_MODE_ENABLED = _dw_should_apps_use_dark_mode() && !_dw_is_high_contrast(); |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
245 |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2141
diff
changeset
|
246 _dw_refresh_titlebar_theme_color(hWnd); |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
247 _dw_set_child_window_theme(hWnd, 0); |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
248 EnumChildWindows(hWnd, _dw_set_child_window_theme, 0); |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
249 } |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
250 } |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
251 break; |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
252 #endif |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
253 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
|
254 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
255 // remove context help button from dialog caption |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
256 LONG lStyle = ::GetWindowLong(hWnd, GWL_STYLE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
257 lStyle &= ~DS_CONTEXTHELP; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
258 ::SetWindowLong(hWnd, GWL_STYLE, lStyle); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
259 lStyle = ::GetWindowLong(hWnd, GWL_EXSTYLE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
260 lStyle &= ~WS_EX_CONTEXTHELP; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
261 ::SetWindowLong(hWnd, GWL_EXSTYLE, lStyle); |
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 FOLDER_PROPS *fp = (FOLDER_PROPS *) lpData; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
264 if (fp) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
265 { |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
266 if (fp->lpszInitialFolder && fp->lpszInitialFolder[0]) |
632
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 // set initial directory |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
269 ::SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)fp->lpszInitialFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
270 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
271 |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
272 if (fp->lpszTitle && fp->lpszTitle[0]) |
632
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 // set window caption |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
275 ::SetWindowText(hWnd, fp->lpszTitle); |
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 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
278 |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
279 #ifdef AEROGLASS |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
280 if(_DW_DARK_MODE_SUPPORTED) |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
281 { |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
282 _dw_set_child_window_theme(hWnd, 0); |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
283 EnumChildWindows(hWnd, _dw_set_child_window_theme, 0); |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2141
diff
changeset
|
284 _dw_refresh_titlebar_theme_color(hWnd); |
1971
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
285 } |
d39f4f9bed26
Win: Change to allow dark mode for the folder browser window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1617
diff
changeset
|
286 #endif |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
287 SizeBrowseDialog(hWnd, fp); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
288 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
289 break; |
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 case BFFM_SELCHANGED: // sent when the selection has changed |
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 TCHAR szDir[MAX_PATH*2] = { 0 }; |
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 // fail if non-filesystem |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
296 BOOL bRet = SHGetPathFromIDList((LPITEMIDLIST) lParam, szDir); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
297 if (bRet) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
298 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
299 // fail if folder not accessible |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
300 if (_taccess(szDir, 00) != 0) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
301 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
302 bRet = FALSE; |
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 else |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
305 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
306 SHFILEINFO sfi; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
307 ::SHGetFileInfo((LPCTSTR)lParam, 0, &sfi, sizeof(sfi), |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
308 SHGFI_PIDL | SHGFI_ATTRIBUTES); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
309 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
310 // fail if pidl is a link |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
311 if (sfi.dwAttributes & SFGAO_LINK) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
312 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
313 bRet = FALSE; |
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 } |
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 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
318 // if invalid selection, disable the OK button |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
319 if (!bRet) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
320 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
321 ::EnableWindow(GetDlgItem(hWnd, IDOK), FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
322 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
323 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
324 break; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
325 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
326 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
327 return 0; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
328 } |
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 /////////////////////////////////////////////////////////////////////////////// |
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 // XBrowseForFolder() |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
333 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
334 // Purpose: Invoke the SHBrowseForFolder API. If lpszInitialFolder is |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
335 // 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
|
336 // 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
|
337 // current directory. The selected folder will be returned in |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
338 // lpszBuf. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
339 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
340 // 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
|
341 // lpszInitialFolder - initial folder in tree; if NULL, the initial |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
342 // folder will be the current directory; if |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
343 // 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
|
344 // nRootFolder - optional CSIDL of root folder for tree; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
345 // -1 = use default. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
346 // lpszCaption - optional caption for folder dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
347 // lpszBuf - buffer for the returned folder path |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
348 // dwBufSize - size of lpszBuf in TCHARs |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
349 // bEditBox - TRUE = include edit box in dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
350 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
351 // Returns: BOOL - TRUE = success; FALSE = user hit Cancel |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
352 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
353 BOOL _cdecl XBrowseForFolder(HWND hWnd, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
354 LPCTSTR lpszInitialFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
355 int nRootFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
356 LPCTSTR lpszCaption, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
357 LPTSTR lpszBuf, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
358 DWORD dwBufSize, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
359 BOOL bEditBox /*= FALSE*/) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
360 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
361 if (lpszBuf == NULL || dwBufSize < MAX_PATH) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
362 return FALSE; |
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 ZeroMemory(lpszBuf, dwBufSize*sizeof(TCHAR)); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
365 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
366 BROWSEINFO bi = { 0 }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
367 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
368 // check if there is a special root folder |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
369 LPITEMIDLIST pidlRoot = NULL; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
370 if (nRootFolder != -1) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
371 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
372 if (SUCCEEDED(SHGetSpecialFolderLocation(hWnd, nRootFolder, &pidlRoot))) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
373 bi.pidlRoot = pidlRoot; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
374 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
375 |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
376 TCHAR szInitialPath[MAX_PATH*2] = { 0 }; |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
377 if (lpszInitialFolder) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
378 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
379 // is this a folder path string or a csidl? |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
380 if (HIWORD(lpszInitialFolder) == 0) |
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 // csidl |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
383 int nFolder = LOWORD((UINT)(UINT_PTR)lpszInitialFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
384 SHGetSpecialFolderPath(hWnd, szInitialPath, nFolder, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
385 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
386 else |
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 // string |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
389 _tcsncpy(szInitialPath, lpszInitialFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
390 sizeof(szInitialPath)/sizeof(TCHAR)-2); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
391 } |
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 |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
394 if (!szInitialPath[0] && !bi.pidlRoot) |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
395 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
396 // 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
|
397 ::GetCurrentDirectory(sizeof(szInitialPath)/sizeof(TCHAR)-2, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
398 szInitialPath); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
399 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
400 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
401 FOLDER_PROPS fp; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
402 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
403 bi.hwndOwner = hWnd; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
404 bi.ulFlags = BIF_RETURNONLYFSDIRS; // do NOT use BIF_NEWDIALOGSTYLE, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
405 // or BIF_STATUSTEXT |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
406 if (bEditBox) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
407 bi.ulFlags |= BIF_EDITBOX; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
408 bi.ulFlags |= BIF_NONEWFOLDERBUTTON; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
409 bi.lpfn = BrowseCallbackProc; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
410 bi.lParam = (LPARAM) &fp; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
411 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
412 fp.lpszInitialFolder = szInitialPath; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
413 fp.lpszTitle = lpszCaption; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
414 fp.ulFlags = bi.ulFlags; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
415 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
416 BOOL bRet = FALSE; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
417 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
418 LPITEMIDLIST pidlFolder = SHBrowseForFolder(&bi); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
419 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
420 if (pidlFolder) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
421 { |
1617
f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1362
diff
changeset
|
422 TCHAR szBuffer[MAX_PATH*2] = { 0 }; |
632
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
423 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
424 if (SHGetPathFromIDList(pidlFolder, szBuffer)) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
425 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
426 _tcsncpy(lpszBuf, szBuffer, dwBufSize-1); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
427 bRet = TRUE; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
428 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
429 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
430 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
431 // free up pidls |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
432 IMalloc *pMalloc = NULL; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
433 if (SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
434 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
435 if (pidlFolder) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
436 pMalloc->Free(pidlFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
437 if (pidlRoot) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
438 pMalloc->Free(pidlRoot); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
439 pMalloc->Release(); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
440 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
441 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
442 return bRet; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
443 } |