6a385d530a87eaa68e5895c43269733323cb31ee
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
47 ////////////////////////////////////////////////////////////////////////////////
49 static void draw_splitbar(HWND hWnd
, int x
)
52 HDC hdc
= GetDC(hWnd
);
54 GetClientRect(hWnd
, &rt
);
55 rt
.left
= x
- SPLIT_WIDTH
/2;
56 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
61 #define _NO_EXTENSIONS
63 static void ResizeWnd(ChildWnd
* pChildWnd
, int cx
, int cy
)
65 HDWP hdwp
= BeginDeferWindowPos(2);
66 RECT rt
= {0, 0, cx
, cy
};
68 cx
= pChildWnd
->nSplitPos
+ SPLIT_WIDTH
/2;
69 DeferWindowPos(hdwp
, pChildWnd
->hTreeWnd
, 0, rt
.left
, rt
.top
, pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2-rt
.left
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
70 DeferWindowPos(hdwp
, pChildWnd
->hListWnd
, 0, rt
.left
+cx
+1, rt
.top
, rt
.right
-cx
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
71 EndDeferWindowPos(hdwp
);
74 static void OnSize(ChildWnd
* pChildWnd
, WPARAM wParam
, LPARAM lParam
)
76 if (wParam
!= SIZE_MINIMIZED
&& pChildWnd
!= NULL
) {
77 ResizeWnd(pChildWnd
, LOWORD(lParam
), HIWORD(lParam
));
81 static void OnPaint(HWND hWnd
)
87 GetClientRect(hWnd
, &rt
);
88 hdc
= BeginPaint(hWnd
, &ps
);
89 FillRect(ps
.hdc
, &rt
, GetStockObject(LTGRAY_BRUSH
));
94 ////////////////////////////////////////////////////////////////////////////////
96 // FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
98 // PURPOSE: Processes WM_COMMAND messages for the main frame window.
102 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
104 switch (LOWORD(wParam
)) {
105 // Parse the menu selections:
106 case ID_REGISTRY_EXIT
:
109 case ID_VIEW_REFRESH
:
118 ////////////////////////////////////////////////////////////////////////////////
120 // FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
122 // PURPOSE: Processes messages for the child windows.
124 // WM_COMMAND - process the application menu
125 // WM_PAINT - Paint the main window
126 // WM_DESTROY - post a quit message and return
129 LRESULT CALLBACK
ChildWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
131 static int last_split
;
132 // ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA);
133 static ChildWnd
* pChildWnd
;
137 pChildWnd
= (ChildWnd
*)((LPCREATESTRUCT
)lParam
)->lpCreateParams
;
139 pChildWnd
->nSplitPos
= 250;
140 pChildWnd
->hTreeWnd
= CreateTreeView(hWnd
, TREE_WINDOW
, &pChildWnd
->root
);
141 pChildWnd
->hListWnd
= CreateListView(hWnd
, LIST_WINDOW
, &pChildWnd
->root
);
144 if (!_CmdWndProc(hWnd
, message
, wParam
, lParam
)) {
145 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
152 if (LOWORD(lParam
) == HTCLIENT
) {
155 ScreenToClient(hWnd
, &pt
);
156 if (pt
.x
>=pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2 && pt
.x
<pChildWnd
->nSplitPos
+SPLIT_WIDTH
/2+1) {
157 SetCursor(LoadCursor(0, IDC_SIZEWE
));
167 case WM_LBUTTONDOWN
: {
169 int x
= LOWORD(lParam
);
170 GetClientRect(hWnd
, &rt
);
171 if (x
>=pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2 && x
<pChildWnd
->nSplitPos
+SPLIT_WIDTH
/2+1) {
172 last_split
= pChildWnd
->nSplitPos
;
173 #ifdef _NO_EXTENSIONS
174 draw_splitbar(hWnd
, last_split
);
181 if (GetCapture() == hWnd
) {
182 #ifdef _NO_EXTENSIONS
184 int x
= LOWORD(lParam
);
185 draw_splitbar(hWnd
, last_split
);
187 GetClientRect(hWnd
, &rt
);
188 pChildWnd
->nSplitPos
= x
;
189 ResizeWnd(pChildWnd
, rt
.right
, rt
.bottom
);
195 #ifdef _NO_EXTENSIONS
196 case WM_CAPTURECHANGED
:
197 if (GetCapture()==hWnd
&& last_split
>=0)
198 draw_splitbar(hWnd
, last_split
);
202 if (wParam
== VK_ESCAPE
)
203 if (GetCapture() == hWnd
) {
205 #ifdef _NO_EXTENSIONS
206 draw_splitbar(hWnd
, last_split
);
208 pChildWnd
->nSplitPos
= last_split
;
210 GetClientRect(hWnd
, &rt
);
211 ResizeWnd(pChildWnd
, rt
.right
, rt
.bottom
);
214 SetCursor(LoadCursor(0, IDC_ARROW
));
219 if (GetCapture() == hWnd
) {
221 int x
= LOWORD(lParam
);
222 #ifdef _NO_EXTENSIONS
223 HDC hdc
= GetDC(hWnd
);
224 GetClientRect(hWnd
, &rt
);
225 rt
.left
= last_split
-SPLIT_WIDTH
/2;
226 rt
.right
= last_split
+SPLIT_WIDTH
/2+1;
227 InvertRect(hdc
, &rt
);
229 rt
.left
= x
-SPLIT_WIDTH
/2;
230 rt
.right
= x
+SPLIT_WIDTH
/2+1;
231 InvertRect(hdc
, &rt
);
232 ReleaseDC(hWnd
, hdc
);
234 GetClientRect(hWnd
, &rt
);
235 if (x
>=0 && x
<rt
.right
) {
236 pChildWnd
->nSplitPos
= x
;
237 //resize_tree(pChildWnd, rt.right, rt.bottom);
238 rt
.left
= x
-SPLIT_WIDTH
/2;
239 rt
.right
= x
+SPLIT_WIDTH
/2+1;
240 InvalidateRect(hWnd
, &rt
, FALSE
);
241 UpdateWindow(hTreeWnd
);
243 UpdateWindow(hListWnd
);
249 #ifndef _NO_EXTENSIONS
250 case WM_GETMINMAXINFO
:
251 DefWindowProc(hWnd
, message
, wParam
, lParam
);
252 {LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lParam
;
253 lpmmi
->ptMaxTrackSize
.x
<<= 1;//2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN
254 lpmmi
->ptMaxTrackSize
.y
<<= 1;//2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN
259 // SetCurrentDirectory(szPath);
260 if (pChildWnd
!= NULL
) {
261 SetFocus(pChildWnd
->nFocusPanel
? pChildWnd
->hListWnd
: pChildWnd
->hTreeWnd
);
269 if ((int)wParam
== TREE_WINDOW
) {
270 if ((((LPNMHDR
)lParam
)->code
) == TVN_SELCHANGED
) {
271 Entry
* entry
= (Entry
*)((NMTREEVIEW
*)lParam
)->itemNew
.lParam
;
273 if (!entry
->scanned
) {
274 //scan_entry(pChildWnd, entry);
276 //RefreshList(pChildWnd->hListWnd, entry);
278 //RefreshList(pChildWnd->hListWnd, entry->down);
279 RefreshList(pChildWnd
->hListWnd
, entry
);
282 if (!SendMessage(pChildWnd
->hTreeWnd
, message
, wParam
, lParam
)) {
286 if ((int)wParam
== LIST_WINDOW
) {
287 if (!SendMessage(pChildWnd
->hListWnd
, message
, wParam
, lParam
)) {
294 if (wParam
!= SIZE_MINIMIZED
) {
295 OnSize(pChildWnd
, wParam
, lParam
);
299 return DefWindowProc(hWnd
, message
, wParam
, lParam
);