Copy w32api from trunk
[reactos.git] / reactos / subsys / system / regedit / framewnd.c
1 /*
2 * Regedit frame window
3 *
4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
22
23 #include <windows.h>
24 #include <tchar.h>
25 #include <commctrl.h>
26 #include <commdlg.h>
27 #include <cderr.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <shellapi.h>
31
32 #include "main.h"
33 #include "regproc.h"
34
35 /********************************************************************************
36 * Global and Local Variables:
37 */
38
39 static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
40
41 /*******************************************************************************
42 * Local module support methods
43 */
44
45 static void resize_frame_rect(HWND hWnd, PRECT prect)
46 {
47 RECT rt;
48 /*
49 if (IsWindowVisible(hToolBar)) {
50 SendMessage(hToolBar, WM_SIZE, 0, 0);
51 GetClientRect(hToolBar, &rt);
52 prect->top = rt.bottom+3;
53 prect->bottom -= rt.bottom+3;
54 }
55 */
56 if (IsWindowVisible(hStatusBar)) {
57 SetupStatusBar(hWnd, TRUE);
58 GetClientRect(hStatusBar, &rt);
59 prect->bottom -= rt.bottom;
60 }
61 MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
62 }
63
64 void resize_frame_client(HWND hWnd)
65 {
66 RECT rect;
67
68 GetClientRect(hWnd, &rect);
69 resize_frame_rect(hWnd, &rect);
70 }
71
72 /********************************************************************************/
73
74 static void OnEnterMenuLoop(HWND hWnd)
75 {
76 int nParts;
77
78 /* Update the status bar pane sizes */
79 nParts = -1;
80 SendMessage(hStatusBar, SB_SETPARTS, 1, (long)&nParts);
81 bInMenuLoop = TRUE;
82 SendMessage(hStatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)_T(""));
83 }
84
85 static void OnExitMenuLoop(HWND hWnd)
86 {
87 bInMenuLoop = FALSE;
88 /* Update the status bar pane sizes*/
89 SetupStatusBar(hWnd, TRUE);
90 UpdateStatusBar();
91 }
92
93 static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
94 {
95 TCHAR str[100];
96
97 _tcscpy(str, _T(""));
98 if (nFlags & MF_POPUP) {
99 if (hSysMenu != GetMenu(hWnd)) {
100 if (nItemID == 2) nItemID = 5;
101 }
102 }
103 if (LoadString(hInst, nItemID, str, 100)) {
104 /* load appropriate string*/
105 LPTSTR lpsz = str;
106 /* first newline terminates actual string*/
107 lpsz = _tcschr(lpsz, '\n');
108 if (lpsz != NULL)
109 *lpsz = '\0';
110 }
111 SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)str);
112 }
113
114 void SetupStatusBar(HWND hWnd, BOOL bResize)
115 {
116 RECT rc;
117 int nParts;
118 GetClientRect(hWnd, &rc);
119 nParts = rc.right;
120 /* nParts = -1;*/
121 if (bResize)
122 SendMessage(hStatusBar, WM_SIZE, 0, 0);
123 SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
124 }
125
126 void UpdateStatusBar(void)
127 {
128 TCHAR text[260];
129 DWORD size;
130
131 size = sizeof(text)/sizeof(TCHAR);
132 GetComputerName(text, &size);
133 SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text);
134 }
135
136 static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
137 {
138 BOOL vis = IsWindowVisible(hchild);
139 HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
140
141 CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
142 ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
143 resize_frame_client(hWnd);
144 }
145
146 static BOOL CheckCommDlgError(HWND hWnd)
147 {
148 DWORD dwErrorCode = CommDlgExtendedError();
149 switch (dwErrorCode) {
150 case CDERR_DIALOGFAILURE:
151 break;
152 case CDERR_FINDRESFAILURE:
153 break;
154 case CDERR_NOHINSTANCE:
155 break;
156 case CDERR_INITIALIZATION:
157 break;
158 case CDERR_NOHOOK:
159 break;
160 case CDERR_LOCKRESFAILURE:
161 break;
162 case CDERR_NOTEMPLATE:
163 break;
164 case CDERR_LOADRESFAILURE:
165 break;
166 case CDERR_STRUCTSIZE:
167 break;
168 case CDERR_LOADSTRFAILURE:
169 break;
170 case FNERR_BUFFERTOOSMALL:
171 break;
172 case CDERR_MEMALLOCFAILURE:
173 break;
174 case FNERR_INVALIDFILENAME:
175 break;
176 case CDERR_MEMLOCKFAILURE:
177 break;
178 case FNERR_SUBCLASSFAILURE:
179 break;
180 default:
181 break;
182 }
183 return TRUE;
184 }
185
186 UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
187 {
188 OPENFILENAME* pOpenFileName;
189 OFNOTIFY* pOfNotify;
190
191 switch (uiMsg) {
192 case WM_INITDIALOG:
193 pOpenFileName = (OPENFILENAME*)lParam;
194 break;
195 case WM_NOTIFY:
196 pOfNotify = (OFNOTIFY*)lParam;
197 if (pOfNotify->hdr.code == CDN_INITDONE) {}
198 break;
199 default:
200 break;
201 }
202 return 0L;
203 }
204
205 #define MAX_CUSTOM_FILTER_SIZE 50
206 TCHAR CustomFilterBuffer[MAX_CUSTOM_FILTER_SIZE];
207 TCHAR FileNameBuffer[_MAX_PATH];
208 TCHAR FileTitleBuffer[_MAX_PATH];
209
210 typedef struct
211 {
212 UINT DisplayID;
213 UINT FilterID;
214 } FILTERPAIR, *PFILTERPAIR;
215
216 void
217 BuildFilterStrings(TCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
218 {
219 int i, c;
220
221 c = 0;
222 for(i = 0; i < PairCount; i++)
223 {
224 c += LoadString(hInst, Pairs[i].DisplayID, &Filter[c], 255 * sizeof(TCHAR));
225 Filter[++c] = '\0';
226 c += LoadString(hInst, Pairs[i].FilterID, &Filter[c], 255 * sizeof(TCHAR));
227 Filter[++c] = '\0';
228 }
229 Filter[++c] = '\0';
230 }
231
232 static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
233 {
234 FILTERPAIR FilterPairs[3];
235 static TCHAR Filter[1024];
236
237 memset(pofn, 0, sizeof(OPENFILENAME));
238 pofn->lStructSize = sizeof(OPENFILENAME);
239 pofn->hwndOwner = hWnd;
240 pofn->hInstance = hInst;
241
242 /* create filter string */
243 FilterPairs[0].DisplayID = IDS_FLT_REGFILES;
244 FilterPairs[0].FilterID = IDS_FLT_REGFILES_FLT;
245 FilterPairs[1].DisplayID = IDS_FLT_REGEDIT4;
246 FilterPairs[1].FilterID = IDS_FLT_REGEDIT4_FLT;
247 FilterPairs[2].DisplayID = IDS_FLT_ALLFILES;
248 FilterPairs[2].FilterID = IDS_FLT_ALLFILES_FLT;
249 BuildFilterStrings(Filter, FilterPairs, sizeof(FilterPairs) / sizeof(FILTERPAIR));
250
251 pofn->lpstrFilter = Filter;
252 pofn->lpstrCustomFilter = CustomFilterBuffer;
253 pofn->nMaxCustFilter = MAX_CUSTOM_FILTER_SIZE;
254 pofn->nFilterIndex = 0;
255 pofn->lpstrFile = FileNameBuffer;
256 pofn->nMaxFile = _MAX_PATH;
257 pofn->lpstrFileTitle = FileTitleBuffer;
258 pofn->nMaxFileTitle = _MAX_PATH;
259 /* pofn->lpstrInitialDir = _T("");*/
260 /* pofn->lpstrTitle = _T("Import Registry File");*/
261 /* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/
262 pofn->Flags = OFN_HIDEREADONLY;
263 /* pofn->nFileOffset = ;*/
264 /* pofn->nFileExtension = ;*/
265 /* pofn->lpstrDefExt = _T("");*/
266 /* pofn->lCustData = ;*/
267 /* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/
268 /* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/
269 /* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/
270 /* pofn->FlagsEx = ;*/
271 return TRUE;
272 }
273
274 static BOOL ImportRegistryFile(HWND hWnd)
275 {
276 OPENFILENAME ofn;
277 TCHAR Caption[128];
278
279 InitOpenFileName(hWnd, &ofn);
280 LoadString(hInst, IDS_IMPORT_REG_FILE, Caption, sizeof(Caption)/sizeof(TCHAR));
281 ofn.lpstrTitle = Caption;
282 /* ofn.lCustData = ;*/
283 if (GetOpenFileName(&ofn)) {
284 /* FIXME - convert to ascii */
285 if (!import_registry_file((LPSTR)ofn.lpstrFile)) {
286 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
287 return FALSE;
288 }
289 #if 0
290 get_file_name(&s, filename, MAX_PATH);
291 if (!filename[0]) {
292 printf("No file name is specified\n%s", usage);
293 return FALSE;
294 /*exit(1);*/
295 }
296 while (filename[0]) {
297 if (!import_registry_file(filename)) {
298 perror("");
299 printf("Can't open file \"%s\"\n", filename);
300 return FALSE;
301 /*exit(1);*/
302 }
303 get_file_name(&s, filename, MAX_PATH);
304 }
305 #endif
306
307 } else {
308 CheckCommDlgError(hWnd);
309 }
310 return TRUE;
311 }
312
313
314 static BOOL ExportRegistryFile(HWND hWnd)
315 {
316 OPENFILENAME ofn;
317 TCHAR ExportKeyPath[_MAX_PATH];
318 TCHAR Caption[128];
319
320 ExportKeyPath[0] = _T('\0');
321 InitOpenFileName(hWnd, &ofn);
322 LoadString(hInst, IDS_EXPORT_REG_FILE, Caption, sizeof(Caption)/sizeof(TCHAR));
323 ofn.lpstrTitle = Caption;
324 /* ofn.lCustData = ;*/
325 ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER;
326 ofn.lpfnHook = ImportRegistryFile_OFNHookProc;
327 ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);
328 if (GetSaveFileName(&ofn)) {
329 BOOL result;
330 /* FIXME - convert strings to ascii! */
331 result = export_registry_key((CHAR*)ofn.lpstrFile, (CHAR*)ExportKeyPath);
332 /*result = export_registry_key(ofn.lpstrFile, NULL);*/
333 /*if (!export_registry_key(ofn.lpstrFile, NULL)) {*/
334 if (!result) {
335 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
336 return FALSE;
337 }
338 #if 0
339 TCHAR filename[MAX_PATH];
340 filename[0] = '\0';
341 get_file_name(&s, filename, MAX_PATH);
342 if (!filename[0]) {
343 printf("No file name is specified\n%s", usage);
344 return FALSE;
345 /*exit(1);*/
346 }
347 if (s[0]) {
348 TCHAR reg_key_name[KEY_MAX_LEN];
349 get_file_name(&s, reg_key_name, KEY_MAX_LEN);
350 export_registry_key((CHAR)filename, reg_key_name);
351 } else {
352 export_registry_key(filename, NULL);
353 }
354 #endif
355
356 } else {
357 CheckCommDlgError(hWnd);
358 }
359 return TRUE;
360 }
361
362 BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
363 {
364 #if 1
365 PRINTDLG pd;
366
367 ZeroMemory(&pd, sizeof(PRINTDLG));
368 pd.lStructSize = sizeof(PRINTDLG);
369 pd.hwndOwner = hWnd;
370 pd.hDevMode = NULL; /* Don't forget to free or store hDevMode*/
371 pd.hDevNames = NULL; /* Don't forget to free or store hDevNames*/
372 pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
373 pd.nCopies = 1;
374 pd.nFromPage = 0xFFFF;
375 pd.nToPage = 0xFFFF;
376 pd.nMinPage = 1;
377 pd.nMaxPage = 0xFFFF;
378 if (PrintDlg(&pd) == TRUE) {
379 /* GDI calls to render output. */
380 DeleteDC(pd.hDC); /* Delete DC when done.*/
381 }
382 #else
383 HRESULT hResult;
384 PRINTDLGEX pd;
385
386 hResult = PrintDlgEx(&pd);
387 if (hResult == S_OK) {
388 switch (pd.dwResultAction) {
389 case PD_RESULT_APPLY:
390 /*The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. */
391 break;
392 case PD_RESULT_CANCEL:
393 /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
394 break;
395 case PD_RESULT_PRINT:
396 /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
397 break;
398 default:
399 break;
400 }
401 } else {
402 switch (hResult) {
403 case E_OUTOFMEMORY:
404 /*Insufficient memory. */
405 break;
406 case E_INVALIDARG:
407 /* One or more arguments are invalid. */
408 break;
409 case E_POINTER:
410 /*Invalid pointer. */
411 break;
412 case E_HANDLE:
413 /*Invalid handle. */
414 break;
415 case E_FAIL:
416 /*Unspecified error. */
417 break;
418 default:
419 break;
420 }
421 return FALSE;
422 }
423 #endif
424 return TRUE;
425 }
426
427 BOOL CopyKeyName(HWND hWnd, LPTSTR keyName)
428 {
429 BOOL result;
430
431 result = OpenClipboard(hWnd);
432 if (result) {
433 result = EmptyClipboard();
434 if (result) {
435
436 /*HANDLE hClipData;*/
437 /*hClipData = SetClipboardData(UINT uFormat, HANDLE hMem);*/
438
439 } else {
440 /* error emptying clipboard*/
441 /* DWORD dwError = GetLastError(); */
442 ;
443 }
444 if (!CloseClipboard()) {
445 /* error closing clipboard*/
446 /* DWORD dwError = GetLastError(); */
447 ;
448 }
449 } else {
450 /* error opening clipboard*/
451 /* DWORD dwError = GetLastError(); */
452 ;
453 }
454 return result;
455 }
456
457 BOOL RefreshView(HWND hWnd)
458 {
459 /* TODO:*/
460 MessageBeep(-1);
461 MessageBeep(MB_ICONASTERISK);
462 MessageBeep(MB_ICONEXCLAMATION);
463 MessageBeep(MB_ICONHAND);
464 MessageBeep(MB_ICONQUESTION);
465 MessageBeep(MB_OK);
466 return TRUE;
467 }
468
469 /*******************************************************************************
470 *
471 * FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
472 *
473 * PURPOSE: Processes WM_COMMAND messages for the main frame window.
474 *
475 */
476 static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
477 {
478 HKEY hKeyRoot = 0, hKey = 0;
479 LPCTSTR keyPath;
480 LPCTSTR valueName;
481 BOOL result = TRUE;
482 REGSAM regsam = KEY_READ;
483 LONG lRet;
484 int item;
485
486 switch (LOWORD(wParam)) {
487 case ID_REGISTRY_IMPORTREGISTRYFILE:
488 ImportRegistryFile(hWnd);
489 return TRUE;
490 case ID_REGISTRY_EXPORTREGISTRYFILE:
491 ExportRegistryFile(hWnd);
492 return TRUE;
493 case ID_REGISTRY_CONNECTNETWORKREGISTRY:
494 return TRUE;
495 case ID_REGISTRY_DISCONNECTNETWORKREGISTRY:
496 return TRUE;
497 case ID_REGISTRY_PRINT:
498 PrintRegistryHive(hWnd, _T(""));
499 return TRUE;
500 case ID_REGISTRY_EXIT:
501 DestroyWindow(hWnd);
502 return TRUE;
503 case ID_VIEW_STATUSBAR:
504 toggle_child(hWnd, LOWORD(wParam), hStatusBar);
505 return TRUE;
506 case ID_HELP_HELPTOPICS:
507 WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
508 return TRUE;
509 case ID_HELP_ABOUT:
510 ShowAboutBox(hWnd);
511 return TRUE;
512 case ID_VIEW_SPLIT:
513 {
514 RECT rt;
515 POINT pt, pts;
516 GetClientRect(g_pChildWnd->hWnd, &rt);
517 pt.x = rt.left + g_pChildWnd->nSplitPos;
518 pt.y = (rt.bottom / 2);
519 pts = pt;
520 if(ClientToScreen(g_pChildWnd->hWnd, &pts))
521 {
522 SetCursorPos(pts.x, pts.y);
523 SetCursor(LoadCursor(0, IDC_SIZEWE));
524 SendMessage(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
525 }
526 return TRUE;
527 }
528 case ID_EDIT_RENAME:
529 case ID_EDIT_MODIFY:
530 case ID_EDIT_MODIFY_BIN:
531 case ID_EDIT_DELETE:
532 regsam |= KEY_WRITE;
533 break;
534 }
535
536 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
537 valueName = GetValueName(g_pChildWnd->hListWnd, -1);
538 if (keyPath) {
539 lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, regsam, &hKey);
540 if (lRet != ERROR_SUCCESS) hKey = 0;
541 }
542
543 switch (LOWORD(wParam)) {
544 case ID_EDIT_MODIFY:
545 if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
546 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
547 break;
548 case ID_EDIT_MODIFY_BIN:
549 if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
550 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
551 break;
552 case ID_EDIT_RENAME:
553 if(ListView_GetSelectedCount(g_pChildWnd->hListWnd) == 1)
554 {
555 item = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_SELECTED);
556 if(item > -1)
557 {
558 ListView_EditLabel(g_pChildWnd->hListWnd, item);
559 }
560 }
561 break;
562 case ID_EDIT_DELETE:
563 {
564 UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
565 if(nSelected >= 1)
566 {
567 TCHAR msg[128], caption[128];
568 LoadString(hInst, IDS_QUERY_DELETE_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR));
569 LoadString(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, sizeof(msg)/sizeof(TCHAR));
570 if(MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
571 {
572 int ni, errs;
573
574 item = -1;
575 errs = 0;
576 while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1)
577 {
578 valueName = GetValueName(g_pChildWnd->hListWnd, item);
579 if(RegDeleteValue(hKey, valueName) != ERROR_SUCCESS)
580 {
581 errs++;
582 }
583 item = ni;
584 }
585
586 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
587 if(errs > 0)
588 {
589 LoadString(hInst, IDS_ERR_DELVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR));
590 LoadString(hInst, IDS_ERR_DELETEVALUE, msg, sizeof(msg)/sizeof(TCHAR));
591 MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
592 }
593 }
594 }
595 break;
596 }
597 case ID_EDIT_COPYKEYNAME:
598 CopyKeyName(hWnd, _T(""));
599 break;
600 case ID_EDIT_PERMISSIONS:
601 if(keyPath != NULL && _tcslen(keyPath) > 0)
602 {
603 RegKeyEditPermissions(hWnd, hKey, NULL, keyPath);
604 }
605 else
606 {
607 MessageBeep(MB_ICONASTERISK);
608 }
609 break;
610 case ID_REGISTRY_PRINTERSETUP:
611 /*PRINTDLG pd;*/
612 /*PrintDlg(&pd);*/
613 /*PAGESETUPDLG psd;*/
614 /*PageSetupDlg(&psd);*/
615 break;
616 case ID_REGISTRY_OPENLOCAL:
617 break;
618
619 case ID_VIEW_REFRESH:
620 RefreshView(hWnd);
621 break;
622 /*case ID_OPTIONS_TOOLBAR:*/
623 /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
624 /* break;*/
625 default:
626 result = FALSE;
627 }
628
629 if(hKey)
630 RegCloseKey(hKey);
631 return result;
632 }
633
634 /********************************************************************************
635 *
636 * FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
637 *
638 * PURPOSE: Processes messages for the main frame window.
639 *
640 * WM_COMMAND - process the application menu
641 * WM_DESTROY - post a quit message and return
642 *
643 */
644
645 LRESULT CALLBACK
646 FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
647 {
648 switch (message) {
649 case WM_CREATE:
650 CreateWindowEx(0, szChildClass, NULL, WS_CHILD | WS_VISIBLE,
651 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
652 hWnd, (HMENU)0, hInst, 0);
653 break;
654 case WM_COMMAND:
655 if (!_CmdWndProc(hWnd, message, wParam, lParam))
656 return DefWindowProc(hWnd, message, wParam, lParam);
657 break;
658 case WM_SIZE:
659 resize_frame_client(hWnd);
660 break;
661 case WM_TIMER:
662 break;
663 case WM_ENTERMENULOOP:
664 OnEnterMenuLoop(hWnd);
665 break;
666 case WM_EXITMENULOOP:
667 OnExitMenuLoop(hWnd);
668 break;
669 case WM_MENUSELECT:
670 OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
671 break;
672 case WM_ACTIVATE:
673 if (LOWORD(hWnd))
674 SetFocus(g_pChildWnd->hWnd);
675 break;
676 case WM_DESTROY:
677 WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);
678 PostQuitMessage(0);
679 default:
680 return DefWindowProc(hWnd, message, wParam, lParam);
681 }
682 return 0;
683 }