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
54 //#define COLOR_SPLITBAR WHITE_BRUSH
55 #define COLOR_SPLITBAR LTGRAY_BRUSH
57 #define COLOR_SPLITBAR LTGRAY_BRUSH
60 ////////////////////////////////////////////////////////////////////////////////
65 ////////////////////////////////////////////////////////////////////////////////
66 // Local module support methods
69 static BOOL
pane_command(Pane
* pane
, UINT cmd
)
73 if (pane
->visible_cols
) {
74 pane
->visible_cols
= 0;
75 calc_widths(pane
, TRUE
);
76 #ifndef _NO_EXTENSIONS
79 InvalidateRect(pane
->hWnd
, 0, TRUE
);
80 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
|MF_CHECKED
);
81 // CheckMenuItem(Globals.hMenuView, ID_VIEW_ALL_ATTRIBUTES, MF_BYCOMMAND);
82 // CheckMenuItem(Globals.hMenuView, ID_VIEW_SELECTED_ATTRIBUTES, MF_BYCOMMAND);
86 case ID_VIEW_ALL_ATTRIBUTES
:
87 if (pane
->visible_cols
!= COL_ALL
) {
88 pane
->visible_cols
= COL_ALL
;
89 calc_widths(pane
, TRUE
);
90 InvalidateRect(pane
->hWnd
, 0, TRUE
);
91 CheckMenuItem(Globals
.hMenuView
, ID_VIEW_NAME
, MF_BYCOMMAND
);
92 // CheckMenuItem(Globals.hMenuView, ID_VIEW_ALL_ATTRIBUTES, MF_BYCOMMAND|MF_CHECKED);
93 // CheckMenuItem(Globals.hMenuView, ID_VIEW_SELECTED_ATTRIBUTES, MF_BYCOMMAND);
97 // TODO: more command ids...
104 static void draw_splitbar(HWND hWnd
, int x
)
107 HDC hdc
= GetDC(hWnd
);
109 GetClientRect(hWnd
, &rt
);
110 rt
.left
= x
- SPLIT_WIDTH
/2;
111 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
112 InvertRect(hdc
, &rt
);
113 ReleaseDC(hWnd
, hdc
);
116 static void ResizeWnd(ChildWnd
* pChildWnd
, int cx
, int cy
)
118 HDWP hdwp
= BeginDeferWindowPos(2);
119 RECT rt
= {0, 0, cx
, cy
};
121 cx
= pChildWnd
->nSplitPos
+ SPLIT_WIDTH
/2;
122 DeferWindowPos(hdwp
, pChildWnd
->left
.hWnd
, 0, rt
.left
, rt
.top
, pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2-rt
.left
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
123 DeferWindowPos(hdwp
, pChildWnd
->right
.hWnd
, 0, rt
.left
+cx
+1, rt
.top
, rt
.right
-cx
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
124 EndDeferWindowPos(hdwp
);
127 static void OnSize(ChildWnd
* pChildWnd
, WPARAM wParam
, LPARAM lParam
)
129 if (wParam
!= SIZE_MINIMIZED
) {
130 ResizeWnd(pChildWnd
, LOWORD(lParam
), HIWORD(lParam
));
134 void OnFileMove(HWND hWnd
)
136 struct ExecuteDialog dlg
= {{0}};
137 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_DIALOG_FILE_MOVE
), hWnd
, MoveFileWndProc
, (LPARAM
)&dlg
) == IDOK
) {
141 static void OnPaint(HWND hWnd
, ChildWnd
* pChildWnd
)
147 BeginPaint(hWnd
, &ps
);
148 GetClientRect(hWnd
, &rt
);
149 lastBrush
= SelectObject(ps
.hdc
, (HBRUSH
)GetStockObject(COLOR_SPLITBAR
));
150 Rectangle(ps
.hdc
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
151 SelectObject(ps
.hdc
, lastBrush
);
152 // rt.top = rt.bottom - GetSystemMetrics(SM_CYHSCROLL);
153 // FillRect(ps.hdc, &rt, GetStockObject(BLACK_BRUSH));
157 ////////////////////////////////////////////////////////////////////////////////
159 // FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
161 // PURPOSE: Processes WM_COMMAND messages for the main frame window.
165 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
167 //UINT cmd = LOWORD(wParam);
170 switch (LOWORD(wParam
)) {
171 // Parse the menu selections:
173 // case ID_FILE_MOVE:
177 case ID_FILE_COPY_CLIPBOARD:
180 case ID_FILE_PROPERTIES:
181 case ID_FILE_COMPRESS:
182 case ID_FILE_UNCOMPRESS:
188 case ID_FILE_ASSOCIATE:
189 case ID_FILE_CREATE_DIRECTORY:
191 case ID_FILE_SELECT_FILES:
195 SendMessage(hWnd
, WM_CLOSE
, 0, 0);
198 case ID_DISK_COPY_DISK:
200 case ID_DISK_LABEL_DISK:
202 case ID_DISK_CONNECT_NETWORK_DRIVE:
203 MapNetworkDrives(hWnd, TRUE);
205 case ID_DISK_DISCONNECT_NETWORK_DRIVE:
206 MapNetworkDrives(hWnd, FALSE);
208 case ID_DISK_SHARE_AS:
210 case ID_DISK_STOP_SHARING:
212 case ID_DISK_SELECT_DRIVE:
216 case ID_TREE_EXPAND_ONE_LEVEL:
217 case ID_TREE_EXPAND_ALL:
218 case ID_TREE_EXPAND_BRANCH:
219 case ID_TREE_COLLAPSE_BRANCH:
223 case ID_VIEW_BY_FILE_TYPE
:
225 struct ExecuteDialog dlg
= {{0}};
226 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_DIALOG_VIEW_TYPE
), hWnd
, ViewFileTypeWndProc
, (LPARAM
)&dlg
) == IDOK
) {
230 case ID_OPTIONS_CONFIRMATION
:
232 struct ExecuteDialog dlg
= {{0}};
233 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_DIALOG_OPTIONS_CONFIRMATON
), hWnd
, OptionsConfirmationWndProc
, (LPARAM
)&dlg
) == IDOK
) {
237 case ID_WINDOW_NEW_WINDOW
:
238 CreateChildWindow(-1);
240 // ChildWnd* pChildWnd = alloc_child_window(path);
241 // if (!create_child_window(pChildWnd))
246 // return DefMDIChildProc(hWnd, message, wParam, lParam);
253 ////////////////////////////////////////////////////////////////////////////////
255 // FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
257 // PURPOSE: Processes messages for the child windows.
259 // WM_COMMAND - process the application menu
260 // WM_PAINT - Paint the main window
261 // WM_DESTROY - post a quit message and return
264 LRESULT CALLBACK
ChildWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
266 static int last_split
;
268 ChildWnd
* pChildWnd
= (ChildWnd
*)GetWindowLong(hWnd
, GWL_USERDATA
);
273 CreateTreeWnd(pChildWnd
->hWnd
, &pChildWnd
->left
, IDW_TREE_LEFT
);
274 CreateListWnd(pChildWnd
->hWnd
, &pChildWnd
->right
, IDW_TREE_RIGHT
, pChildWnd
->szPath
);
275 //create_tree_window(pChildWnd->hWnd, &pChildWnd->left, IDW_TREE_LEFT, IDW_HEADER_LEFT, pChildWnd->szPath);
276 //create_list_window(pChildWnd->hWnd, &pChildWnd->right, IDW_TREE_RIGHT, IDW_HEADER_RIGHT);
280 OnPaint(hWnd
, pChildWnd
);
283 // free_child_window(pChildWnd);
284 SetWindowLong(hWnd
, GWL_USERDATA
, 0);
287 if (LOWORD(lParam
) == HTCLIENT
) {
290 ScreenToClient(hWnd
, &pt
);
291 if (pt
.x
>=pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2 && pt
.x
<pChildWnd
->nSplitPos
+SPLIT_WIDTH
/2+1) {
292 SetCursor(LoadCursor(0, IDC_SIZEWE
));
297 case WM_LBUTTONDOWN
: {
299 int x
= LOWORD(lParam
);
300 GetClientRect(hWnd
, &rt
);
301 if (x
>=pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2 && x
<pChildWnd
->nSplitPos
+SPLIT_WIDTH
/2+1) {
302 last_split
= pChildWnd
->nSplitPos
;
303 draw_splitbar(hWnd
, last_split
);
309 if (GetCapture() == hWnd
) {
311 int x
= LOWORD(lParam
);
312 draw_splitbar(hWnd
, last_split
);
314 GetClientRect(hWnd
, &rt
);
315 pChildWnd
->nSplitPos
= x
;
316 ResizeWnd(pChildWnd
, rt
.right
, rt
.bottom
);
321 case WM_CAPTURECHANGED
:
322 if (GetCapture()==hWnd
&& last_split
>=0)
323 draw_splitbar(hWnd
, last_split
);
327 if (wParam
== VK_ESCAPE
)
328 if (GetCapture() == hWnd
) {
330 draw_splitbar(hWnd
, last_split
);
331 GetClientRect(hWnd
, &rt
);
332 ResizeWnd(pChildWnd
, rt
.right
, rt
.bottom
);
335 SetCursor(LoadCursor(0, IDC_ARROW
));
340 if (GetCapture() == hWnd
) {
342 int x
= LOWORD(lParam
);
343 HDC hdc
= GetDC(hWnd
);
344 GetClientRect(hWnd
, &rt
);
345 rt
.left
= last_split
-SPLIT_WIDTH
/2;
346 rt
.right
= last_split
+SPLIT_WIDTH
/2+1;
347 InvertRect(hdc
, &rt
);
349 rt
.left
= x
-SPLIT_WIDTH
/2;
350 rt
.right
= x
+SPLIT_WIDTH
/2+1;
351 InvertRect(hdc
, &rt
);
352 ReleaseDC(hWnd
, hdc
);
357 SetCurrentDirectory(pChildWnd
->szPath
);
358 SetFocus(pChildWnd
->nFocusPanel
? pChildWnd
->right
.hWnd
: pChildWnd
->left
.hWnd
);
361 case WM_DISPATCH_COMMAND
:
362 if (_CmdWndProc(hWnd
, message
, wParam
, lParam
)) break;
364 return SendMessage(pChildWnd
->right
.hWnd
, message
, wParam
, lParam
);
366 return SendMessage(pChildWnd
->left
.hWnd
, message
, wParam
, lParam
);
371 if (_CmdWndProc(hWnd
, message
, wParam
, lParam
)) break;
372 return DefMDIChildProc(hWnd
, message
, wParam
, lParam
);
374 // if (LOWORD(wParam) > ID_CMD_FIRST && LOWORD(wParam) < ID_CMD_LAST) {
375 // if (!SendMessage(pChildWnd->right.hWnd, message, wParam, lParam)) {
376 // return DefMDIChildProc(hWnd, message, wParam, lParam);
379 // return _CmdWndProc(hWnd, message, wParam, lParam);
384 int idCtrl
= (int)wParam
;
385 //NMHDR* pnmh = (NMHDR*)lParam;
386 //return pane_notify(pnmh->idFrom==IDW_HEADER_LEFT? &pChildWnd->left: &pChildWnd->right, pnmh);
387 if ((int)wParam
== IDW_TREE_LEFT
) {
388 if ((((LPNMHDR
)lParam
)->code
) == TVN_SELCHANGED
) {
389 Entry
* entry
= (Entry
*)((NMTREEVIEW
*)lParam
)->itemNew
.lParam
;
391 //RefreshList(pChildWnd->right.hWnd, entry);
392 //void set_curdir(ChildWnd* child, Entry* entry)
393 set_curdir(pChildWnd
, entry
);
396 if (!SendMessage(pChildWnd
->left
.hWnd
, message
, wParam
, lParam
)) {
397 return DefMDIChildProc(hWnd
, message
, wParam
, lParam
);
400 if ((int)wParam
== IDW_TREE_RIGHT
) {
401 if (!SendMessage(pChildWnd
->right
.hWnd
, message
, wParam
, lParam
)) {
402 return DefMDIChildProc(hWnd
, message
, wParam
, lParam
);
409 if (wParam
!= SIZE_MINIMIZED
&& pChildWnd
!= NULL
) {
410 ResizeWnd(pChildWnd
, LOWORD(lParam
), HIWORD(lParam
));
414 return DefMDIChildProc(hWnd
, message
, wParam
, lParam
);
419 ATOM
RegisterChildWnd(HINSTANCE hInstance
, int res_id
)
421 WNDCLASSEX wcFrame
= {
423 CS_HREDRAW
| CS_VREDRAW
/*style*/,
428 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_WINFILE
)),
429 LoadCursor(0, IDC_ARROW
),
433 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_WINFILE
), IMAGE_ICON
,
434 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
436 ATOM hFrameWndClass
= RegisterClassEx(&wcFrame
); // register frame window class
437 return hFrameWndClass
;