2 * ReactOS Application MDI Child Window
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
43 ////////////////////////////////////////////////////////////////////////////////
45 static void draw_splitbar(HWND hWnd
, int x
)
48 HDC hdc
= GetDC(hWnd
);
50 GetClientRect(hWnd
, &rt
);
51 rt
.left
= x
- SPLIT_WIDTH
/2;
52 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
57 static void OnPaint(HWND hWnd
, ChildWnd
* pChildWnd
)
61 GetClientRect(hWnd
, &rt
);
62 BeginPaint(hWnd
, &ps
);
64 // lastBrush = SelectObject(ps.hdc, (HBRUSH)GetStockObject(WHITE_BRUSH));
65 // Rectangle(ps.hdc, rt.left, rt.top-1, rt.right, rt.bottom+1);
66 // SelectObject(ps.hdc, lastBrush);
67 // rt.top = rt.bottom - GetSystemMetrics(SM_CYHSCROLL);
68 FillRect(ps
.hdc
, &rt
, GetStockObject(BLACK_BRUSH
));
70 rt.left = pChildWnd->nSplitPos-SPLIT_WIDTH/2;
71 rt.right = pChildWnd->nSplitPos+SPLIT_WIDTH/2+1;
72 lastBrush = SelectBrush(ps.hdc, (HBRUSH)GetStockObject(COLOR_SPLITBAR));
73 Rectangle(ps.hdc, rt.left, rt.top-1, rt.right, rt.bottom+1);
74 SelectObject(ps.hdc, lastBrush);
76 rt.top = rt.bottom - GetSystemMetrics(SM_CYHSCROLL);
77 FillRect(ps.hdc, &rt, GetStockObject(BLACK_BRUSH));
84 static void OnSize(ChildWnd
* pChildWnd
, WPARAM wParam
, LPARAM lParam
)
86 if (wParam
!= SIZE_MINIMIZED
) {
87 //resize_tree(pChildWnd, LOWORD(lParam), HIWORD(lParam));
92 // FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
94 // PURPOSE: Processes messages for the child windows.
96 // WM_COMMAND - process the application menu
97 // WM_PAINT - Paint the main window
98 // WM_DESTROY - post a quit message and return
101 LRESULT CALLBACK
ChildWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
103 static int last_split
;
104 ChildWnd
* pChildWnd
= (ChildWnd
*)GetWindowLong(hWnd
, GWL_USERDATA
);
112 case WM_MDIACTIVATE
: // set an alternate menu here
113 if (lParam
== (LPARAM
)hWnd
) {
116 DrawMenuBar(hFrameWnd
);
121 OnPaint(hWnd
, pChildWnd
);
125 //SetWindowLong(hWnd, GWL_USERDATA, 0);
129 if (LOWORD(lParam
) == HTCLIENT
) {
132 ScreenToClient(hWnd
, &pt
);
134 if (pt
.x
>=pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2 && pt
.x
<pChildWnd
->nSplitPos
+SPLIT_WIDTH
/2+1) {
135 SetCursor(LoadCursor(0, IDC_SIZEWE
));
142 case WM_LBUTTONDOWN
: {
144 int x
= LOWORD(lParam
);
145 GetClientRect(hWnd
, &rt
);
146 if (x
>=pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2 && x
<pChildWnd
->nSplitPos
+SPLIT_WIDTH
/2+1) {
147 last_split
= pChildWnd
->nSplitPos
;
148 #ifdef _NO_EXTENSIONS
149 draw_splitbar(hWnd
, last_split
);
156 if (GetCapture() == hWnd
) {
157 #ifdef _NO_EXTENSIONS
159 int x
= LOWORD(lParam
);
160 draw_splitbar(hWnd
, last_split
);
162 GetClientRect(hWnd
, &rt
);
163 pChildWnd
->nSplitPos
= x
;
164 //resize_tree(pChildWnd, rt.right, rt.bottom);
170 #ifdef _NO_EXTENSIONS
171 case WM_CAPTURECHANGED
:
172 if (GetCapture()==hWnd
&& last_split
>=0)
173 draw_splitbar(hWnd
, last_split
);
177 if (wParam
== VK_ESCAPE
)
178 if (GetCapture() == hWnd
) {
180 #ifdef _NO_EXTENSIONS
181 draw_splitbar(hWnd
, last_split
);
183 pChildWnd
->nSplitPos
= last_split
;
185 GetClientRect(hWnd
, &rt
);
186 //resize_tree(pChildWnd, rt.right, rt.bottom);
189 SetCursor(LoadCursor(0, IDC_ARROW
));
194 if (GetCapture() == hWnd
) {
196 int x
= LOWORD(lParam
);
197 #ifdef _NO_EXTENSIONS
198 HDC hdc
= GetDC(hWnd
);
199 GetClientRect(hWnd
, &rt
);
200 rt
.left
= last_split
-SPLIT_WIDTH
/2;
201 rt
.right
= last_split
+SPLIT_WIDTH
/2+1;
202 InvertRect(hdc
, &rt
);
204 rt
.left
= x
-SPLIT_WIDTH
/2;
205 rt
.right
= x
+SPLIT_WIDTH
/2+1;
206 InvertRect(hdc
, &rt
);
207 ReleaseDC(hWnd
, hdc
);
209 GetClientRect(hWnd
, &rt
);
210 if (x
>=0 && x
<rt
.right
) {
211 pChildWnd
->nSplitPos
= x
;
212 resize_tree(pChildWnd
, rt
.right
, rt
.bottom
);
213 rt
.left
= x
-SPLIT_WIDTH
/2;
214 rt
.right
= x
+SPLIT_WIDTH
/2+1;
215 InvalidateRect(hWnd
, &rt
, FALSE
);
216 UpdateWindow(pChildWnd
->left
.hWnd
);
218 UpdateWindow(pChildWnd
->right
.hWnd
);
224 #ifndef _NO_EXTENSIONS
225 case WM_GETMINMAXINFO
:
226 DefMDIChildProc(hWnd
, message
, wParam
, lParam
);
227 {LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lParam
;
228 lpmmi
->ptMaxTrackSize
.x
<<= 1;//2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN
229 lpmmi
->ptMaxTrackSize
.y
<<= 1;//2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN
234 SetCurrentDirectory(pChildWnd
->szPath
);
235 SetFocus(pChildWnd
->nFocusPanel
? pChildWnd
->hRightWnd
: pChildWnd
->hLeftWnd
);
239 pane = GetFocus()==pChildWnd->left.hWnd? &pChildWnd->left: &pChildWnd->right;
240 switch(LOWORD(wParam)) {
241 case ID_WINDOW_NEW_WINDOW:
244 return pane_command(pane, LOWORD(wParam));
250 if (wParam
!= SIZE_MINIMIZED
) {
251 OnSize(pChildWnd
, wParam
, lParam
);
255 return DefMDIChildProc(hWnd
, message
, wParam
, lParam
);
257 return DefMDIChildProc(hWnd
, message
, wParam
, lParam
);