Mercurial > dwindows
annotate win/XBrowseForFolder.cpp @ 1000:99907f19a703
Minor fixed and code cleanups on OS/2.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 08 May 2011 03:28:10 +0000 |
parents | bf3a6d596cd4 |
children | 412af8059331 |
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 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
32 // if you don't want to use MFC, comment out the following line: |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
33 //#include "stdafx.h" |
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__ |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
36 #include "windows.h" |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
37 #include "crtdbg.h" |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
38 #include "tchar.h" |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
39 #endif |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
40 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
41 #include "Shlobj.h" |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
42 #include "io.h" |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
43 #include "XBrowseForFolder.h" |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
44 |
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 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
48 #ifndef __noop |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
49 #if _MSC_VER < 1300 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
50 #define __noop ((void)0) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
51 #endif |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
52 #endif |
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 #undef TRACE |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
55 #define TRACE __noop |
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 //============================================================================= |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
58 // if you want to see the TRACE output, uncomment this line: |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
59 //#include "XTrace.h" |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
60 //============================================================================= |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
61 |
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 // struct to pass to callback function |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
64 //============================================================================= |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
65 struct FOLDER_PROPS |
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 LPCTSTR lpszTitle; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
68 LPCTSTR lpszInitialFolder; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
69 UINT ulFlags; |
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 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
72 #ifndef __AFX_H__ |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
73 |
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 // CRect - a minimal CRect class |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
76 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
77 class CRect : public tagRECT |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
78 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
79 public: |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
80 //CRect() { } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
81 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
|
82 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
83 left = l; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
84 top = t; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
85 right = r; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
86 bottom = b; |
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 int Width() const { return right - left; } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
89 int Height() const { return bottom - top; } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
90 void SwapLeftRight() { SwapLeftRight(LPRECT(this)); } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
91 static void SwapLeftRight(LPRECT lpRect) { LONG temp = lpRect->left; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
92 lpRect->left = lpRect->right; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
93 lpRect->right = temp; } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
94 operator LPRECT() { return this; } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
95 }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
96 #endif |
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 // ScreenToClientX - helper function in case non-MFC |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
100 static void ScreenToClientX(HWND hWnd, LPRECT lpRect) |
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 _ASSERTE(::IsWindow(hWnd)); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
103 ::ScreenToClient(hWnd, (LPPOINT)lpRect); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
104 ::ScreenToClient(hWnd, ((LPPOINT)lpRect)+1); |
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 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
108 // MoveWindowX - helper function in case non-MFC |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
109 static void MoveWindowX(HWND hWnd, CRect& rect, BOOL bRepaint) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
110 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
111 _ASSERTE(::IsWindow(hWnd)); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
112 ::MoveWindow(hWnd, rect.left, rect.top, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
113 rect.Width(), rect.Height(), bRepaint); |
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 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
116 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
117 // SizeBrowseDialog - resize dialog, move controls |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
118 static void SizeBrowseDialog(HWND hWnd, FOLDER_PROPS *fp) |
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 TRACE(_T("in void SizeBrowseDialog\n")); |
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 // find the folder tree and make dialog larger |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
123 HWND hwndTree = FindWindowEx(hWnd, NULL, _T("SysTreeView32"), NULL); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
124 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
125 if (!hwndTree) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
126 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
127 // ... this usually means that BIF_NEWDIALOGSTYLE is enabled. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
128 // Then the class name is as used in the code below. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
129 hwndTree = FindWindowEx(hWnd, NULL, _T("SHBrowseForFolder ShellNameSpace Control"), NULL); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
130 TRACE(_T("SHBrowseForFolder ShellNameSpace Control: hwndTree=%X\n"), hwndTree); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
131 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
132 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
133 CRect rectDlg; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
134 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
135 _ASSERTE(IsWindow(hwndTree)); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
136 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
137 if (hwndTree) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
138 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
139 // check if edit box |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
140 int nEditHeight = 0; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
141 HWND hwndEdit = FindWindowEx(hWnd, NULL, _T("Edit"), NULL); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
142 TRACE(_T("hwndEdit=%x\n"), hwndEdit); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
143 CRect rectEdit; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
144 if (hwndEdit && (fp->ulFlags & BIF_EDITBOX)) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
145 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
146 ::GetWindowRect(hwndEdit, &rectEdit); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
147 ScreenToClientX(hWnd, &rectEdit); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
148 nEditHeight = rectEdit.Height(); |
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 else if (hwndEdit) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
151 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
152 ::MoveWindow(hwndEdit, 20000, 20000, 10, 10, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
153 ::ShowWindow(hwndEdit, SW_HIDE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
154 hwndEdit = 0; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
155 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
156 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
157 // make the dialog larger |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
158 ::GetWindowRect(hWnd, &rectDlg); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
159 rectDlg.right += 40; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
160 rectDlg.bottom += 30; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
161 if (hwndEdit) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
162 rectDlg.bottom += nEditHeight + 5; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
163 MoveWindowX(hWnd, rectDlg, TRUE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
164 ::GetClientRect(hWnd, &rectDlg); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
165 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
166 int hMargin = 10; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
167 int vMargin = 10; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
168 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
169 // 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
|
170 // grabber in lower right corner |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
171 if (fp->ulFlags & BIF_NEWDIALOGSTYLE) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
172 hMargin = ::GetSystemMetrics(SM_CXVSCROLL); |
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 // move the Cancel button |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
175 CRect rectCancel; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
176 HWND hwndCancel = ::GetDlgItem(hWnd, IDCANCEL); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
177 if (hwndCancel) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
178 ::GetWindowRect(hwndCancel, &rectCancel); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
179 ScreenToClientX(hWnd, &rectCancel); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
180 int h = rectCancel.Height(); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
181 int w = rectCancel.Width(); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
182 rectCancel.bottom = rectDlg.bottom - vMargin;//nMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
183 rectCancel.top = rectCancel.bottom - h; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
184 rectCancel.right = rectDlg.right - hMargin; //(scrollWidth + 2*borderWidth); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
185 rectCancel.left = rectCancel.right - w; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
186 if (hwndCancel) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
187 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
188 //TRACERECT(rectCancel); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
189 MoveWindowX(hwndCancel, rectCancel, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
190 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
191 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
192 // move the OK button |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
193 CRect rectOK(0, 0, 0, 0); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
194 HWND hwndOK = ::GetDlgItem(hWnd, IDOK); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
195 if (hwndOK) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
196 ::GetWindowRect(hwndOK, &rectOK); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
197 ScreenToClientX(hWnd, &rectOK); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
198 rectOK.bottom = rectCancel.bottom; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
199 rectOK.top = rectCancel.top; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
200 rectOK.right = rectCancel.left - 10; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
201 rectOK.left = rectOK.right - w; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
202 if (hwndOK) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
203 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
204 MoveWindowX(hwndOK, rectOK, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
205 } |
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 // expand the folder tree to fill the dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
208 CRect rectTree; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
209 ::GetWindowRect(hwndTree, &rectTree); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
210 ScreenToClientX(hWnd, &rectTree); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
211 if (hwndEdit) |
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 rectEdit.left = hMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
214 rectEdit.right = rectDlg.right - hMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
215 rectEdit.top = vMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
216 rectEdit.bottom = rectEdit.top + nEditHeight; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
217 MoveWindowX(hwndEdit, rectEdit, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
218 rectTree.top = rectEdit.bottom + 5; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
219 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
220 else |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
221 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
222 rectTree.top = vMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
223 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
224 rectTree.left = hMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
225 rectTree.bottom = rectOK.top - 10;//nMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
226 rectTree.right = rectDlg.right - hMargin; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
227 //TRACERECT(rectTree); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
228 MoveWindowX(hwndTree, rectTree, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
229 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
230 else |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
231 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
232 TRACE(_T("ERROR - tree control not found.\n")); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
233 //_ASSERTE(hwndTree); |
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 } |
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 /////////////////////////////////////////////////////////////////////////////// |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
238 // BrowseCallbackProc - SHBrowseForFolder callback function |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
239 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
|
240 UINT uMsg, // Value identifying the event |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
241 LPARAM lParam, // Value dependent upon the message |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
242 LPARAM lpData) // Application-defined value that was |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
243 // specified in the lParam member of the |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
244 // BROWSEINFO structure |
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 switch (uMsg) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
247 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
248 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
|
249 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
250 TRACE(_T("hWnd=%X\n"), hWnd); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
251 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
252 // remove context help button from dialog caption |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
253 LONG lStyle = ::GetWindowLong(hWnd, GWL_STYLE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
254 lStyle &= ~DS_CONTEXTHELP; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
255 ::SetWindowLong(hWnd, GWL_STYLE, lStyle); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
256 lStyle = ::GetWindowLong(hWnd, GWL_EXSTYLE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
257 lStyle &= ~WS_EX_CONTEXTHELP; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
258 ::SetWindowLong(hWnd, GWL_EXSTYLE, lStyle); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
259 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
260 FOLDER_PROPS *fp = (FOLDER_PROPS *) lpData; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
261 if (fp) |
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 if (fp->lpszInitialFolder && (fp->lpszInitialFolder[0] != _T('\0'))) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
264 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
265 // set initial directory |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
266 ::SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)fp->lpszInitialFolder); |
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 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
269 if (fp->lpszTitle && (fp->lpszTitle[0] != _T('\0'))) |
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 // set window caption |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
272 ::SetWindowText(hWnd, fp->lpszTitle); |
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 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
275 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
276 SizeBrowseDialog(hWnd, fp); |
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 break; |
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 case BFFM_SELCHANGED: // sent when the selection has changed |
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 TCHAR szDir[MAX_PATH*2] = { 0 }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
283 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
284 // fail if non-filesystem |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
285 BOOL bRet = SHGetPathFromIDList((LPITEMIDLIST) lParam, szDir); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
286 if (bRet) |
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 // fail if folder not accessible |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
289 if (_taccess(szDir, 00) != 0) |
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 bRet = FALSE; |
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 else |
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 SHFILEINFO sfi; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
296 ::SHGetFileInfo((LPCTSTR)lParam, 0, &sfi, sizeof(sfi), |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
297 SHGFI_PIDL | SHGFI_ATTRIBUTES); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
298 TRACE(_T("dwAttributes=0x%08X\n"), sfi.dwAttributes); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
299 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
300 // fail if pidl is a link |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
301 if (sfi.dwAttributes & SFGAO_LINK) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
302 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
303 TRACE(_T("SFGAO_LINK\n")); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
304 bRet = FALSE; |
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 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
307 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
308 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
309 // if invalid selection, disable the OK button |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
310 if (!bRet) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
311 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
312 ::EnableWindow(GetDlgItem(hWnd, IDOK), FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
313 } |
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 TRACE(_T("szDir=%s\n"), szDir); |
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 break; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
318 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
319 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
320 return 0; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
321 } |
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 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
325 // XBrowseForFolder() |
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 // Purpose: Invoke the SHBrowseForFolder API. If lpszInitialFolder is |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
328 // 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
|
329 // 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
|
330 // current directory. The selected folder will be returned in |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
331 // lpszBuf. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
332 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
333 // 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
|
334 // lpszInitialFolder - initial folder in tree; if NULL, the initial |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
335 // folder will be the current directory; if |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
336 // 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
|
337 // nRootFolder - optional CSIDL of root folder for tree; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
338 // -1 = use default. |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
339 // lpszCaption - optional caption for folder dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
340 // lpszBuf - buffer for the returned folder path |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
341 // dwBufSize - size of lpszBuf in TCHARs |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
342 // bEditBox - TRUE = include edit box in dialog |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
343 // |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
344 // Returns: BOOL - TRUE = success; FALSE = user hit Cancel |
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 BOOL _cdecl XBrowseForFolder(HWND hWnd, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
347 LPCTSTR lpszInitialFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
348 int nRootFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
349 LPCTSTR lpszCaption, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
350 LPTSTR lpszBuf, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
351 DWORD dwBufSize, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
352 BOOL bEditBox /*= FALSE*/) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
353 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
354 _ASSERTE(lpszBuf); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
355 _ASSERTE(dwBufSize >= MAX_PATH); |
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 if (lpszBuf == NULL || dwBufSize < MAX_PATH) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
358 return FALSE; |
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 ZeroMemory(lpszBuf, dwBufSize*sizeof(TCHAR)); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
361 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
362 BROWSEINFO bi = { 0 }; |
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 // check if there is a special root folder |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
365 LPITEMIDLIST pidlRoot = NULL; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
366 if (nRootFolder != -1) |
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 if (SUCCEEDED(SHGetSpecialFolderLocation(hWnd, nRootFolder, &pidlRoot))) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
369 bi.pidlRoot = pidlRoot; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
370 } |
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 TCHAR szInitialPath[MAX_PATH*2] = { _T('\0') }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
373 if (lpszInitialFolder) |
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 // is this a folder path string or a csidl? |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
376 if (HIWORD(lpszInitialFolder) == 0) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
377 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
378 // csidl |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
379 int nFolder = LOWORD((UINT)(UINT_PTR)lpszInitialFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
380 TRACE(_T("csidl: nFolder=0x%X\n"), nFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
381 SHGetSpecialFolderPath(hWnd, szInitialPath, nFolder, FALSE); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
382 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
383 else |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
384 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
385 // string |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
386 _tcsncpy(szInitialPath, lpszInitialFolder, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
387 sizeof(szInitialPath)/sizeof(TCHAR)-2); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
388 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
389 TRACE(_T("szInitialPath=<%s>\n"), szInitialPath); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
390 } |
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 if ((szInitialPath[0] == _T('\0')) && (bi.pidlRoot == NULL)) |
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 // 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
|
395 ::GetCurrentDirectory(sizeof(szInitialPath)/sizeof(TCHAR)-2, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
396 szInitialPath); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
397 } |
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 FOLDER_PROPS fp; |
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 bi.hwndOwner = hWnd; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
402 bi.ulFlags = BIF_RETURNONLYFSDIRS; // do NOT use BIF_NEWDIALOGSTYLE, |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
403 // or BIF_STATUSTEXT |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
404 if (bEditBox) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
405 bi.ulFlags |= BIF_EDITBOX; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
406 bi.ulFlags |= BIF_NONEWFOLDERBUTTON; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
407 bi.lpfn = BrowseCallbackProc; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
408 bi.lParam = (LPARAM) &fp; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
409 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
410 fp.lpszInitialFolder = szInitialPath; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
411 fp.lpszTitle = lpszCaption; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
412 fp.ulFlags = bi.ulFlags; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
413 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
414 BOOL bRet = FALSE; |
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 LPITEMIDLIST pidlFolder = SHBrowseForFolder(&bi); |
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 if (pidlFolder) |
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 TCHAR szBuffer[MAX_PATH*2] = { _T('\0') }; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
421 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
422 if (SHGetPathFromIDList(pidlFolder, szBuffer)) |
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 _tcsncpy(lpszBuf, szBuffer, dwBufSize-1); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
425 bRet = TRUE; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
426 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
427 else |
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 TRACE(_T("SHGetPathFromIDList failed\n")); |
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 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
432 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
433 // free up pidls |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
434 IMalloc *pMalloc = NULL; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
435 if (SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
436 { |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
437 if (pidlFolder) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
438 pMalloc->Free(pidlFolder); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
439 if (pidlRoot) |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
440 pMalloc->Free(pidlRoot); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
441 pMalloc->Release(); |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
442 } |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
443 |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
444 return bRet; |
bf3a6d596cd4
Use better directory browser widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
445 } |