468aeb84ab0a7caca0942b34c1d9273a1b367012
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
41 ////////////////////////////////////////////////////////////////////////////////
42 // Global and Local Variables:
45 static BOOL bInMenuLoop
= FALSE
; // Tells us if we are in the menu loop
47 static HWND hChildWnd
;
49 ////////////////////////////////////////////////////////////////////////////////
50 // Local module support methods
53 static void resize_frame_rect(HWND hWnd
, PRECT prect
)
57 if (IsWindowVisible(hToolBar)) {
58 SendMessage(hToolBar, WM_SIZE, 0, 0);
59 GetClientRect(hToolBar, &rt);
60 prect->top = rt.bottom+3;
61 prect->bottom -= rt.bottom+3;
64 if (IsWindowVisible(hStatusBar
)) {
65 SetupStatusBar(hWnd
, TRUE
);
66 GetClientRect(hStatusBar
, &rt
);
67 prect
->bottom
-= rt
.bottom
;
69 MoveWindow(hChildWnd
, prect
->left
, prect
->top
, prect
->right
, prect
->bottom
, TRUE
);
72 void resize_frame_client(HWND hWnd
)
76 GetClientRect(hWnd
, &rect
);
77 resize_frame_rect(hWnd
, &rect
);
80 ////////////////////////////////////////////////////////////////////////////////
82 static void OnEnterMenuLoop(HWND hWnd
)
86 // Update the status bar pane sizes
88 SendMessage(hStatusBar
, SB_SETPARTS
, 1, (long)&nParts
);
90 SendMessage(hStatusBar
, SB_SETTEXT
, (WPARAM
)0, (LPARAM
)_T(""));
93 static void OnExitMenuLoop(HWND hWnd
)
96 // Update the status bar pane sizes
97 SetupStatusBar(hWnd
, TRUE
);
101 static void OnMenuSelect(HWND hWnd
, UINT nItemID
, UINT nFlags
, HMENU hSysMenu
)
105 _tcscpy(str
, _T(""));
106 if (nFlags
& MF_POPUP
) {
107 if (hSysMenu
!= GetMenu(hWnd
)) {
108 if (nItemID
== 2) nItemID
= 5;
111 if (LoadString(hInst
, nItemID
, str
, 100)) {
112 // load appropriate string
114 // first newline terminates actual string
115 lpsz
= _tcschr(lpsz
, '\n');
119 SendMessage(hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)str
);
122 void SetupStatusBar(HWND hWnd
, BOOL bResize
)
126 GetClientRect(hWnd
, &rc
);
130 SendMessage(hStatusBar
, WM_SIZE
, 0, 0);
131 SendMessage(hStatusBar
, SB_SETPARTS
, 1, (LPARAM
)&nParts
);
134 void UpdateStatusBar(void)
139 size
= sizeof(text
)/sizeof(TCHAR
);
140 GetComputerName(text
, &size
);
141 SendMessage(hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)text
);
144 static void toggle_child(HWND hWnd
, UINT cmd
, HWND hchild
)
146 BOOL vis
= IsWindowVisible(hchild
);
147 HMENU hMenuView
= GetSubMenu(hMenuFrame
, ID_VIEW_MENU
);
149 CheckMenuItem(hMenuView
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
150 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
151 resize_frame_client(hWnd
);
154 ////////////////////////////////////////////////////////////////////////////////
156 // FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
158 // PURPOSE: Processes WM_COMMAND messages for the main frame window.
162 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
164 switch (LOWORD(wParam
)) {
165 // Parse the menu selections:
166 case ID_REGISTRY_PRINTERSETUP
:
170 //PageSetupDlg(&psd);
172 case ID_REGISTRY_OPENLOCAL
:
174 case ID_REGISTRY_EXIT
:
177 case ID_VIEW_REFRESH
:
180 // case ID_OPTIONS_TOOLBAR:
181 // toggle_child(hWnd, LOWORD(wParam), hToolBar);
183 case ID_VIEW_STATUSBAR
:
184 toggle_child(hWnd
, LOWORD(wParam
), hStatusBar
);
186 case ID_HELP_HELPTOPICS
:
187 // WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);
188 WinHelp(hWnd
, _T("regedit"), HELP_FINDER
, 0);
192 ShellAbout(hWnd
, szTitle
, _T(""), LoadIcon(hInst
, (LPCTSTR
)IDI_REGEDIT
));
203 ////////////////////////////////////////////////////////////////////////////////
205 // FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
207 // PURPOSE: Processes messages for the main frame window.
209 // WM_COMMAND - process the application menu
210 // WM_DESTROY - post a quit message and return
214 LRESULT CALLBACK
FrameWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
216 static ChildWnd
* pChildWnd
= NULL
;
221 pChildWnd
= malloc(sizeof(ChildWnd
));
222 _tcsncpy(pChildWnd
->szPath
, _T("My Computer"), MAX_PATH
);
223 hChildWnd
= CreateWindowEx(0, szChildClass
, _T("regedit child window"),
224 // WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,
225 WS_CHILD
|WS_VISIBLE
| WS_EX_CLIENTEDGE
,
226 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
227 hWnd
, (HMENU
)0, hInst
, pChildWnd
);
231 if (!_CmdWndProc(hWnd
, message
, wParam
, lParam
)) {
232 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
236 resize_frame_client(hWnd
);
240 case WM_ENTERMENULOOP
:
241 OnEnterMenuLoop(hWnd
);
243 case WM_EXITMENULOOP
:
244 OnExitMenuLoop(hWnd
);
247 OnMenuSelect(hWnd
, LOWORD(wParam
), HIWORD(wParam
), (HMENU
)lParam
);
254 WinHelp(hWnd
, _T("regedit"), HELP_QUIT
, 0);
257 return DefWindowProc(hWnd
, message
, wParam
, lParam
);