4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
35 /********************************************************************************
36 * Global and Local Variables:
39 static TCHAR favoritesKey[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\RegEdit\\Favorites");
40 static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
41 static TCHAR favoriteName[128];
42 static TCHAR searchString[128];
43 static int searchMask = SEARCH_KEYS | SEARCH_VALUES | SEARCH_CONTENT;
45 /*******************************************************************************
46 * Local module support methods
49 static void resize_frame_rect(HWND hWnd, PRECT prect)
53 if (IsWindowVisible(hToolBar)) {
54 SendMessage(hToolBar, WM_SIZE, 0, 0);
55 GetClientRect(hToolBar, &rt);
56 prect->top = rt.bottom+3;
57 prect->bottom -= rt.bottom+3;
60 if (IsWindowVisible(hStatusBar)) {
61 SetupStatusBar(hWnd, TRUE);
62 GetClientRect(hStatusBar, &rt);
63 prect->bottom -= rt.bottom;
65 MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
68 static void resize_frame_client(HWND hWnd)
72 GetClientRect(hWnd, &rect);
73 resize_frame_rect(hWnd, &rect);
76 /********************************************************************************/
78 static void OnEnterMenuLoop(HWND hWnd)
82 /* Update the status bar pane sizes */
84 SendMessage(hStatusBar, SB_SETPARTS, 1, (long)&nParts);
86 SendMessage(hStatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)_T(""));
89 static void OnExitMenuLoop(HWND hWnd)
92 /* Update the status bar pane sizes*/
93 SetupStatusBar(hWnd, TRUE);
97 static void UpdateMenuItems(HMENU hMenu) {
98 HWND hwndTV = g_pChildWnd->hTreeWnd;
99 BOOL bIsKeySelected = FALSE;
100 HKEY hRootKey = NULL;
102 keyName = GetItemPath(hwndTV, TreeView_GetSelection(hwndTV), &hRootKey);
103 if (keyName && *keyName) { /* can't modify root keys */
104 bIsKeySelected = TRUE;
106 EnableMenuItem(hMenu, ID_EDIT_FIND, MF_ENABLED | MF_BYCOMMAND);
107 EnableMenuItem(hMenu, ID_EDIT_FINDNEXT, MF_ENABLED | MF_BYCOMMAND);
108 EnableMenuItem(hMenu, ID_EDIT_MODIFY, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
109 EnableMenuItem(hMenu, ID_EDIT_DELETE, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
110 EnableMenuItem(hMenu, ID_EDIT_RENAME, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
111 EnableMenuItem(hMenu, ID_FAVORITES_ADDTOFAVORITES, (hRootKey ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
112 EnableMenuItem(hMenu, ID_FAVORITES_REMOVEFAVORITE,
113 (GetMenuItemCount(hMenu)>2 ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
116 static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem)
120 while(GetMenuItemCount(hMenu)>2)
121 DeleteMenu(hMenu, 2, MF_BYPOSITION);
122 if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey,
123 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
124 TCHAR namebuf[KEY_MAX_LEN];
128 DWORD ksize, vsize, type;
132 vsize = sizeof(valuebuf);
133 error = RegEnumValue(hKey, i, namebuf, &ksize, NULL, &type, valuebuf, &vsize);
134 if (error != ERROR_SUCCESS)
136 if (type == REG_SZ) {
138 AppendMenu(hMenu, MF_SEPARATOR, -1, NULL);
141 AppendMenu(hMenu, MF_STRING, ID_FAVORITE_FIRST+i, namebuf);
144 } while(error == ERROR_SUCCESS);
148 UpdateMenuItems(hMenu);
151 static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
155 _tcscpy(str, _T(""));
156 if (nFlags & MF_POPUP) {
157 if (hSysMenu != GetMenu(hWnd)) {
158 if (nItemID == 2) nItemID = 5;
161 if (LoadString(hInst, nItemID, str, 100)) {
162 /* load appropriate string*/
164 /* first newline terminates actual string*/
165 lpsz = _tcschr(lpsz, '\n');
169 SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)str);
172 void SetupStatusBar(HWND hWnd, BOOL bResize)
176 GetClientRect(hWnd, &rc);
180 SendMessage(hStatusBar, WM_SIZE, 0, 0);
181 SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
185 void UpdateStatusBar(void)
187 LPTSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, TRUE);
188 SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
189 HeapFree(GetProcessHeap(), 0, fullPath);
192 static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
194 BOOL vis = IsWindowVisible(hchild);
195 HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
197 CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
198 ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
199 resize_frame_client(hWnd);
202 static BOOL CheckCommDlgError(HWND hWnd)
204 DWORD dwErrorCode = CommDlgExtendedError();
205 switch (dwErrorCode) {
206 case CDERR_DIALOGFAILURE:
208 case CDERR_FINDRESFAILURE:
210 case CDERR_NOHINSTANCE:
212 case CDERR_INITIALIZATION:
216 case CDERR_LOCKRESFAILURE:
218 case CDERR_NOTEMPLATE:
220 case CDERR_LOADRESFAILURE:
222 case CDERR_STRUCTSIZE:
224 case CDERR_LOADSTRFAILURE:
226 case FNERR_BUFFERTOOSMALL:
228 case CDERR_MEMALLOCFAILURE:
230 case FNERR_INVALIDFILENAME:
232 case CDERR_MEMLOCKFAILURE:
234 case FNERR_SUBCLASSFAILURE:
242 static void ExportRegistryFile_StoreSelection(HWND hdlg, OPENFILENAME *pOpenFileName)
244 if (IsDlgButtonChecked(hdlg, IDC_EXPORT_SELECTED))
246 INT len = SendDlgItemMessage(hdlg, IDC_EXPORT_PATH, WM_GETTEXTLENGTH, 0, 0);
247 pOpenFileName->lCustData = (LPARAM)HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(TCHAR));
248 SendDlgItemMessage(hdlg, IDC_EXPORT_PATH, WM_GETTEXT, len+1, pOpenFileName->lCustData);
251 pOpenFileName->lCustData = (LPARAM)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TCHAR));
254 static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
256 static OPENFILENAME* pOpenFileName;
262 pOpenFileName = (OPENFILENAME*)lParam;
265 if (LOWORD(wParam) == IDC_EXPORT_PATH && HIWORD(wParam) == EN_UPDATE)
266 CheckRadioButton(hdlg, IDC_EXPORT_ALL, IDC_EXPORT_SELECTED, IDC_EXPORT_SELECTED);
269 pOfNotify = (OFNOTIFY*)lParam;
270 switch (pOfNotify->hdr.code)
273 path = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
274 SendDlgItemMessage(hdlg, IDC_EXPORT_PATH, WM_SETTEXT, 0, (LPARAM)path);
275 HeapFree(GetProcessHeap(), 0, path);
276 CheckRadioButton(hdlg, IDC_EXPORT_ALL, IDC_EXPORT_SELECTED, IDC_EXPORT_ALL);
279 ExportRegistryFile_StoreSelection(hdlg, pOpenFileName);
289 TCHAR FileNameBuffer[_MAX_PATH];
290 TCHAR FileTitleBuffer[_MAX_PATH];
291 TCHAR FilterBuffer[_MAX_PATH];
293 static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
295 memset(pofn, 0, sizeof(OPENFILENAME));
296 pofn->lStructSize = sizeof(OPENFILENAME);
297 pofn->hwndOwner = hWnd;
298 pofn->hInstance = hInst;
300 if (FilterBuffer[0] == 0)
301 LoadString(hInst, IDS_FILEDIALOG_FILTER, FilterBuffer, _MAX_PATH);
302 pofn->lpstrFilter = FilterBuffer;
303 pofn->nFilterIndex = 1;
304 pofn->lpstrFile = FileNameBuffer;
305 pofn->nMaxFile = _MAX_PATH;
306 pofn->lpstrFileTitle = FileTitleBuffer;
307 pofn->nMaxFileTitle = _MAX_PATH;
308 pofn->Flags = OFN_HIDEREADONLY;
309 /* some other fields may be set by the caller */
313 static BOOL ImportRegistryFile(HWND hWnd)
318 InitOpenFileName(hWnd, &ofn);
319 LoadString(hInst, IDS_FILEDIALOG_IMPORT_TITLE, title, COUNT_OF(title));
320 ofn.lpstrTitle = title;
321 if (GetOpenFileName(&ofn)) {
322 if (!import_registry_file(ofn.lpstrFile)) {
323 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
327 CheckCommDlgError(hWnd);
333 static BOOL ExportRegistryFile(HWND hWnd)
336 TCHAR ExportKeyPath[_MAX_PATH];
339 ExportKeyPath[0] = _T('\0');
340 InitOpenFileName(hWnd, &ofn);
341 LoadString(hInst, IDS_FILEDIALOG_EXPORT_TITLE, title, COUNT_OF(title));
342 ofn.lpstrTitle = title;
344 ofn.Flags = OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
345 ofn.lpfnHook = ExportRegistryFile_OFNHookProc;
346 ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXPORT_TEMPLATE);
347 if (GetSaveFileName(&ofn)) {
349 result = export_registry_key(ofn.lpstrFile, (LPTSTR)ofn.lCustData);
351 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
355 CheckCommDlgError(hWnd);
360 static BOOL PrintRegistryHive(HWND hWnd, LPCTSTR path)
365 ZeroMemory(&pd, sizeof(PRINTDLG));
366 pd.lStructSize = sizeof(PRINTDLG);
368 pd.hDevMode = NULL; /* Don't forget to free or store hDevMode*/
369 pd.hDevNames = NULL; /* Don't forget to free or store hDevNames*/
370 pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
372 pd.nFromPage = 0xFFFF;
375 pd.nMaxPage = 0xFFFF;
377 /* GDI calls to render output. */
378 DeleteDC(pd.hDC); /* Delete DC when done.*/
384 hResult = PrintDlgEx(&pd);
385 if (hResult == S_OK) {
386 switch (pd.dwResultAction) {
387 case PD_RESULT_APPLY:
388 /*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. */
390 case PD_RESULT_CANCEL:
391 /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
393 case PD_RESULT_PRINT:
394 /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
402 /*Insufficient memory. */
405 /* One or more arguments are invalid. */
408 /*Invalid pointer. */
414 /*Unspecified error. */
425 static BOOL CopyKeyName(HWND hWnd, LPCTSTR keyName)
429 result = OpenClipboard(hWnd);
431 result = EmptyClipboard();
433 int len = (_tcslen(keyName)+1)*sizeof(TCHAR);
434 HANDLE hClipData = GlobalAlloc(GHND, len);
435 LPVOID pLoc = GlobalLock(hClipData);
436 _tcscpy(pLoc, keyName);
437 GlobalUnlock(hClipData);
438 hClipData = SetClipboardData(CF_TEXT, hClipData);
441 /* error emptying clipboard*/
442 /* DWORD dwError = GetLastError(); */
445 if (!CloseClipboard()) {
446 /* error closing clipboard*/
447 /* DWORD dwError = GetLastError(); */
451 /* error opening clipboard*/
452 /* DWORD dwError = GetLastError(); */
458 static INT_PTR CALLBACK find_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
460 HWND hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_NAME);
464 EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
465 CheckDlgButton(hwndDlg, IDC_FIND_KEYS, searchMask&SEARCH_KEYS ? BST_CHECKED : BST_UNCHECKED);
466 CheckDlgButton(hwndDlg, IDC_FIND_VALUES, searchMask&SEARCH_VALUES ? BST_CHECKED : BST_UNCHECKED);
467 CheckDlgButton(hwndDlg, IDC_FIND_CONTENT, searchMask&SEARCH_CONTENT ? BST_CHECKED : BST_UNCHECKED);
468 CheckDlgButton(hwndDlg, IDC_FIND_WHOLE, searchMask&SEARCH_WHOLE ? BST_CHECKED : BST_UNCHECKED);
469 SendMessage(hwndValue, EM_SETLIMITTEXT, 127, 0);
470 SetWindowText(hwndValue, searchString);
473 switch(LOWORD(wParam)) {
475 if (HIWORD(wParam) == EN_UPDATE) {
476 EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(hwndValue)>0);
481 if (GetWindowTextLength(hwndValue)>0) {
483 if (IsDlgButtonChecked(hwndDlg, IDC_FIND_KEYS)) mask |= SEARCH_KEYS;
484 if (IsDlgButtonChecked(hwndDlg, IDC_FIND_VALUES)) mask |= SEARCH_VALUES;
485 if (IsDlgButtonChecked(hwndDlg, IDC_FIND_CONTENT)) mask |= SEARCH_CONTENT;
486 if (IsDlgButtonChecked(hwndDlg, IDC_FIND_WHOLE)) mask |= SEARCH_WHOLE;
488 GetWindowText(hwndValue, searchString, 128);
489 EndDialog(hwndDlg, IDOK);
493 EndDialog(hwndDlg, IDCANCEL);
501 static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
503 HWND hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_NAME);
507 EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
508 SendMessage(hwndValue, EM_SETLIMITTEXT, 127, 0);
511 switch(LOWORD(wParam)) {
513 if (HIWORD(wParam) == EN_UPDATE) {
514 EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(hwndValue)>0);
519 if (GetWindowTextLength(hwndValue)>0) {
520 GetWindowText(hwndValue, favoriteName, 128);
521 EndDialog(hwndDlg, IDOK);
525 EndDialog(hwndDlg, IDCANCEL);
533 static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
535 HWND hwndList = GetDlgItem(hwndDlg, IDC_NAME_LIST);
538 case WM_INITDIALOG: {
541 EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
542 if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey,
543 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
544 TCHAR namebuf[KEY_MAX_LEN];
546 DWORD ksize, vsize, type;
550 vsize = sizeof(valuebuf);
551 error = RegEnumValue(hKey, i, namebuf, &ksize, NULL, &type, valuebuf, &vsize);
552 if (error != ERROR_SUCCESS)
554 if (type == REG_SZ) {
555 SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)namebuf);
558 } while(error == ERROR_SUCCESS);
563 EnableWindow(GetDlgItem(hwndDlg, IDOK), i != 0);
564 SendMessage(hwndList, LB_SETCURSEL, 0, 0);
568 switch(LOWORD(wParam)) {
570 if (HIWORD(wParam) == LBN_SELCHANGE) {
571 EnableWindow(GetDlgItem(hwndDlg, IDOK), lParam != -1);
576 int pos = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
577 int len = SendMessage(hwndList, LB_GETTEXTLEN, pos, 0);
579 LPTSTR lpName = HeapAlloc(GetProcessHeap(), 0, sizeof(TCHAR)*(len+1));
580 SendMessage(hwndList, LB_GETTEXT, pos, (LPARAM)lpName);
583 _tcscpy(favoriteName, lpName);
584 EndDialog(hwndDlg, IDOK);
585 HeapFree(GetProcessHeap(), 0, lpName);
590 EndDialog(hwndDlg, IDCANCEL);
598 /*******************************************************************************
600 * FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
602 * PURPOSE: Processes WM_COMMAND messages for the main frame window.
605 static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
610 TCHAR newKey[MAX_NEW_KEY_LEN];
613 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
614 valueName = GetValueName(g_pChildWnd->hListWnd);
616 if (LOWORD(wParam) >= ID_FAVORITE_FIRST && LOWORD(wParam) <= ID_FAVORITE_LAST) {
618 if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey,
619 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
620 TCHAR namebuf[KEY_MAX_LEN];
622 DWORD ksize = KEY_MAX_LEN, vsize = sizeof(valuebuf), type = 0;
623 if (RegEnumValue(hKey, LOWORD(wParam) - ID_FAVORITE_FIRST, namebuf, &ksize, NULL,
624 &type, valuebuf, &vsize) == ERROR_SUCCESS) {
625 SendMessage( g_pChildWnd->hTreeWnd, TVM_SELECTITEM, TVGN_CARET,
626 (LPARAM) FindPathInTree(g_pChildWnd->hTreeWnd, (TCHAR *)valuebuf) );
632 switch (LOWORD(wParam)) {
633 case ID_REGISTRY_IMPORTREGISTRYFILE:
634 ImportRegistryFile(hWnd);
636 case ID_REGISTRY_EXPORTREGISTRYFILE:
637 ExportRegistryFile(hWnd);
639 case ID_REGISTRY_CONNECTNETWORKREGISTRY:
641 case ID_REGISTRY_DISCONNECTNETWORKREGISTRY:
643 case ID_REGISTRY_PRINT:
644 PrintRegistryHive(hWnd, _T(""));
647 if (GetFocus() == g_pChildWnd->hTreeWnd) {
648 if (keyPath == 0 || *keyPath == 0) {
649 MessageBeep(MB_ICONHAND);
650 } else if (DeleteKey(hWnd, hKeyRoot, keyPath)) {
651 DeleteNode(g_pChildWnd->hTreeWnd, 0);
653 } else if (GetFocus() == g_pChildWnd->hListWnd) {
654 if (DeleteValue(hWnd, hKeyRoot, keyPath, valueName))
655 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL);
659 if (ModifyValue(hWnd, hKeyRoot, keyPath, valueName))
660 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, valueName);
663 case ID_EDIT_FINDNEXT:
666 if (LOWORD(wParam) == ID_EDIT_FIND &&
667 DialogBox(0, MAKEINTRESOURCE(IDD_FIND), hWnd, find_dlgproc) != IDOK)
671 hItem = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
673 int row = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_FOCUSED);
674 HCURSOR hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
675 hItem = FindNext(g_pChildWnd->hTreeWnd, hItem, searchString, searchMask, &row);
676 SetCursor(hcursorOld);
678 SendMessage( g_pChildWnd->hTreeWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM) hItem );
679 InvalidateRect(g_pChildWnd->hTreeWnd, NULL, TRUE);
680 UpdateWindow(g_pChildWnd->hTreeWnd);
682 ListView_SetItemState(g_pChildWnd->hListWnd, -1, 0, LVIS_FOCUSED|LVIS_SELECTED);
683 ListView_SetItemState(g_pChildWnd->hListWnd, row, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
684 SetFocus(g_pChildWnd->hListWnd);
686 SetFocus(g_pChildWnd->hTreeWnd);
689 error(hWnd, IDS_NOTFOUND, searchString);
694 case ID_EDIT_COPYKEYNAME:
696 LPTSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
698 CopyKeyName(hWnd, fullPath);
699 HeapFree(GetProcessHeap(), 0, fullPath);
703 case ID_EDIT_NEW_KEY:
704 if (CreateKey(hWnd, hKeyRoot, keyPath, newKey)) {
705 if (InsertNode(g_pChildWnd->hTreeWnd, 0, newKey))
706 StartKeyRename(g_pChildWnd->hTreeWnd);
709 case ID_EDIT_NEW_STRINGVALUE:
712 case ID_EDIT_NEW_BINARYVALUE:
713 valueType = REG_BINARY;
715 case ID_EDIT_NEW_DWORDVALUE:
716 valueType = REG_DWORD;
719 if (CreateValue(hWnd, hKeyRoot, keyPath, valueType, newKey)) {
720 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, newKey);
721 StartValueRename(g_pChildWnd->hListWnd);
722 /* FIXME: start rename */
726 if (keyPath == 0 || *keyPath == 0) {
727 MessageBeep(MB_ICONHAND);
728 } else if (GetFocus() == g_pChildWnd->hTreeWnd) {
729 StartKeyRename(g_pChildWnd->hTreeWnd);
730 } else if (GetFocus() == g_pChildWnd->hListWnd) {
731 StartValueRename(g_pChildWnd->hListWnd);
735 case ID_REGISTRY_PRINTERSETUP:
738 /*PAGESETUPDLG psd;*/
739 /*PageSetupDlg(&psd);*/
741 case ID_REGISTRY_OPENLOCAL:
743 case ID_REGISTRY_EXIT:
746 case ID_FAVORITES_ADDTOFAVORITES:
749 LPTSTR lpKeyPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
751 if (DialogBox(0, MAKEINTRESOURCE(IDD_ADDFAVORITE), hWnd, addtofavorites_dlgproc) == IDOK) {
752 if (RegCreateKeyEx(HKEY_CURRENT_USER, favoritesKey,
754 KEY_READ|KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
755 RegSetValueEx(hKey, favoriteName, 0, REG_SZ, (BYTE *)lpKeyPath, (_tcslen(lpKeyPath)+1)*sizeof(TCHAR));
759 HeapFree(GetProcessHeap(), 0, lpKeyPath);
763 case ID_FAVORITES_REMOVEFAVORITE:
765 if (DialogBox(0, MAKEINTRESOURCE(IDD_DELFAVORITE), hWnd, removefavorite_dlgproc) == IDOK) {
767 if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey,
768 0, KEY_READ|KEY_WRITE, &hKey) == ERROR_SUCCESS) {
769 RegDeleteValue(hKey, favoriteName);
775 case ID_VIEW_REFRESH:
776 RefreshTreeView(g_pChildWnd->hTreeWnd);
777 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL);
779 /*case ID_OPTIONS_TOOLBAR:*/
780 /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
782 case ID_VIEW_STATUSBAR:
783 toggle_child(hWnd, LOWORD(wParam), hStatusBar);
785 case ID_HELP_HELPTOPICS:
786 WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
791 case ID_VIEW_SPLIT: {
794 GetClientRect(g_pChildWnd->hWnd, &rt);
795 pt.x = rt.left + g_pChildWnd->nSplitPos;
796 pt.y = (rt.bottom / 2);
798 if(ClientToScreen(g_pChildWnd->hWnd, &pts)) {
799 SetCursorPos(pts.x, pts.y);
800 SetCursor(LoadCursor(0, IDC_SIZEWE));
801 SendMessage(g_pChildWnd->hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
812 /********************************************************************************
814 * FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
816 * PURPOSE: Processes messages for the main frame window.
818 * WM_COMMAND - process the application menu
819 * WM_DESTROY - post a quit message and return
823 LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
827 CreateWindowEx(0, szChildClass, _T("regedit child window"), WS_CHILD | WS_VISIBLE,
828 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
829 hWnd, NULL, hInst, 0);
832 if (!_CmdWndProc(hWnd, message, wParam, lParam))
833 return DefWindowProc(hWnd, message, wParam, lParam);
837 SetFocus(g_pChildWnd->hWnd);
840 resize_frame_client(hWnd);
844 case WM_ENTERMENULOOP:
845 OnEnterMenuLoop(hWnd);
847 case WM_EXITMENULOOP:
848 OnExitMenuLoop(hWnd);
850 case WM_INITMENUPOPUP:
852 OnInitMenuPopup(hWnd, (HMENU)wParam, LOWORD(lParam));
855 OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
858 WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);
861 return DefWindowProc(hWnd, message, wParam, lParam);