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 LPCSTR pszExportKeyPath
;
370 CHAR buffer
[_MAX_PATH
];
372 WideCharToMultiByte(CP_ACP
, 0, ExportKeyPath
, -1, buffer
, sizeof(buffer
), NULL
, NULL
);
373 pszExportKeyPath
= buffer
;
375 pszExportKeyPath
= ExportKeyPath
;
378 result
= export_registry_key(ofn
.lpstrFile
, pszExportKeyPath
);
380 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
384 TCHAR filename
[MAX_PATH
];
386 get_file_name(&s
, filename
, MAX_PATH
);
388 printf("No file name is specified\n%s", usage
);
393 TCHAR reg_key_name
[KEY_MAX_LEN
];
394 get_file_name(&s
, reg_key_name
, KEY_MAX_LEN
);
395 export_registry_key((CHAR
)filename
, reg_key_name
);
397 export_registry_key(filename
, NULL
);
402 CheckCommDlgError(hWnd
);
407 BOOL
PrintRegistryHive(HWND hWnd
, LPTSTR path
)
412 ZeroMemory(&pd
, sizeof(PRINTDLG
));
413 pd
.lStructSize
= sizeof(PRINTDLG
);
415 pd
.hDevMode
= NULL
; /* Don't forget to free or store hDevMode*/
416 pd
.hDevNames
= NULL
; /* Don't forget to free or store hDevNames*/
417 pd
.Flags
= PD_USEDEVMODECOPIESANDCOLLATE
| PD_RETURNDC
;
419 pd
.nFromPage
= 0xFFFF;
422 pd
.nMaxPage
= 0xFFFF;
424 /* GDI calls to render output. */
425 DeleteDC(pd
.hDC
); /* Delete DC when done.*/
431 hResult
= PrintDlgEx(&pd
);
432 if (hResult
== S_OK
) {
433 switch (pd
.dwResultAction
) {
434 case PD_RESULT_APPLY
:
435 /*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. */
437 case PD_RESULT_CANCEL
:
438 /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
440 case PD_RESULT_PRINT
:
441 /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
449 /*Insufficient memory. */
452 /* One or more arguments are invalid. */
455 /*Invalid pointer. */
461 /*Unspecified error. */
472 static BOOL
CopyKeyName(HWND hWnd
, LPCTSTR keyName
)
476 result
= OpenClipboard(hWnd
);
478 result
= EmptyClipboard();
481 /*HANDLE hClipData;*/
482 /*hClipData = SetClipboardData(UINT uFormat, HANDLE hMem);*/
485 /* error emptying clipboard*/
486 /* DWORD dwError = GetLastError(); */
489 if (!CloseClipboard()) {
490 /* error closing clipboard*/
491 /* DWORD dwError = GetLastError(); */
495 /* error opening clipboard*/
496 /* DWORD dwError = GetLastError(); */
502 static BOOL
CreateNewValue(HKEY hRootKey
, LPCTSTR pszKeyPath
, DWORD dwType
)
504 TCHAR szNewValueFormat
[128];
505 TCHAR szNewValue
[128];
508 DWORD dwExistingType
, cbData
;
513 if (RegOpenKey(hRootKey
, pszKeyPath
, &hKey
) != ERROR_SUCCESS
)
516 LoadString(hInst
, IDS_NEW_VALUE
, szNewValueFormat
, sizeof(szNewValueFormat
)
517 / sizeof(szNewValueFormat
[0]));
521 _sntprintf(szNewValue
, sizeof(szNewValue
) / sizeof(szNewValue
[0]),
522 szNewValueFormat
, iIndex
++);
524 cbData
= sizeof(data
);
525 lResult
= RegQueryValueEx(hKey
, szNewValue
, NULL
, &dwExistingType
, data
, &cbData
);
527 while(lResult
== ERROR_SUCCESS
);
531 cbData
= sizeof(DWORD
);
535 cbData
= sizeof(TCHAR
);
538 cbData
= sizeof(TCHAR
) * 2;
541 cbData
= sizeof(DWORD
) * 2;
547 memset(data
, 0, cbData
);
548 lResult
= RegSetValueEx(hKey
, szNewValue
, 0, dwType
, data
, cbData
);
549 if (lResult
!= ERROR_SUCCESS
)
552 RefreshListView(g_pChildWnd
->hListWnd
, hRootKey
, pszKeyPath
);
554 /* locate the newly added value, and get ready to rename it */
555 memset(&lvfi
, 0, sizeof(lvfi
));
556 lvfi
.flags
= LVFI_STRING
;
557 lvfi
.psz
= szNewValue
;
558 iIndex
= ListView_FindItem(g_pChildWnd
->hListWnd
, -1, &lvfi
);
560 ListView_EditLabel(g_pChildWnd
->hListWnd
, iIndex
);
566 InitializeRemoteRegistryPicker(OUT IDsObjectPicker
**pDsObjectPicker
)
570 *pDsObjectPicker
= NULL
;
572 hRet
= CoCreateInstance(&CLSID_DsObjectPicker
,
574 CLSCTX_INPROC_SERVER
,
575 &IID_IDsObjectPicker
,
576 (LPVOID
*)pDsObjectPicker
);
579 DSOP_INIT_INFO InitInfo
;
580 static DSOP_SCOPE_INIT_INFO Scopes
[] =
583 sizeof(DSOP_SCOPE_INIT_INFO
),
584 DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE
| DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE
|
585 DSOP_SCOPE_TYPE_GLOBAL_CATALOG
| DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN
|
586 DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN
| DSOP_SCOPE_TYPE_WORKGROUP
|
587 DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN
| DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN
,
591 DSOP_FILTER_COMPUTERS
,
595 DSOP_DOWNLEVEL_FILTER_COMPUTERS
603 InitInfo
.cbSize
= sizeof(InitInfo
);
604 InitInfo
.pwzTargetComputer
= NULL
;
605 InitInfo
.cDsScopeInfos
= sizeof(Scopes
) / sizeof(Scopes
[0]);
606 InitInfo
.aDsScopeInfos
= Scopes
;
607 InitInfo
.flOptions
= 0;
608 InitInfo
.cAttributesToFetch
= 0;
609 InitInfo
.apwzAttributeNames
= NULL
;
611 hRet
= (*pDsObjectPicker
)->lpVtbl
->Initialize(*pDsObjectPicker
,
616 /* delete the object picker in case initialization failed! */
617 (*pDsObjectPicker
)->lpVtbl
->Release(*pDsObjectPicker
);
625 InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker
*pDsObjectPicker
,
626 IN HWND hwndParent OPTIONAL
,
630 IDataObject
*pdo
= NULL
;
633 hRet
= pDsObjectPicker
->lpVtbl
->InvokeDialog(pDsObjectPicker
,
641 fe
.cfFormat
= RegisterClipboardFormat(CFSTR_DSOP_DS_SELECTION_LIST
);
643 fe
.dwAspect
= DVASPECT_CONTENT
;
645 fe
.tymed
= TYMED_HGLOBAL
;
647 hRet
= pdo
->lpVtbl
->GetData(pdo
,
652 PDS_SELECTION_LIST SelectionList
= (PDS_SELECTION_LIST
)GlobalLock(stm
.hGlobal
);
653 if (SelectionList
!= NULL
)
655 if (SelectionList
->cItems
== 1)
657 UINT nlen
= wcslen(SelectionList
->aDsSelection
[0].pwzName
);
664 SelectionList
->aDsSelection
[0].pwzName
,
665 nlen
* sizeof(WCHAR
));
667 WideCharToMultiByte(CP_ACP
,
669 SelectionList
->aDsSelection
[0].pwzName
,
676 lpBuffer
[nlen
] = L
'\0';
679 GlobalUnlock(stm
.hGlobal
);
682 ReleaseStgMedium(&stm
);
685 pdo
->lpVtbl
->Release(pdo
);
692 FreeObjectPicker(IN IDsObjectPicker
*pDsObjectPicker
)
694 pDsObjectPicker
->lpVtbl
->Release(pDsObjectPicker
);
697 /*******************************************************************************
699 * FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
701 * PURPOSE: Processes WM_COMMAND messages for the main frame window.
704 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
706 HKEY hKeyRoot
= 0, hKey
= 0;
710 REGSAM regsam
= KEY_READ
;
714 switch (LOWORD(wParam
)) {
715 case ID_REGISTRY_IMPORTREGISTRYFILE
:
716 ImportRegistryFile(hWnd
);
718 case ID_REGISTRY_EXPORTREGISTRYFILE
:
719 ExportRegistryFile(hWnd
);
721 case ID_REGISTRY_CONNECTNETWORKREGISTRY
:
723 IDsObjectPicker
*ObjectPicker
;
724 TCHAR szComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
727 hRet
= CoInitialize(NULL
);
730 hRet
= InitializeRemoteRegistryPicker(&ObjectPicker
);
733 hRet
= InvokeRemoteRegistryPickerDialog(ObjectPicker
,
736 sizeof(szComputerName
) / sizeof(szComputerName
[0]));
739 /* FIXME - connect to the registry */
742 FreeObjectPicker(ObjectPicker
);
750 case ID_REGISTRY_DISCONNECTNETWORKREGISTRY
:
752 case ID_REGISTRY_PRINT
:
753 PrintRegistryHive(hWnd
, _T(""));
755 case ID_REGISTRY_EXIT
:
758 case ID_VIEW_STATUSBAR
:
759 toggle_child(hWnd
, LOWORD(wParam
), hStatusBar
);
761 case ID_HELP_HELPTOPICS
:
762 WinHelp(hWnd
, _T("regedit"), HELP_FINDER
, 0);
771 GetClientRect(g_pChildWnd
->hWnd
, &rt
);
772 pt
.x
= rt
.left
+ g_pChildWnd
->nSplitPos
;
773 pt
.y
= (rt
.bottom
/ 2);
775 if(ClientToScreen(g_pChildWnd
->hWnd
, &pts
))
777 SetCursorPos(pts
.x
, pts
.y
);
778 SetCursor(LoadCursor(0, IDC_SIZEWE
));
779 SendMessage(g_pChildWnd
->hWnd
, WM_LBUTTONDOWN
, 0, MAKELPARAM(pt
.x
, pt
.y
));
785 case ID_EDIT_MODIFY_BIN
:
791 keyPath
= GetItemPath(g_pChildWnd
->hTreeWnd
, 0, &hKeyRoot
);
792 valueName
= GetValueName(g_pChildWnd
->hListWnd
, -1);
794 lRet
= RegOpenKeyEx(hKeyRoot
, keyPath
, 0, regsam
, &hKey
);
795 if (lRet
!= ERROR_SUCCESS
) hKey
= 0;
798 switch (LOWORD(wParam
)) {
800 if (valueName
&& ModifyValue(hWnd
, hKey
, valueName
, FALSE
))
801 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
803 case ID_EDIT_MODIFY_BIN
:
804 if (valueName
&& ModifyValue(hWnd
, hKey
, valueName
, TRUE
))
805 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
808 if(ListView_GetSelectedCount(g_pChildWnd
->hListWnd
) == 1)
810 item
= ListView_GetNextItem(g_pChildWnd
->hListWnd
, -1, LVNI_SELECTED
);
813 ListView_EditLabel(g_pChildWnd
->hListWnd
, item
);
819 UINT nSelected
= ListView_GetSelectedCount(g_pChildWnd
->hListWnd
);
822 TCHAR msg
[128], caption
[128];
823 LoadString(hInst
, IDS_QUERY_DELETE_CONFIRM
, caption
, sizeof(caption
)/sizeof(TCHAR
));
824 LoadString(hInst
, (nSelected
== 1 ? IDS_QUERY_DELETE_ONE
: IDS_QUERY_DELETE_MORE
), msg
, sizeof(msg
)/sizeof(TCHAR
));
825 if(MessageBox(g_pChildWnd
->hWnd
, msg
, caption
, MB_ICONQUESTION
| MB_YESNO
) == IDYES
)
831 while((ni
= ListView_GetNextItem(g_pChildWnd
->hListWnd
, item
, LVNI_SELECTED
)) > -1)
833 valueName
= GetValueName(g_pChildWnd
->hListWnd
, item
);
834 if(RegDeleteValue(hKey
, valueName
) != ERROR_SUCCESS
)
841 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
844 LoadString(hInst
, IDS_ERR_DELVAL_CAPTION
, caption
, sizeof(caption
)/sizeof(TCHAR
));
845 LoadString(hInst
, IDS_ERR_DELETEVALUE
, msg
, sizeof(msg
)/sizeof(TCHAR
));
846 MessageBox(g_pChildWnd
->hWnd
, msg
, caption
, MB_ICONSTOP
);
851 case ID_EDIT_NEW_STRINGVALUE
:
852 CreateNewValue(hKeyRoot
, keyPath
, REG_SZ
);
854 case ID_EDIT_NEW_BINARYVALUE
:
855 CreateNewValue(hKeyRoot
, keyPath
, REG_BINARY
);
857 case ID_EDIT_NEW_DWORDVALUE
:
858 CreateNewValue(hKeyRoot
, keyPath
, REG_DWORD
);
861 case ID_EDIT_COPYKEYNAME
:
862 CopyKeyName(hWnd
, _T(""));
864 case ID_EDIT_PERMISSIONS
:
865 if(keyPath
!= NULL
&& _tcslen(keyPath
) > 0)
867 RegKeyEditPermissions(hWnd
, hKey
, NULL
, keyPath
);
871 MessageBeep(MB_ICONASTERISK
);
874 case ID_REGISTRY_PRINTERSETUP
:
877 /*PAGESETUPDLG psd;*/
878 /*PageSetupDlg(&psd);*/
880 case ID_REGISTRY_OPENLOCAL
:
883 case ID_VIEW_REFRESH
:
884 RefreshTreeView(g_pChildWnd
->hTreeWnd
);
885 /*RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); */
887 /*case ID_OPTIONS_TOOLBAR:*/
888 /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
890 case ID_EDIT_NEW_KEY
:
891 CreateNewKey(g_pChildWnd
->hTreeWnd
, TreeView_GetSelection(g_pChildWnd
->hTreeWnd
));
902 /********************************************************************************
904 * FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
906 * PURPOSE: Processes messages for the main frame window.
908 * WM_COMMAND - process the application menu
909 * WM_DESTROY - post a quit message and return
913 LRESULT CALLBACK
FrameWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
917 CreateWindowEx(0, szChildClass
, NULL
, WS_CHILD
| WS_VISIBLE
,
918 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
919 hWnd
, (HMENU
)0, hInst
, 0);
922 if (!_CmdWndProc(hWnd
, message
, wParam
, lParam
))
923 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
927 SetFocus(g_pChildWnd
->hWnd
);
930 resize_frame_client(hWnd
);
934 case WM_ENTERMENULOOP
:
935 OnEnterMenuLoop(hWnd
);
937 case WM_EXITMENULOOP
:
938 OnExitMenuLoop(hWnd
);
941 OnMenuSelect(hWnd
, LOWORD(wParam
), HIWORD(wParam
), (HMENU
)lParam
);
944 WinHelp(hWnd
, _T("regedit"), HELP_QUIT
, 0);
947 return DefWindowProc(hWnd
, message
, wParam
, lParam
);