Updated with latest progress. How does one read a default registry value???
[reactos.git] / rosapps / regedt32 / framewnd.c
1 /*
2 * ReactOS regedt32
3 *
4 * framewnd.c
5 *
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
7 *
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.
12 *
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.
17 *
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.
21 */
22
23 #ifdef _MSC_VER
24 #include "stdafx.h"
25 #else
26 //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
27 #include <windows.h>
28 #include <commctrl.h>
29 #include <stdlib.h>
30 #include <malloc.h>
31 #include <memory.h>
32 #include <tchar.h>
33 #include <process.h>
34 #include <stdio.h>
35 #endif
36
37 #include <shellapi.h>
38
39 #include "main.h"
40 #include "framewnd.h"
41
42
43 ////////////////////////////////////////////////////////////////////////////////
44 // Global and Local Variables:
45 //
46
47 enum OPTION_FLAGS Options;
48 BOOL bInMenuLoop = FALSE; // Tells us if we are in the menu loop
49
50 static HHOOK hcbthook;
51 static ChildWnd* newchild = NULL;
52
53
54 ////////////////////////////////////////////////////////////////////////////////
55 // Local module support methods
56 //
57
58 static void resize_frame_rect(HWND hWnd, PRECT prect)
59 {
60 RECT rt;
61 /*
62 if (IsWindowVisible(hToolBar)) {
63 SendMessage(hToolBar, WM_SIZE, 0, 0);
64 GetClientRect(hToolBar, &rt);
65 prect->top = rt.bottom+3;
66 prect->bottom -= rt.bottom+3;
67 }
68 */
69 if (IsWindowVisible(hStatusBar)) {
70 SetupStatusBar(hWnd, TRUE);
71 GetClientRect(hStatusBar, &rt);
72 prect->bottom -= rt.bottom;
73 }
74 MoveWindow(hMDIClient, prect->left,prect->top,prect->right,prect->bottom, TRUE);
75 }
76
77 static void resize_frame(HWND hWnd, int cx, int cy)
78 {
79 RECT rect = {0, 0, cx, cy};
80
81 resize_frame_rect(hWnd, &rect);
82 }
83
84 void resize_frame_client(HWND hWnd)
85 {
86 RECT rect;
87
88 GetClientRect(hWnd, &rect);
89 resize_frame_rect(hWnd, &rect);
90 }
91
92 ////////////////////////////////////////////////////////////////////////////////
93
94 static LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam)
95 {
96 if (code == HCBT_CREATEWND && newchild) {
97 ChildWnd* pChildWnd = newchild;
98 newchild = NULL;
99 pChildWnd->hWnd = (HWND)wParam;
100 SetWindowLong(pChildWnd->hWnd, GWL_USERDATA, (LPARAM)pChildWnd);
101 }
102 return CallNextHookEx(hcbthook, code, wParam, lParam);
103 }
104
105 static ChildWnd* alloc_child_window(LPCTSTR szKeyName, HKEY hKey)
106 {
107 ChildWnd* pChildWnd = (ChildWnd*)malloc(sizeof(ChildWnd));
108
109 memset(pChildWnd, 0, sizeof(ChildWnd));
110 pChildWnd->pos.length = sizeof(WINDOWPLACEMENT);
111 pChildWnd->pos.flags = 0;
112 pChildWnd->pos.showCmd = SW_SHOWNORMAL;
113 pChildWnd->pos.rcNormalPosition.left = CW_USEDEFAULT;
114 pChildWnd->pos.rcNormalPosition.top = CW_USEDEFAULT;
115 pChildWnd->pos.rcNormalPosition.right = CW_USEDEFAULT;
116 pChildWnd->pos.rcNormalPosition.bottom = CW_USEDEFAULT;
117 pChildWnd->nFocusPanel = 0;
118 pChildWnd->nSplitPos = 300;
119 // pChildWnd->visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES;
120 // pChildWnd->sortOrder = SORT_NAME;
121 // pChildWnd->header_wdths_ok = FALSE;
122 lstrcpy(pChildWnd->szKeyName, szKeyName); // MAX_PATH
123 pChildWnd->hKey = hKey;
124 return pChildWnd;
125 }
126
127 static HWND CreateChildWindow(HWND hWnd, LPCTSTR szKeyName, HKEY hKey, int unused)
128 {
129 ChildWnd* pChildWnd = alloc_child_window(szKeyName, hKey);
130 if (pChildWnd != NULL) {
131 MDICREATESTRUCT mcs = { szChildClass, szKeyName, hInst,
132 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
133 0/*style*/, (LPARAM)hKey/*lParam*/};
134 hcbthook = SetWindowsHookEx(WH_CBT, CBTProc, 0, GetCurrentThreadId());
135 newchild = pChildWnd;
136 pChildWnd->hWnd = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LPARAM)&mcs);
137 UnhookWindowsHookEx(hcbthook);
138 if (pChildWnd->hWnd != NULL) {
139 return pChildWnd->hWnd;
140 } else {
141 free(pChildWnd);
142 newchild = pChildWnd = NULL;
143 }
144 }
145 return 0;
146 }
147
148 void CreateClientChildren(HWND hWnd)
149 {
150 CreateChildWindow(hWnd, _T("HKEY_CLASSES_ROOT"), HKEY_CLASSES_ROOT, 1);
151 CreateChildWindow(hWnd, _T("HKEY_CURRENT_USER"), HKEY_CURRENT_USER, 1);
152 CreateChildWindow(hWnd, _T("HKEY_LOCAL_MACHINE"), HKEY_LOCAL_MACHINE, 1);
153 CreateChildWindow(hWnd, _T("HKEY_USERS"), HKEY_USERS, 1);
154 CreateChildWindow(hWnd, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1);
155 PostMessage(hMDIClient, WM_MDICASCADE, 0, 0);
156 }
157
158
159 static BOOL CALLBACK CloseEnumProc(HWND hWnd, LPARAM lParam)
160 {
161 if (!GetWindow(hWnd, GW_OWNER)) {
162 SendMessage(GetParent(hWnd), WM_MDIRESTORE, (WPARAM)hWnd, 0);
163 if (SendMessage(hWnd, WM_QUERYENDSESSION, 0, 0)) {
164 SendMessage(GetParent(hWnd), WM_MDIDESTROY, (WPARAM)hWnd, 0);
165 }
166 }
167 return 1;
168 }
169 /*
170 UINT_PTR CALLBACK CFHookProc(
171 HWND hdlg, // handle to dialog box
172 UINT uiMsg, // message identifier
173 WPARAM wParam, // message parameter
174 LPARAM lParam // message parameter
175 );
176
177 typedef UINT_PTR (CALLBACK *LPCFHOOKPROC)(HWND, UINT, WPARAM, LPARAM);
178
179 typedef struct {
180 DWORD lStructSize;
181 HWND hwndOwner;
182 HDC hDC;
183 LPLOGFONT lpLogFont;
184 INT iPointSize;
185 DWORD Flags;
186 COLORREF rgbColors;
187 LPARAM lCustData;
188 LPCFHOOKPROC lpfnHook;
189 LPCTSTR lpTemplateName;
190 HINSTANCE hInstance;
191 LPTSTR lpszStyle;
192 WORD nFontType;
193 WORD ___MISSING_ALIGNMENT__;
194 INT nSizeMin;
195 INT nSizeMax;
196 } CHOOSEFONT, *LPCHOOSEFONT;
197 */
198 static void CmdOptionsFont(HWND hWnd)
199 {
200 // LOGFONT LogFont;
201 CHOOSEFONT cf = { sizeof(CHOOSEFONT), hWnd, NULL,
202 // &LogFont, // lpLogFont
203 NULL, // lpLogFont
204 0, // iPointSize
205 // CF_INITTOLOGFONTSTRUCT, // Flags
206 CF_SCREENFONTS, // Flags
207 0, // rgbColors;
208 0L, // lCustData;
209 NULL, // lpfnHook;
210 NULL, // lpTemplateName;
211 hInst, // hInstance;
212 NULL, // lpszStyle;
213 0, // nFontType;
214 0, // ___MISSING_ALIGNMENT__;
215 0, // nSizeMin;
216 0 // nSizeMax
217 };
218
219 if (ChooseFont(&cf)) {
220
221
222 } else {
223 TCHAR* errStr = NULL;
224 DWORD error = CommDlgExtendedError();
225 switch (error) {
226 case CDERR_DIALOGFAILURE: errStr = _T("The dialog box could not be created. The common dialog box function's call to the DialogBox function failed. For example, this error occurs if the common dialog box call specifies an invalid window handle."); break;
227 case CDERR_FINDRESFAILURE: errStr = _T("The common dialog box function failed to find a specified resource."); break;
228 case CDERR_INITIALIZATION: errStr = _T("The common dialog box function failed during initialization. This error often occurs when sufficient memory is not available."); break;
229 case CDERR_LOADRESFAILURE: errStr = _T("The common dialog box function failed to load a specified resource."); break;
230 case CDERR_LOADSTRFAILURE: errStr = _T("The common dialog box function failed to load a specified string."); break;
231 case CDERR_LOCKRESFAILURE: errStr = _T("The common dialog box function failed to lock a specified resource."); break;
232 case CDERR_MEMALLOCFAILURE: errStr = _T("The common dialog box function was unable to allocate memory for internal structures."); break;
233 case CDERR_MEMLOCKFAILURE: errStr = _T("The common dialog box function was unable to lock the memory associated with a handle."); break;
234 case CDERR_NOHINSTANCE: errStr = _T("The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but you failed to provide a corresponding instance handle."); break;
235 case CDERR_NOHOOK: errStr = _T("The ENABLEHOOK flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but you failed to provide a pointer to a corresponding hook procedure."); break;
236 case CDERR_NOTEMPLATE: errStr = _T("The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but you failed to provide a corresponding template."); break;
237 case CDERR_REGISTERMSGFAIL: errStr = _T("The RegisterWindowMessage function returned an error code when it was called by the common dialog box function."); break;
238 case CDERR_STRUCTSIZE: errStr = _T("The lStructSize member of the initialization structure for the corresponding common dialog box is invalid."); break;
239 case CFERR_MAXLESSTHANMIN:
240 break;
241 case CFERR_NOFONTS:
242 break;
243 }
244 if (errStr) {
245 MessageBox(hWnd, errStr, szTitle, MB_ICONERROR | MB_OK);
246 }
247 }
248 }
249
250
251 static void CmdRegistryPrint(HWND hWnd, int cmd)
252 {
253 PRINTDLG pd = { sizeof(PRINTDLG), hWnd,
254 0, // hDevMode;
255 0, // hDevNames;
256 NULL, // hDC;
257 0L, // Flags;
258 0, // nFromPage;
259 0, // nToPage;
260 0, // nMinPage;
261 0, // nMaxPage;
262 0, // nCopies;
263 NULL, // hInstance;
264 0, // lCustData;
265 NULL, // lpfnPrintHook;
266 NULL, // lpfnSetupHook;
267 NULL, // lpPrintTemplateName;
268 NULL, // lpSetupTemplateName;
269 0, // hPrintTemplate;
270 0 // hSetupTemplate;
271 };
272
273 switch (cmd) {
274 case ID_REGISTRY_PRINTSUBTREE:
275 PrintDlg(&pd);
276 break;
277 case ID_REGISTRY_PRINTERSETUP:
278 PrintDlg(&pd);
279 break;
280 }
281 //PAGESETUPDLG psd;
282 //PageSetupDlg(&psd);
283 }
284 /*
285 typedef struct tagOFN {
286 DWORD lStructSize;
287 HWND hwndOwner;
288 HINSTANCE hInstance;
289 LPCTSTR lpstrFilter;
290 LPTSTR lpstrCustomFilter;
291 DWORD nMaxCustFilter;
292 DWORD nFilterIndex;
293 LPTSTR lpstrFile;
294 DWORD nMaxFile;
295 LPTSTR lpstrFileTitle;
296 DWORD nMaxFileTitle;
297 LPCTSTR lpstrInitialDir;
298 LPCTSTR lpstrTitle;
299 DWORD Flags;
300 WORD nFileOffset;
301 WORD nFileExtension;
302 LPCTSTR lpstrDefExt;
303 LPARAM lCustData;
304 LPOFNHOOKPROC lpfnHook;
305 LPCTSTR lpTemplateName;
306 #if (_WIN32_WINNT >= 0x0500)
307 void * pvReserved;
308 DWORD dwReserved;
309 DWORD FlagsEx;
310 #endif // (_WIN32_WINNT >= 0x0500)
311 } OPENFILENAME, *LPOPENFILENAME;
312 */
313 //GetOpenFileName(...);
314 //GetSaveFileName(...);
315 static void CmdRegistrySaveSubTreeAs(HWND hWnd)
316 {
317 OPENFILENAME ofn;// = { };
318
319 memset(&ofn, 0, sizeof(OPENFILENAME));
320
321 ofn.lStructSize = sizeof(OPENFILENAME);
322 ofn.hwndOwner = hWnd;
323 if (GetSaveFileName(&ofn)) {
324 } else {
325 }
326 }
327
328 void SetupStatusBar(HWND hWnd, BOOL bResize)
329 {
330 RECT rc;
331 int nParts;
332 GetClientRect(hWnd, &rc);
333 nParts = rc.right;
334 // nParts = -1;
335 if (bResize)
336 SendMessage(hStatusBar, WM_SIZE, 0, 0);
337 SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
338 }
339
340 void UpdateStatusBar(void)
341 {
342 TCHAR text[260];
343 DWORD size;
344
345 size = sizeof(text)/sizeof(TCHAR);
346 GetComputerName(text, &size);
347 SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text);
348 }
349
350 static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
351 {
352 BOOL vis = IsWindowVisible(hchild);
353
354 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
355 ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
356 resize_frame_client(hWnd);
357 }
358
359 ////////////////////////////////////////////////////////////////////////////////
360 //
361 // FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
362 //
363 // PURPOSE: Processes WM_COMMAND messages for the main frame window.
364 //
365 //
366
367 static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
368 {
369 HWND hChildWnd;
370 switch (LOWORD(wParam)) {
371 case ID_WINDOW_CLOSEALL:
372 EnumChildWindows(hMDIClient, &CloseEnumProc, 0);
373 break;
374 case ID_WINDOW_CLOSE:
375 hChildWnd = (HWND) SendMessage(hMDIClient, WM_MDIGETACTIVE, 0, 0);
376 if (!SendMessage(hChildWnd, WM_QUERYENDSESSION, 0, 0))
377 SendMessage(hMDIClient, WM_MDIDESTROY, (WPARAM)hChildWnd, 0);
378 break;
379 case ID_REGISTRY_OPENLOCAL:
380 CreateClientChildren(hWnd);
381 break;
382 case ID_REGISTRY_CLOSE:
383 SendMessage(hWnd, WM_COMMAND, ID_WINDOW_CLOSEALL, 0);
384 // SendMessage(hWnd, WM_CLOSE, 0, 0);
385 break;
386 case ID_REGISTRY_LOADHIVE:
387 case ID_REGISTRY_UNLOADHIVE:
388 case ID_REGISTRY_RESTORE:
389 case ID_REGISTRY_SAVEKEY:
390 case ID_REGISTRY_SELECTCOMPUTER:
391 break;
392 case ID_REGISTRY_PRINTSUBTREE:
393 case ID_REGISTRY_PRINTERSETUP:
394 CmdRegistryPrint(hWnd, LOWORD(wParam));
395 break;
396 case ID_REGISTRY_SAVESUBTREEAS:
397 CmdRegistrySaveSubTreeAs(hWnd);
398 break;
399 case ID_REGISTRY_EXIT:
400 DestroyWindow(hWnd);
401 break;
402 case ID_OPTIONS_FONT:
403 CmdOptionsFont(hWnd);
404 break;
405
406 case ID_VIEW_STATUSBAR:
407 toggle_child(hWnd, LOWORD(wParam), hStatusBar);
408 break;
409
410 case ID_VIEW_DISPLAYBINARYDATA:
411 if (Options & OPTIONS_DISPLAY_BINARY_DATA) {
412 Options &= ~OPTIONS_DISPLAY_BINARY_DATA;
413 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), LOWORD(wParam), MF_BYCOMMAND);
414 } else {
415 Options |= OPTIONS_DISPLAY_BINARY_DATA;
416 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
417 }
418 break;
419 ////
420 case ID_VIEW_TREEANDDATA:
421 Options &= ~(OPTIONS_VIEW_TREE_ONLY|OPTIONS_VIEW_DATA_ONLY);
422 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
423 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_TREEONLY, MF_BYCOMMAND);
424 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_DATAONLY, MF_BYCOMMAND);
425 break;
426 case ID_VIEW_TREEONLY:
427 Options &= ~OPTIONS_VIEW_DATA_ONLY;
428 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
429 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_TREEANDDATA, MF_BYCOMMAND);
430 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_DATAONLY, MF_BYCOMMAND);
431 break;
432 case ID_VIEW_DATAONLY:
433 Options &= ~OPTIONS_VIEW_TREE_ONLY;
434 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
435 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_TREEANDDATA, MF_BYCOMMAND);
436 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_TREEONLY, MF_BYCOMMAND);
437 break;
438 ////
439 case ID_OPTIONS_AUTOREFRESH:
440 if (Options & OPTIONS_AUTO_REFRESH) {
441 Options &= ~OPTIONS_AUTO_REFRESH;
442 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), LOWORD(wParam), MF_BYCOMMAND);
443 } else {
444 Options |= OPTIONS_AUTO_REFRESH;
445 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
446 }
447 break;
448 case ID_OPTIONS_READONLYMODE:
449 if (Options & OPTIONS_READ_ONLY_MODE) {
450 Options &= ~OPTIONS_READ_ONLY_MODE;
451 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), LOWORD(wParam), MF_BYCOMMAND);
452 } else {
453 Options |= OPTIONS_READ_ONLY_MODE;
454 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
455 }
456 break;
457 case ID_OPTIONS_CONFIRMONDELETE:
458 if (Options & OPTIONS_CONFIRM_ON_DELETE) {
459 Options &= ~OPTIONS_CONFIRM_ON_DELETE;
460 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), LOWORD(wParam), MF_BYCOMMAND);
461 } else {
462 Options |= OPTIONS_CONFIRM_ON_DELETE;
463 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
464 }
465 break;
466 case ID_OPTIONS_SAVESETTINGSONEXIT:
467 if (Options & OPTIONS_SAVE_ON_EXIT) {
468 Options &= ~OPTIONS_SAVE_ON_EXIT;
469 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), LOWORD(wParam), MF_BYCOMMAND);
470 } else {
471 Options |= OPTIONS_SAVE_ON_EXIT;
472 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
473 }
474 break;
475
476 case ID_WINDOW_CASCADE:
477 SendMessage(hMDIClient, WM_MDICASCADE, 0, 0);
478 break;
479 case ID_WINDOW_TILE_HORZ:
480 SendMessage(hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0);
481 break;
482 case ID_WINDOW_TILE_VERT:
483 SendMessage(hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0);
484 break;
485 case ID_WINDOW_ARRANGEICONS:
486 SendMessage(hMDIClient, WM_MDIICONARRANGE, 0, 0);
487 break;
488 case ID_HELP_ABOUT:
489 // ShowAboutBox(hWnd);
490 {
491 HICON hIcon = LoadIcon(hInst, (LPCTSTR)IDI_REGEDT32);
492 ShellAbout(hWnd, szTitle, "FrameWndProc", hIcon);
493 //if (hIcon) DestroyIcon(hIcon); // NOT REQUIRED
494 }
495 break;
496 default:
497 return FALSE;
498 }
499 return TRUE;
500 }
501
502 ////////////////////////////////////////////////////////////////////////////////
503 //
504 // FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
505 //
506 // PURPOSE: Processes messages for the main frame window.
507 //
508 // WM_COMMAND - process the application menu
509 // WM_DESTROY - post a quit message and return
510 //
511 //
512
513 LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
514 {
515 switch (message) {
516 case WM_CREATE:
517 {
518 HMENU hMenuWindow = GetSubMenu(hMenuFrame, GetMenuItemCount(hMenuFrame)-2);
519 CLIENTCREATESTRUCT ccs = { hMenuWindow, IDW_FIRST_CHILD };
520 hMDIClient = CreateWindowEx(0, _T("MDICLIENT"), NULL,
521 WS_EX_MDICHILD|WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,
522 0, 0, 0, 0,
523 hWnd, (HMENU)0, hInst, &ccs);
524 }
525 if (Options & OPTIONS_AUTO_REFRESH) {
526 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), ID_OPTIONS_AUTOREFRESH, MF_BYCOMMAND | MF_CHECKED);
527 }
528 if (Options & OPTIONS_READ_ONLY_MODE) {
529 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), ID_OPTIONS_READONLYMODE, MF_BYCOMMAND | MF_CHECKED);
530 }
531 if (Options & OPTIONS_CONFIRM_ON_DELETE) {
532 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), ID_OPTIONS_CONFIRMONDELETE, MF_BYCOMMAND | MF_CHECKED);
533 }
534 if (Options & OPTIONS_SAVE_ON_EXIT) {
535 CheckMenuItem(GetSubMenu(hMenuFrame, ID_OPTIONS_MENU), ID_OPTIONS_SAVESETTINGSONEXIT, MF_BYCOMMAND | MF_CHECKED);
536 }
537 CreateClientChildren(hWnd);
538 break;
539 case WM_COMMAND:
540 if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
541 // HWND hChildWnd = (HWND)SendMessage(hMDIClient, WM_MDIGETACTIVE, 0, 0);
542 // if (IsWindow(hChildWnd))
543 // if (SendMessage(hChildWnd, WM_DISPATCH_COMMAND, wParam, lParam))
544 // break;
545 return DefFrameProc(hWnd, hMDIClient, message, wParam, lParam);
546 }
547 break;
548 case WM_SIZE:
549 resize_frame_client(hWnd);
550 break;
551 case WM_DESTROY:
552 WinHelp(hWnd, _T("regedt32"), HELP_QUIT, 0);
553 PostQuitMessage(0);
554 break;
555 case WM_QUERYENDSESSION:
556 case WM_CLOSE:
557 SendMessage(hWnd, WM_COMMAND, ID_WINDOW_CLOSEALL, 0);
558 if (GetWindow(hMDIClient, GW_CHILD) != NULL)
559 return 0;
560 // else fall thru...
561 default:
562 return DefFrameProc(hWnd, hMDIClient, message, wParam, lParam);
563 }
564 return 0;
565 }
566
567