fc8918fbfc0feaafb299c8a44b251b6485b87f3a
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library 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 GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
43 ////////////////////////////////////////////////////////////////////////////////
44 // Local module support methods
47 static void MakeFullRegPath(HWND hwndTV
, HTREEITEM hItem
, LPTSTR keyPath
, int* pPathLen
, int max
)
50 item
.mask
= TVIF_PARAM
;
52 if (TreeView_GetItem(hwndTV
, &item
)) {
53 if (item
.hItem
!= TreeView_GetRoot(hwndTV
)) {
55 MakeFullRegPath(hwndTV
, TreeView_GetParent(hwndTV
, hItem
), keyPath
, pPathLen
, max
);
56 keyPath
[*pPathLen
] = _T('\\');
59 item
.mask
= TVIF_TEXT
;
61 item
.pszText
= &keyPath
[*pPathLen
];
62 item
.cchTextMax
= max
- *pPathLen
;
63 if (TreeView_GetItem(hwndTV
, &item
)) {
64 *pPathLen
+= _tcslen(item
.pszText
);
69 static void draw_splitbar(HWND hWnd
, int x
)
72 HDC hdc
= GetDC(hWnd
);
74 GetClientRect(hWnd
, &rt
);
75 rt
.left
= x
- SPLIT_WIDTH
/2;
76 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
81 static void ResizeWnd(ChildWnd
* pChildWnd
, int cx
, int cy
)
83 HDWP hdwp
= BeginDeferWindowPos(2);
84 RECT rt
= {0, 0, cx
, cy
};
86 cx
= pChildWnd
->nSplitPos
+ SPLIT_WIDTH
/2;
87 DeferWindowPos(hdwp
, pChildWnd
->hTreeWnd
, 0, rt
.left
, rt
.top
, pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2-rt
.left
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
88 DeferWindowPos(hdwp
, pChildWnd
->hListWnd
, 0, rt
.left
+cx
, rt
.top
, rt
.right
-cx
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
89 EndDeferWindowPos(hdwp
);
92 static void OnPaint(HWND hWnd
)
98 GetClientRect(hWnd
, &rt
);
99 hdc
= BeginPaint(hWnd
, &ps
);
100 FillRect(ps
.hdc
, &rt
, GetStockObject(LTGRAY_BRUSH
));
104 ////////////////////////////////////////////////////////////////////////////////
106 // FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
108 // PURPOSE: Processes WM_COMMAND messages for the main frame window.
112 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
114 switch (LOWORD(wParam
)) {
115 // Parse the menu selections:
116 case ID_REGISTRY_EXIT
:
119 case ID_VIEW_REFRESH
:
128 ////////////////////////////////////////////////////////////////////////////////
130 // FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
132 // PURPOSE: Processes messages for the child windows.
134 // WM_COMMAND - process the application menu
135 // WM_PAINT - Paint the main window
136 // WM_DESTROY - post a quit message and return
139 LRESULT CALLBACK
ChildWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
141 static int last_split
;
142 // ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA);
143 static ChildWnd
* pChildWnd
;
147 pChildWnd
= (ChildWnd
*)((LPCREATESTRUCT
)lParam
)->lpCreateParams
;
149 pChildWnd
->nSplitPos
= 250;
150 pChildWnd
->hTreeWnd
= CreateTreeView(hWnd
, pChildWnd
->szPath
, TREE_WINDOW
);
151 pChildWnd
->hListWnd
= CreateListView(hWnd
, LIST_WINDOW
/*, pChildWnd->szPath*/);
154 if (!_CmdWndProc(hWnd
, message
, wParam
, lParam
)) {
162 if (LOWORD(lParam
) == HTCLIENT
) {
165 ScreenToClient(hWnd
, &pt
);
166 if (pt
.x
>=pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2 && pt
.x
<pChildWnd
->nSplitPos
+SPLIT_WIDTH
/2+1) {
167 SetCursor(LoadCursor(0, IDC_SIZEWE
));
175 case WM_LBUTTONDOWN
: {
177 int x
= LOWORD(lParam
);
178 GetClientRect(hWnd
, &rt
);
179 if (x
>=pChildWnd
->nSplitPos
-SPLIT_WIDTH
/2 && x
<pChildWnd
->nSplitPos
+SPLIT_WIDTH
/2+1) {
180 last_split
= pChildWnd
->nSplitPos
;
181 draw_splitbar(hWnd
, last_split
);
187 if (GetCapture() == hWnd
) {
189 int x
= LOWORD(lParam
);
190 draw_splitbar(hWnd
, last_split
);
192 GetClientRect(hWnd
, &rt
);
193 pChildWnd
->nSplitPos
= x
;
194 ResizeWnd(pChildWnd
, rt
.right
, rt
.bottom
);
199 case WM_CAPTURECHANGED
:
200 if (GetCapture()==hWnd
&& last_split
>=0)
201 draw_splitbar(hWnd
, last_split
);
205 if (wParam
== VK_ESCAPE
)
206 if (GetCapture() == hWnd
) {
208 draw_splitbar(hWnd
, last_split
);
209 GetClientRect(hWnd
, &rt
);
210 ResizeWnd(pChildWnd
, rt
.right
, rt
.bottom
);
213 SetCursor(LoadCursor(0, IDC_ARROW
));
218 if (GetCapture() == hWnd
) {
220 int x
= LOWORD(lParam
);
221 HDC hdc
= GetDC(hWnd
);
222 GetClientRect(hWnd
, &rt
);
223 rt
.left
= last_split
-SPLIT_WIDTH
/2;
224 rt
.right
= last_split
+SPLIT_WIDTH
/2+1;
225 InvertRect(hdc
, &rt
);
227 rt
.left
= x
-SPLIT_WIDTH
/2;
228 rt
.right
= x
+SPLIT_WIDTH
/2+1;
229 InvertRect(hdc
, &rt
);
230 ReleaseDC(hWnd
, hdc
);
235 if (pChildWnd
!= NULL
) {
236 SetFocus(pChildWnd
->nFocusPanel
? pChildWnd
->hListWnd
: pChildWnd
->hTreeWnd
);
244 if ((int)wParam
== TREE_WINDOW
) {
245 switch (((LPNMHDR
)lParam
)->code
) {
246 case TVN_ITEMEXPANDING
:
247 return !OnTreeExpanding(pChildWnd
->hTreeWnd
, (NMTREEVIEW
*)lParam
);
253 keyPath
[0] = _T('\0');
254 hKey
= FindRegRoot(pChildWnd
->hTreeWnd
, ((NMTREEVIEW
*)lParam
)->itemNew
.hItem
, keyPath
, &keyPathLen
, sizeof(keyPath
)/sizeof(TCHAR
));
255 RefreshListView(pChildWnd
->hListWnd
, hKey
, keyPath
);
258 keyPath
[0] = _T('\0');
259 MakeFullRegPath(pChildWnd
->hTreeWnd
, ((NMTREEVIEW
*)lParam
)->itemNew
.hItem
, keyPath
, &keyPathLen
, sizeof(keyPath
)/sizeof(TCHAR
));
260 SendMessage(hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)keyPath
);
267 if ((int)wParam
== LIST_WINDOW
) {
268 if (!SendMessage(pChildWnd
->hListWnd
, message
, wParam
, lParam
)) {
275 if (wParam
!= SIZE_MINIMIZED
&& pChildWnd
!= NULL
) {
276 ResizeWnd(pChildWnd
, LOWORD(lParam
), HIWORD(lParam
));
280 return DefWindowProc(hWnd
, message
, wParam
, lParam
);