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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 /********************************************************************************
36 * Global and Local Variables:
39 static BOOL bInMenuLoop
= FALSE
; /* Tells us if we are in the menu loop */
41 /*******************************************************************************
42 * Local module support methods
45 static void resize_frame_rect(HWND hWnd
, PRECT prect
)
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;
56 if (IsWindowVisible(hStatusBar
)) {
57 SetupStatusBar(hWnd
, TRUE
);
58 GetClientRect(hStatusBar
, &rt
);
59 prect
->bottom
-= rt
.bottom
;
61 MoveWindow(g_pChildWnd
->hWnd
, prect
->left
, prect
->top
, prect
->right
, prect
->bottom
, TRUE
);
64 static void resize_frame_client(HWND hWnd
)
68 GetClientRect(hWnd
, &rect
);
69 resize_frame_rect(hWnd
, &rect
);
72 /********************************************************************************/
74 static void OnEnterMenuLoop(HWND hWnd
)
78 /* Update the status bar pane sizes */
80 SendMessage(hStatusBar
, SB_SETPARTS
, 1, (LPARAM
)&nParts
);
82 SendMessage(hStatusBar
, SB_SETTEXT
, (WPARAM
)0, (LPARAM
)_T(""));
85 static void OnExitMenuLoop(HWND hWnd
)
88 /* Update the status bar pane sizes*/
89 SetupStatusBar(hWnd
, TRUE
);
93 static void OnMenuSelect(HWND hWnd
, UINT nItemID
, UINT nFlags
, HMENU hSysMenu
)
98 if (nFlags
& MF_POPUP
) {
99 if (hSysMenu
!= GetMenu(hWnd
)) {
100 if (nItemID
== 2) nItemID
= 5;
103 if (LoadString(hInst
, nItemID
, str
, 100)) {
104 /* load appropriate string*/
106 /* first newline terminates actual string*/
107 lpsz
= _tcschr(lpsz
, '\n');
111 SendMessage(hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)str
);
114 void SetupStatusBar(HWND hWnd
, BOOL bResize
)
118 GetClientRect(hWnd
, &rc
);
122 SendMessage(hStatusBar
, WM_SIZE
, 0, 0);
123 SendMessage(hStatusBar
, SB_SETPARTS
, 1, (LPARAM
)&nParts
);
126 void UpdateStatusBar(void)
131 size
= sizeof(text
)/sizeof(TCHAR
);
132 GetComputerName(text
, &size
);
133 SendMessage(hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)text
);
136 static void toggle_child(HWND hWnd
, UINT cmd
, HWND hchild
)
138 BOOL vis
= IsWindowVisible(hchild
);
139 HMENU hMenuView
= GetSubMenu(hMenuFrame
, ID_VIEW_MENU
);
141 CheckMenuItem(hMenuView
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
142 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
143 resize_frame_client(hWnd
);
146 static BOOL
CheckCommDlgError(HWND hWnd
)
148 DWORD dwErrorCode
= CommDlgExtendedError();
149 switch (dwErrorCode
) {
150 case CDERR_DIALOGFAILURE
:
152 case CDERR_FINDRESFAILURE
:
154 case CDERR_NOHINSTANCE
:
156 case CDERR_INITIALIZATION
:
160 case CDERR_LOCKRESFAILURE
:
162 case CDERR_NOTEMPLATE
:
164 case CDERR_LOADRESFAILURE
:
166 case CDERR_STRUCTSIZE
:
168 case CDERR_LOADSTRFAILURE
:
170 case FNERR_BUFFERTOOSMALL
:
172 case CDERR_MEMALLOCFAILURE
:
174 case FNERR_INVALIDFILENAME
:
176 case CDERR_MEMLOCKFAILURE
:
178 case FNERR_SUBCLASSFAILURE
:
186 #define MAX_CUSTOM_FILTER_SIZE 50
187 TCHAR CustomFilterBuffer
[MAX_CUSTOM_FILTER_SIZE
];
188 TCHAR FileNameBuffer
[_MAX_PATH
];
189 TCHAR FileTitleBuffer
[_MAX_PATH
];
195 } FILTERPAIR
, *PFILTERPAIR
;
198 BuildFilterStrings(TCHAR
*Filter
, PFILTERPAIR Pairs
, int PairCount
)
203 for(i
= 0; i
< PairCount
; i
++)
205 c
+= LoadString(hInst
, Pairs
[i
].DisplayID
, &Filter
[c
], 255 * sizeof(TCHAR
));
207 c
+= LoadString(hInst
, Pairs
[i
].FilterID
, &Filter
[c
], 255 * sizeof(TCHAR
));
213 static BOOL
InitOpenFileName(HWND hWnd
, OPENFILENAME
* pofn
)
215 FILTERPAIR FilterPairs
[3];
216 static TCHAR Filter
[1024];
218 memset(pofn
, 0, sizeof(OPENFILENAME
));
219 pofn
->lStructSize
= sizeof(OPENFILENAME
);
220 pofn
->hwndOwner
= hWnd
;
221 pofn
->hInstance
= hInst
;
223 /* create filter string */
224 FilterPairs
[0].DisplayID
= IDS_FLT_REGFILES
;
225 FilterPairs
[0].FilterID
= IDS_FLT_REGFILES_FLT
;
226 FilterPairs
[1].DisplayID
= IDS_FLT_REGEDIT4
;
227 FilterPairs
[1].FilterID
= IDS_FLT_REGEDIT4_FLT
;
228 FilterPairs
[2].DisplayID
= IDS_FLT_ALLFILES
;
229 FilterPairs
[2].FilterID
= IDS_FLT_ALLFILES_FLT
;
230 BuildFilterStrings(Filter
, FilterPairs
, sizeof(FilterPairs
) / sizeof(FILTERPAIR
));
232 pofn
->lpstrFilter
= Filter
;
233 pofn
->lpstrCustomFilter
= CustomFilterBuffer
;
234 pofn
->nMaxCustFilter
= MAX_CUSTOM_FILTER_SIZE
;
235 pofn
->nFilterIndex
= 0;
236 pofn
->lpstrFile
= FileNameBuffer
;
237 pofn
->nMaxFile
= _MAX_PATH
;
238 pofn
->lpstrFileTitle
= FileTitleBuffer
;
239 pofn
->nMaxFileTitle
= _MAX_PATH
;
240 /* pofn->lpstrInitialDir = _T("");*/
241 /* pofn->lpstrTitle = _T("Import Registry File");*/
242 /* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/
243 pofn
->Flags
= OFN_HIDEREADONLY
;
244 /* pofn->nFileOffset = ;*/
245 /* pofn->nFileExtension = ;*/
246 /* pofn->lpstrDefExt = _T("");*/
247 /* pofn->lCustData = ;*/
248 /* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/
249 /* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/
250 /* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/
251 /* pofn->FlagsEx = ;*/
255 static BOOL
ImportRegistryFile(HWND hWnd
)
260 InitOpenFileName(hWnd
, &ofn
);
261 LoadString(hInst
, IDS_IMPORT_REG_FILE
, Caption
, sizeof(Caption
)/sizeof(TCHAR
));
262 ofn
.lpstrTitle
= Caption
;
263 /* ofn.lCustData = ;*/
264 if (GetOpenFileName(&ofn
)) {
265 /* FIXME - convert to ascii */
266 if (!import_registry_file(ofn
.lpstrFile
)) {
267 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
271 get_file_name(&s
, filename
, MAX_PATH
);
273 printf("No file name is specified\n%s", usage
);
277 while (filename
[0]) {
278 if (!import_registry_file(filename
)) {
280 printf("Can't open file \"%s\"\n", filename
);
284 get_file_name(&s
, filename
, MAX_PATH
);
289 CheckCommDlgError(hWnd
);
295 static UINT_PTR CALLBACK
ExportRegistryFile_OFNHookProc(HWND hdlg
, UINT uiMsg
, WPARAM wParam
, LPARAM lParam
)
298 HWND hwndExportBranch
;
299 HWND hwndExportBranchText
;
300 UINT_PTR iResult
= 0;
302 LPTSTR pszSelectedKey
;
303 OFNOTIFY
*pOfnNotify
;
307 pOfn
= (OPENFILENAME
*) lParam
;
308 pszSelectedKey
= (LPTSTR
) pOfn
->lCustData
;
310 hwndExportAll
= GetDlgItem(hdlg
, IDC_EXPORT_ALL
);
312 SendMessage(hwndExportAll
, BM_SETCHECK
, pszSelectedKey
[0] ? BST_UNCHECKED
: BST_CHECKED
, 0);
314 hwndExportBranch
= GetDlgItem(hdlg
, IDC_EXPORT_BRANCH
);
315 if (hwndExportBranch
)
316 SendMessage(hwndExportBranch
, BM_SETCHECK
, pszSelectedKey
[0] ? BST_CHECKED
: BST_UNCHECKED
, 0);
318 hwndExportBranchText
= GetDlgItem(hdlg
, IDC_EXPORT_BRANCH_TEXT
);
319 if (hwndExportBranchText
)
320 SetWindowText(hwndExportBranchText
, pszSelectedKey
);
324 if (((NMHDR
*) lParam
)->code
== CDN_FILEOK
)
326 pOfnNotify
= (OFNOTIFY
*) lParam
;
327 pszSelectedKey
= (LPTSTR
) pOfnNotify
->lpOFN
->lCustData
;
329 hwndExportBranch
= GetDlgItem(hdlg
, IDC_EXPORT_BRANCH
);
330 hwndExportBranchText
= GetDlgItem(hdlg
, IDC_EXPORT_BRANCH_TEXT
);
331 if (hwndExportBranch
&& hwndExportBranchText
332 && (SendMessage(hwndExportBranch
, BM_GETCHECK
, 0, 0) == BST_CHECKED
))
334 GetWindowText(hwndExportBranchText
, pszSelectedKey
, _MAX_PATH
);
338 pszSelectedKey
[0] = '\0';
346 static BOOL
ExportRegistryFile(HWND hWnd
)
349 TCHAR ExportKeyPath
[_MAX_PATH
];
354 /* Figure out which key path we are exporting */
355 pszKeyPath
= GetItemPath(g_pChildWnd
->hTreeWnd
, 0, &hKeyRoot
);
356 RegKeyGetName(ExportKeyPath
, sizeof(ExportKeyPath
) / sizeof(ExportKeyPath
[0]),
357 hKeyRoot
, pszKeyPath
);
359 InitOpenFileName(hWnd
, &ofn
);
360 LoadString(hInst
, IDS_EXPORT_REG_FILE
, Caption
, sizeof(Caption
)/sizeof(TCHAR
));
361 ofn
.lpstrTitle
= Caption
;
362 ofn
.lCustData
= (LPARAM
) ExportKeyPath
;
363 ofn
.Flags
= OFN_ENABLETEMPLATE
| OFN_EXPLORER
| OFN_ENABLEHOOK
;
364 ofn
.lpfnHook
= ExportRegistryFile_OFNHookProc
;
365 ofn
.lpTemplateName
= MAKEINTRESOURCE(IDD_EXPORTRANGE
);
366 if (GetSaveFileName(&ofn
)) {
368 /* FIXME - convert strings to ascii! */
369 result
= export_registry_key((CHAR
*)ofn
.lpstrFile
, (CHAR
*)ExportKeyPath
);
370 /*result = export_registry_key(ofn.lpstrFile, NULL);*/
371 /*if (!export_registry_key(ofn.lpstrFile, NULL)) {*/
373 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
377 TCHAR filename
[MAX_PATH
];
379 get_file_name(&s
, filename
, MAX_PATH
);
381 printf("No file name is specified\n%s", usage
);
386 TCHAR reg_key_name
[KEY_MAX_LEN
];
387 get_file_name(&s
, reg_key_name
, KEY_MAX_LEN
);
388 export_registry_key((CHAR
)filename
, reg_key_name
);
390 export_registry_key(filename
, NULL
);
395 CheckCommDlgError(hWnd
);
400 BOOL
PrintRegistryHive(HWND hWnd
, LPTSTR path
)
405 ZeroMemory(&pd
, sizeof(PRINTDLG
));
406 pd
.lStructSize
= sizeof(PRINTDLG
);
408 pd
.hDevMode
= NULL
; /* Don't forget to free or store hDevMode*/
409 pd
.hDevNames
= NULL
; /* Don't forget to free or store hDevNames*/
410 pd
.Flags
= PD_USEDEVMODECOPIESANDCOLLATE
| PD_RETURNDC
;
412 pd
.nFromPage
= 0xFFFF;
415 pd
.nMaxPage
= 0xFFFF;
417 /* GDI calls to render output. */
418 DeleteDC(pd
.hDC
); /* Delete DC when done.*/
424 hResult
= PrintDlgEx(&pd
);
425 if (hResult
== S_OK
) {
426 switch (pd
.dwResultAction
) {
427 case PD_RESULT_APPLY
:
428 /*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. */
430 case PD_RESULT_CANCEL
:
431 /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
433 case PD_RESULT_PRINT
:
434 /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
442 /*Insufficient memory. */
445 /* One or more arguments are invalid. */
448 /*Invalid pointer. */
454 /*Unspecified error. */
465 static BOOL
CopyKeyName(HWND hWnd
, LPCTSTR keyName
)
469 result
= OpenClipboard(hWnd
);
471 result
= EmptyClipboard();
474 /*HANDLE hClipData;*/
475 /*hClipData = SetClipboardData(UINT uFormat, HANDLE hMem);*/
478 /* error emptying clipboard*/
479 /* DWORD dwError = GetLastError(); */
482 if (!CloseClipboard()) {
483 /* error closing clipboard*/
484 /* DWORD dwError = GetLastError(); */
488 /* error opening clipboard*/
489 /* DWORD dwError = GetLastError(); */
495 static BOOL
CreateNewValue(HKEY hRootKey
, LPCTSTR pszKeyPath
, DWORD dwType
)
497 TCHAR szNewValueFormat
[128];
498 TCHAR szNewValue
[128];
501 DWORD dwExistingType
, cbData
;
506 if (RegOpenKey(hRootKey
, pszKeyPath
, &hKey
) != ERROR_SUCCESS
)
509 LoadString(hInst
, IDS_NEW_VALUE
, szNewValueFormat
, sizeof(szNewValueFormat
)
510 / sizeof(szNewValueFormat
[0]));
514 _sntprintf(szNewValue
, sizeof(szNewValue
) / sizeof(szNewValue
[0]),
515 szNewValueFormat
, iIndex
++);
517 cbData
= sizeof(data
);
518 lResult
= RegQueryValueEx(hKey
, szNewValue
, NULL
, &dwExistingType
, data
, &cbData
);
520 while(lResult
== ERROR_SUCCESS
);
524 cbData
= sizeof(DWORD
);
528 cbData
= sizeof(TCHAR
);
531 cbData
= sizeof(TCHAR
) * 2;
534 cbData
= sizeof(DWORD
) * 2;
540 memset(data
, 0, cbData
);
541 lResult
= RegSetValueEx(hKey
, szNewValue
, 0, dwType
, data
, cbData
);
542 if (lResult
!= ERROR_SUCCESS
)
545 RefreshListView(g_pChildWnd
->hListWnd
, hRootKey
, pszKeyPath
);
547 /* locate the newly added value, and get ready to rename it */
548 memset(&lvfi
, 0, sizeof(lvfi
));
549 lvfi
.flags
= LVFI_STRING
;
550 lvfi
.psz
= szNewValue
;
551 iIndex
= ListView_FindItem(g_pChildWnd
->hListWnd
, -1, &lvfi
);
553 ListView_EditLabel(g_pChildWnd
->hListWnd
, iIndex
);
559 InitializeRemoteRegistryPicker(OUT IDsObjectPicker
**pDsObjectPicker
)
563 *pDsObjectPicker
= NULL
;
565 hRet
= CoCreateInstance(&CLSID_DsObjectPicker
,
567 CLSCTX_INPROC_SERVER
,
568 &IID_IDsObjectPicker
,
569 (LPVOID
*)pDsObjectPicker
);
572 DSOP_INIT_INFO InitInfo
;
573 static DSOP_SCOPE_INIT_INFO Scopes
[] =
576 sizeof(DSOP_SCOPE_INIT_INFO
),
577 DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE
| DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE
|
578 DSOP_SCOPE_TYPE_GLOBAL_CATALOG
| DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN
|
579 DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN
| DSOP_SCOPE_TYPE_WORKGROUP
|
580 DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN
| DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN
,
584 DSOP_FILTER_COMPUTERS
,
588 DSOP_DOWNLEVEL_FILTER_COMPUTERS
596 InitInfo
.cbSize
= sizeof(InitInfo
);
597 InitInfo
.pwzTargetComputer
= NULL
;
598 InitInfo
.cDsScopeInfos
= sizeof(Scopes
) / sizeof(Scopes
[0]);
599 InitInfo
.aDsScopeInfos
= Scopes
;
600 InitInfo
.flOptions
= 0;
601 InitInfo
.cAttributesToFetch
= 0;
602 InitInfo
.apwzAttributeNames
= NULL
;
604 hRet
= (*pDsObjectPicker
)->lpVtbl
->Initialize(*pDsObjectPicker
,
609 /* delete the object picker in case initialization failed! */
610 (*pDsObjectPicker
)->lpVtbl
->Release(*pDsObjectPicker
);
618 InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker
*pDsObjectPicker
,
619 IN HWND hwndParent OPTIONAL
,
623 IDataObject
*pdo
= NULL
;
626 hRet
= pDsObjectPicker
->lpVtbl
->InvokeDialog(pDsObjectPicker
,
634 fe
.cfFormat
= RegisterClipboardFormat(CFSTR_DSOP_DS_SELECTION_LIST
);
636 fe
.dwAspect
= DVASPECT_CONTENT
;
638 fe
.tymed
= TYMED_HGLOBAL
;
640 hRet
= pdo
->lpVtbl
->GetData(pdo
,
645 PDS_SELECTION_LIST SelectionList
= (PDS_SELECTION_LIST
)GlobalLock(stm
.hGlobal
);
646 if (SelectionList
!= NULL
)
648 if (SelectionList
->cItems
== 1)
650 UINT nlen
= wcslen(SelectionList
->aDsSelection
[0].pwzName
);
657 SelectionList
->aDsSelection
[0].pwzName
,
658 nlen
* sizeof(WCHAR
));
660 WideCharToMultiByte(CP_ACP
,
662 SelectionList
->aDsSelection
[0].pwzName
,
669 lpBuffer
[nlen
] = L
'\0';
672 GlobalUnlock(stm
.hGlobal
);
675 ReleaseStgMedium(&stm
);
678 pdo
->lpVtbl
->Release(pdo
);
685 FreeObjectPicker(IN IDsObjectPicker
*pDsObjectPicker
)
687 pDsObjectPicker
->lpVtbl
->Release(pDsObjectPicker
);
690 /*******************************************************************************
692 * FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
694 * PURPOSE: Processes WM_COMMAND messages for the main frame window.
697 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
699 HKEY hKeyRoot
= 0, hKey
= 0;
703 REGSAM regsam
= KEY_READ
;
707 switch (LOWORD(wParam
)) {
708 case ID_REGISTRY_IMPORTREGISTRYFILE
:
709 ImportRegistryFile(hWnd
);
711 case ID_REGISTRY_EXPORTREGISTRYFILE
:
712 ExportRegistryFile(hWnd
);
714 case ID_REGISTRY_CONNECTNETWORKREGISTRY
:
716 IDsObjectPicker
*ObjectPicker
;
717 TCHAR szComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
720 hRet
= CoInitialize(NULL
);
723 hRet
= InitializeRemoteRegistryPicker(&ObjectPicker
);
726 hRet
= InvokeRemoteRegistryPickerDialog(ObjectPicker
,
729 sizeof(szComputerName
) / sizeof(szComputerName
[0]));
732 /* FIXME - connect to the registry */
735 FreeObjectPicker(ObjectPicker
);
743 case ID_REGISTRY_DISCONNECTNETWORKREGISTRY
:
745 case ID_REGISTRY_PRINT
:
746 PrintRegistryHive(hWnd
, _T(""));
748 case ID_REGISTRY_EXIT
:
751 case ID_VIEW_STATUSBAR
:
752 toggle_child(hWnd
, LOWORD(wParam
), hStatusBar
);
754 case ID_HELP_HELPTOPICS
:
755 WinHelp(hWnd
, _T("regedit"), HELP_FINDER
, 0);
764 GetClientRect(g_pChildWnd
->hWnd
, &rt
);
765 pt
.x
= rt
.left
+ g_pChildWnd
->nSplitPos
;
766 pt
.y
= (rt
.bottom
/ 2);
768 if(ClientToScreen(g_pChildWnd
->hWnd
, &pts
))
770 SetCursorPos(pts
.x
, pts
.y
);
771 SetCursor(LoadCursor(0, IDC_SIZEWE
));
772 SendMessage(g_pChildWnd
->hWnd
, WM_LBUTTONDOWN
, 0, MAKELPARAM(pt
.x
, pt
.y
));
778 case ID_EDIT_MODIFY_BIN
:
784 keyPath
= GetItemPath(g_pChildWnd
->hTreeWnd
, 0, &hKeyRoot
);
785 valueName
= GetValueName(g_pChildWnd
->hListWnd
, -1);
787 lRet
= RegOpenKeyEx(hKeyRoot
, keyPath
, 0, regsam
, &hKey
);
788 if (lRet
!= ERROR_SUCCESS
) hKey
= 0;
791 switch (LOWORD(wParam
)) {
793 if (valueName
&& ModifyValue(hWnd
, hKey
, valueName
, FALSE
))
794 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
796 case ID_EDIT_MODIFY_BIN
:
797 if (valueName
&& ModifyValue(hWnd
, hKey
, valueName
, TRUE
))
798 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
801 if(ListView_GetSelectedCount(g_pChildWnd
->hListWnd
) == 1)
803 item
= ListView_GetNextItem(g_pChildWnd
->hListWnd
, -1, LVNI_SELECTED
);
806 ListView_EditLabel(g_pChildWnd
->hListWnd
, item
);
812 UINT nSelected
= ListView_GetSelectedCount(g_pChildWnd
->hListWnd
);
815 TCHAR msg
[128], caption
[128];
816 LoadString(hInst
, IDS_QUERY_DELETE_CONFIRM
, caption
, sizeof(caption
)/sizeof(TCHAR
));
817 LoadString(hInst
, (nSelected
== 1 ? IDS_QUERY_DELETE_ONE
: IDS_QUERY_DELETE_MORE
), msg
, sizeof(msg
)/sizeof(TCHAR
));
818 if(MessageBox(g_pChildWnd
->hWnd
, msg
, caption
, MB_ICONQUESTION
| MB_YESNO
) == IDYES
)
824 while((ni
= ListView_GetNextItem(g_pChildWnd
->hListWnd
, item
, LVNI_SELECTED
)) > -1)
826 valueName
= GetValueName(g_pChildWnd
->hListWnd
, item
);
827 if(RegDeleteValue(hKey
, valueName
) != ERROR_SUCCESS
)
834 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
837 LoadString(hInst
, IDS_ERR_DELVAL_CAPTION
, caption
, sizeof(caption
)/sizeof(TCHAR
));
838 LoadString(hInst
, IDS_ERR_DELETEVALUE
, msg
, sizeof(msg
)/sizeof(TCHAR
));
839 MessageBox(g_pChildWnd
->hWnd
, msg
, caption
, MB_ICONSTOP
);
844 case ID_EDIT_NEW_STRINGVALUE
:
845 CreateNewValue(hKeyRoot
, keyPath
, REG_SZ
);
847 case ID_EDIT_NEW_BINARYVALUE
:
848 CreateNewValue(hKeyRoot
, keyPath
, REG_BINARY
);
850 case ID_EDIT_NEW_DWORDVALUE
:
851 CreateNewValue(hKeyRoot
, keyPath
, REG_DWORD
);
854 case ID_EDIT_COPYKEYNAME
:
855 CopyKeyName(hWnd
, _T(""));
857 case ID_EDIT_PERMISSIONS
:
858 if(keyPath
!= NULL
&& _tcslen(keyPath
) > 0)
860 RegKeyEditPermissions(hWnd
, hKey
, NULL
, keyPath
);
864 MessageBeep(MB_ICONASTERISK
);
867 case ID_REGISTRY_PRINTERSETUP
:
870 /*PAGESETUPDLG psd;*/
871 /*PageSetupDlg(&psd);*/
873 case ID_REGISTRY_OPENLOCAL
:
876 case ID_VIEW_REFRESH
:
877 RefreshTreeView(g_pChildWnd
->hTreeWnd
);
878 /*RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); */
880 /*case ID_OPTIONS_TOOLBAR:*/
881 /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
883 case ID_EDIT_NEW_KEY
:
884 CreateNewKey(g_pChildWnd
->hTreeWnd
, TreeView_GetSelection(g_pChildWnd
->hTreeWnd
));
895 /********************************************************************************
897 * FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
899 * PURPOSE: Processes messages for the main frame window.
901 * WM_COMMAND - process the application menu
902 * WM_DESTROY - post a quit message and return
906 LRESULT CALLBACK
FrameWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
910 CreateWindowEx(0, szChildClass
, NULL
, WS_CHILD
| WS_VISIBLE
,
911 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
912 hWnd
, (HMENU
)0, hInst
, 0);
915 if (!_CmdWndProc(hWnd
, message
, wParam
, lParam
))
916 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
920 SetFocus(g_pChildWnd
->hWnd
);
923 resize_frame_client(hWnd
);
927 case WM_ENTERMENULOOP
:
928 OnEnterMenuLoop(hWnd
);
930 case WM_EXITMENULOOP
:
931 OnExitMenuLoop(hWnd
);
934 OnMenuSelect(hWnd
, LOWORD(wParam
), HIWORD(wParam
), (HMENU
)lParam
);
937 WinHelp(hWnd
, _T("regedit"), HELP_QUIT
, 0);
940 return DefWindowProc(hWnd
, message
, wParam
, lParam
);