#include "regedit.h"
+#include <commdlg.h>
+#include <cderr.h>
+#include <objsel.h>
+
/********************************************************************************
* Global and Local Variables:
*/
static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
+extern WCHAR Suggestions[256];
/*******************************************************************************
* Local module support methods
*/
static void resize_frame_rect(HWND hWnd, PRECT prect)
{
- RECT rt;
- /*
- if (IsWindowVisible(hToolBar)) {
- SendMessageW(hToolBar, WM_SIZE, 0, 0);
- GetClientRect(hToolBar, &rt);
- prect->top = rt.bottom+3;
- prect->bottom -= rt.bottom+3;
- }
- */
if (IsWindowVisible(hStatusBar))
{
+ RECT rt;
+
SetupStatusBar(hWnd, TRUE);
- GetClientRect(hStatusBar, &rt);
- prect->bottom -= rt.bottom;
+ GetWindowRect(hStatusBar, &rt);
+ prect->bottom -= rt.bottom - rt.top;
}
MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
}
dwIndex = 0;
do
{
- cbValueName = COUNT_OF(szValueName);
+ cbValueName = ARRAY_SIZE(szValueName);
cbValueData = sizeof(abValueData);
lResult = RegEnumValueW(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData);
if ((lResult == ERROR_SUCCESS) && (dwType == REG_SZ))
{
WCHAR str[100];
- wcscpy(str, L"");
+ str[0] = UNICODE_NULL;
if (nFlags & MF_POPUP)
{
if (hSysMenu != GetMenu(hWnd))
void UpdateStatusBar(void)
{
- NMHDR nmhdr;
- ZeroMemory(&nmhdr, sizeof(NMHDR));
- nmhdr.code = TVN_SELCHANGED;
- SendMessageW(g_pChildWnd->hWnd, WM_NOTIFY, (WPARAM)TREE_WINDOW, (LPARAM)&nmhdr);
+ HKEY hKeyRoot;
+ LPCWSTR pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
+
+ SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)pszKeyPath);
}
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
return TRUE;
}
-WCHAR FileNameBuffer[_MAX_PATH];
-WCHAR FileTitleBuffer[_MAX_PATH];
+WCHAR FileNameBuffer[MAX_PATH];
typedef struct
{
c = 0;
for(i = 0; i < PairCount; i++)
{
- c += LoadStringW(hInst, Pairs[i].DisplayID, &Filter[c], 255 * sizeof(WCHAR));
+ c += LoadStringW(hInst, Pairs[i].DisplayID, &Filter[c], 255);
Filter[++c] = L'\0';
- c += LoadStringW(hInst, Pairs[i].FilterID, &Filter[c], 255 * sizeof(WCHAR));
+ c += LoadStringW(hInst, Pairs[i].FilterID, &Filter[c], 255);
Filter[++c] = L'\0';
}
Filter[++c] = L'\0';
}
-static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
+static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn, BOOL bSave)
{
- FILTERPAIR FilterPairs[4];
+ FILTERPAIR FilterPairs[5];
static WCHAR Filter[1024];
memset(pofn, 0, sizeof(OPENFILENAME));
FilterPairs[1].FilterID = IDS_FLT_HIVFILES_FLT;
FilterPairs[2].DisplayID = IDS_FLT_REGEDIT4;
FilterPairs[2].FilterID = IDS_FLT_REGEDIT4_FLT;
- FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
- FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
- BuildFilterStrings(Filter, FilterPairs, COUNT_OF(FilterPairs));
+ if (bSave)
+ {
+ FilterPairs[3].DisplayID = IDS_FLT_TXTFILES;
+ FilterPairs[3].FilterID = IDS_FLT_TXTFILES_FLT;
+ FilterPairs[4].DisplayID = IDS_FLT_ALLFILES;
+ FilterPairs[4].FilterID = IDS_FLT_ALLFILES_FLT;
+ }
+ else
+ {
+ FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
+ FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
+ }
+
+ BuildFilterStrings(Filter, FilterPairs, ARRAY_SIZE(FilterPairs) - !bSave);
pofn->lpstrFilter = Filter;
pofn->lpstrFile = FileNameBuffer;
- pofn->nMaxFile = _MAX_PATH;
- pofn->lpstrFileTitle = FileTitleBuffer;
- pofn->nMaxFileTitle = _MAX_PATH;
- pofn->Flags = OFN_HIDEREADONLY;
+ pofn->nMaxFile = _countof(FileNameBuffer);
+ pofn->Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
pofn->lpstrDefExt = L"reg";
+ if (bSave)
+ pofn->Flags |= OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
+ else
+ pofn->Flags |= OFN_FILEMUSTEXIST;
+
return TRUE;
}
/* get the item key to load the hive in */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
/* initialize the "open file" dialog */
- InitOpenFileName(hWnd, &ofn);
+ InitOpenFileName(hWnd, &ofn, FALSE);
/* build the "All Files" filter up */
filter.DisplayID = IDS_FLT_ALLFILES;
filter.FilterID = IDS_FLT_ALLFILES_FLT;
- BuildFilterStrings(Filter, &filter, sizeof(filter));
+ BuildFilterStrings(Filter, &filter, 1);
ofn.lpstrFilter = Filter;
/* load and set the caption and flags for dialog */
- LoadStringW(hInst, IDS_LOAD_HIVE, Caption, COUNT_OF(Caption));
+ LoadStringW(hInst, IDS_LOAD_HIVE, Caption, ARRAY_SIZE(Caption));
ofn.lpstrTitle = Caption;
ofn.Flags |= OFN_ENABLESIZING;
- /* ofn.lCustData = ;*/
+
/* now load the hive */
if (GetOpenFileName(&ofn))
{
/* refresh tree and list views */
RefreshTreeView(g_pChildWnd->hTreeWnd);
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
- RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
+ RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
}
else
{
/* get the item key to unload */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
/* load and set the caption and flags for dialog */
- LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));
+ LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, ARRAY_SIZE(Caption));
/* Enable the 'restore' privilege, unload the hive, disable the privilege */
EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
/* refresh tree and list views */
RefreshTreeView(g_pChildWnd->hTreeWnd);
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
- RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
+ RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
}
else
{
/* Figure out in which key path we are importing */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
- InitOpenFileName(hWnd, &ofn);
- LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, COUNT_OF(Caption));
+ InitOpenFileName(hWnd, &ofn, FALSE);
+ LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, ARRAY_SIZE(Caption));
ofn.lpstrTitle = Caption;
ofn.Flags |= OFN_ENABLESIZING;
- /* ofn.lCustData = ;*/
+
if (GetOpenFileName(&ofn))
{
/* Look at the extension of the file to determine its type */
_wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"reg") == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
{
/* Open the file */
- FILE* fp = _wfopen(ofn.lpstrFile, L"r");
+ FILE* fp = _wfopen(ofn.lpstrFile, L"rb");
/* Import it */
if (fp == NULL || !import_registry_file(fp))
{
/* Error opening the file */
- LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
- LoadStringW(hInst, IDS_IMPORT_ERROR, szText, COUNT_OF(szText));
+ LoadStringW(hInst, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
+ LoadStringW(hInst, IDS_IMPORT_ERROR, szText, ARRAY_SIZE(szText));
InfoMessageBox(hWnd, MB_OK | MB_ICONERROR, szTitle, szText, ofn.lpstrFile);
bRet = FALSE;
}
else
{
/* Show successful import */
- LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
- LoadStringW(hInst, IDS_IMPORT_OK, szText, COUNT_OF(szText));
+ LoadStringW(hInst, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
+ LoadStringW(hInst, IDS_IMPORT_OK, szText, ARRAY_SIZE(szText));
InfoMessageBox(hWnd, MB_OK | MB_ICONINFORMATION, szTitle, szText, ofn.lpstrFile);
bRet = TRUE;
}
}
else /* Registry Hive Files */
{
- LoadStringW(hInst, IDS_QUERY_IMPORT_HIVE_CAPTION, szTitle, COUNT_OF(szTitle));
- LoadStringW(hInst, IDS_QUERY_IMPORT_HIVE_MSG, szText, COUNT_OF(szText));
+ LoadStringW(hInst, IDS_QUERY_IMPORT_HIVE_CAPTION, szTitle, ARRAY_SIZE(szTitle));
+ LoadStringW(hInst, IDS_QUERY_IMPORT_HIVE_MSG, szText, ARRAY_SIZE(szText));
/* Display a confirmation message */
if (MessageBoxW(g_pChildWnd->hWnd, szText, szTitle, MB_ICONWARNING | MB_YESNO) == IDYES)
/* refresh tree and list views */
RefreshTreeView(g_pChildWnd->hTreeWnd);
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
- RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, pszKeyPath);
+ RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, pszKeyPath, TRUE);
return bRet;
}
{
GetWindowTextW(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
}
- else
+ else if (pszSelectedKey)
{
pszSelectedKey[0] = L'\0';
}
{
BOOL bRet = FALSE;
OPENFILENAME ofn;
- WCHAR ExportKeyPath[_MAX_PATH];
+ WCHAR ExportKeyPath[_MAX_PATH] = {0};
WCHAR Caption[128], szTitle[512], szText[512];
HKEY hKeyRoot;
LPCWSTR pszKeyPath;
/* Figure out which key path we are exporting */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
- GetKeyName(ExportKeyPath, COUNT_OF(ExportKeyPath), hKeyRoot, pszKeyPath);
+ GetKeyName(ExportKeyPath, ARRAY_SIZE(ExportKeyPath), hKeyRoot, pszKeyPath);
- InitOpenFileName(hWnd, &ofn);
- LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, COUNT_OF(Caption));
+ InitOpenFileName(hWnd, &ofn, TRUE);
+ LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, ARRAY_SIZE(Caption));
ofn.lpstrTitle = Caption;
/* Only set the path if a key (not the root node) is selected */
{
ofn.lCustData = (LPARAM) ExportKeyPath;
}
- ofn.Flags = OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_OVERWRITEPROMPT;
+ ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ENABLEHOOK;
ofn.lpfnHook = ExportRegistryFile_OFNHookProc;
ofn.lpTemplateName = MAKEINTRESOURCEW(IDD_EXPORTRANGE);
if (GetSaveFileName(&ofn))
: REG_FORMAT_5)))
{
/* Error creating the file */
- LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
- LoadStringW(hInst, IDS_EXPORT_ERROR, szText, COUNT_OF(szText));
+ LoadStringW(hInst, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
+ LoadStringW(hInst, IDS_EXPORT_ERROR, szText, ARRAY_SIZE(szText));
InfoMessageBox(hWnd, MB_OK | MB_ICONERROR, szTitle, szText, ofn.lpstrFile);
bRet = FALSE;
}
break;
}
+
+ case 4: /* Text File */
+ {
+ bRet = txt_export_registry_key(ofn.lpstrFile, ExportKeyPath);
+ if (!bRet)
+ {
+ /* Error creating the file */
+ LoadStringW(hInst, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
+ LoadStringW(hInst, IDS_EXPORT_ERROR, szText, ARRAY_SIZE(szText));
+ InfoMessageBox(hWnd, MB_OK | MB_ICONERROR, szTitle, szText, ofn.lpstrFile);
+ }
+ break;
+ }
}
}
else
if (RegOpenKeyExW(HKEY_CURRENT_USER, s_szFavoritesRegKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
goto done;
- cbData = (sizeof(szFavoritePath) / sizeof(szFavoritePath[0])) - 1;
+ cbData = sizeof(szFavoritePath);
memset(szFavoritePath, 0, sizeof(szFavoritePath));
if (RegQueryValueExW(hKey, pszFavorite, NULL, &dwType, (LPBYTE) szFavoritePath, &cbData) != ERROR_SUCCESS)
goto done;
WCHAR szBuffer[512];
HGLOBAL hGlobal;
LPWSTR s;
+ SIZE_T cbGlobal;
if (!OpenClipboard(hWnd))
goto done;
if (!EmptyClipboard())
goto done;
- if (!GetKeyName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName))
+ if (!GetKeyName(szBuffer, ARRAY_SIZE(szBuffer), hRootKey, keyName))
goto done;
- hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
+ cbGlobal = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
+ hGlobal = GlobalAlloc(GMEM_MOVEABLE, cbGlobal);
if (!hGlobal)
goto done;
s = GlobalLock(hGlobal);
- wcscpy(s, szBuffer);
+ StringCbCopyW(s, cbGlobal, szBuffer);
GlobalUnlock(hGlobal);
SetClipboardData(CF_UNICODETEXT, hGlobal);
&hKey) != ERROR_SUCCESS)
return FALSE;
- LoadStringW(hInst, IDS_NEW_VALUE, szNewValueFormat, COUNT_OF(szNewValueFormat));
+ LoadStringW(hInst, IDS_NEW_VALUE, szNewValueFormat, ARRAY_SIZE(szNewValueFormat));
do
{
cbData = sizeof(WCHAR);
break;
case REG_MULTI_SZ:
- cbData = sizeof(WCHAR) * 2;
+ /*
+ * WARNING: An empty multi-string has only one null char.
+ * Indeed, multi-strings are built in the following form:
+ * str1\0str2\0...strN\0\0
+ * where each strI\0 is a null-terminated string, and it
+ * ends with a terminating empty string.
+ * Therefore an empty multi-string contains only the terminating
+ * empty string, that is, one null char.
+ */
+ cbData = sizeof(WCHAR);
break;
- case REG_QWORD:
- cbData = sizeof(DWORD) * 2;
+ case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
+ cbData = sizeof(DWORDLONG); // == sizeof(DWORD) * 2;
break;
default:
cbData = 0;
return FALSE;
}
- RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
+ RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
/* locate the newly added value, and get ready to rename it */
memset(&lvfi, 0, sizeof(lvfi));
lvfi.psz = szNewValue;
iIndex = ListView_FindItem(g_pChildWnd->hListWnd, -1, &lvfi);
if (iIndex >= 0)
+ {
+ ListView_SetItemState(g_pChildWnd->hListWnd, iIndex,
+ LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ ListView_EnsureVisible(g_pChildWnd->hListWnd, iIndex, FALSE);
(void)ListView_EditLabel(g_pChildWnd->hListWnd, iIndex);
+ }
return TRUE;
}
InitInfo.cbSize = sizeof(InitInfo);
InitInfo.pwzTargetComputer = NULL;
- InitInfo.cDsScopeInfos = COUNT_OF(Scopes);
+ InitInfo.cDsScopeInfos = ARRAY_SIZE(Scopes);
InitInfo.aDsScopeInfos = Scopes;
InitInfo.flOptions = 0;
InitInfo.cAttributesToFetch = 0;
LPCWSTR valueName;
BOOL result = TRUE;
REGSAM regsam = KEY_READ;
- LONG lRet;
int item;
UNREFERENCED_PARAMETER(lParam);
hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
hWnd,
szComputerName,
- COUNT_OF(szComputerName));
+ ARRAY_SIZE(szComputerName));
if (hRet == S_OK)
{
/* FIXME - connect to the registry */
toggle_child(hWnd, LOWORD(wParam), hStatusBar);
return TRUE;
case ID_HELP_HELPTOPICS:
- WinHelpW(hWnd, getAppName(), HELP_FINDER, 0);
+ WinHelpW(hWnd, L"regedit", HELP_FINDER, 0);
return TRUE;
case ID_HELP_ABOUT:
ShowAboutBox(hWnd);
valueName = GetValueName(g_pChildWnd->hListWnd, -1);
if (keyPath)
{
- lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey);
- if (lRet != ERROR_SUCCESS) hKey = 0;
+ if (RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey) != ERROR_SUCCESS)
+ hKey = 0;
}
switch (LOWORD(wParam))
{
case ID_EDIT_MODIFY:
if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
- RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+ RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
break;
case ID_EDIT_MODIFY_BIN:
if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
- RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+ RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
break;
case ID_EDIT_RENAME:
if (GetFocus() == g_pChildWnd->hListWnd)
break;
case ID_EDIT_DELETE:
{
- if (GetFocus() == g_pChildWnd->hListWnd)
+ if (GetFocus() == g_pChildWnd->hListWnd && hKey)
{
UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
if(nSelected >= 1)
{
WCHAR msg[128], caption[128];
- LoadStringW(hInst, IDS_QUERY_DELETE_CONFIRM, caption, COUNT_OF(caption));
- LoadStringW(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, COUNT_OF(msg));
+ LoadStringW(hInst, IDS_QUERY_DELETE_CONFIRM, caption, ARRAY_SIZE(caption));
+ LoadStringW(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, ARRAY_SIZE(msg));
if(MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
{
int ni, errs;
item = ni;
}
- RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+ RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
if(errs > 0)
{
- LoadStringW(hInst, IDS_ERR_DELVAL_CAPTION, caption, COUNT_OF(caption));
- LoadStringW(hInst, IDS_ERR_DELETEVALUE, msg, COUNT_OF(msg));
+ LoadStringW(hInst, IDS_ERR_DELVAL_CAPTION, caption, ARRAY_SIZE(caption));
+ LoadStringW(hInst, IDS_ERR_DELETEVALUE, msg, ARRAY_SIZE(msg));
MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
}
}
}
else if (GetFocus() == g_pChildWnd->hTreeWnd)
{
- if (keyPath == 0 || *keyPath == 0)
+ if (keyPath == NULL || *keyPath == UNICODE_NULL)
{
MessageBeep(MB_ICONHAND);
}
FindDialog(hWnd);
break;
case ID_EDIT_FINDNEXT:
- FindNext(hWnd);
+ FindNextMessageBox(hWnd);
break;
case ID_EDIT_COPYKEYNAME:
CopyKeyName(hWnd, hKeyRoot, keyPath);
case ID_VIEW_REFRESH:
RefreshTreeView(g_pChildWnd->hTreeWnd);
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
- RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+ RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, TRUE);
break;
/*case ID_OPTIONS_TOOLBAR:*/
/* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
case ID_EDIT_NEW_KEY:
CreateNewKey(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd));
break;
+
+ case ID_TREE_EXPANDBRANCH:
+ TreeView_Expand(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd), TVE_EXPAND);
+ break;
+ case ID_TREE_COLLAPSEBRANCH:
+ TreeView_Expand(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd), TVE_COLLAPSE);
+ break;
+ case ID_TREE_RENAME:
+ SetFocus(g_pChildWnd->hTreeWnd);
+ TreeView_EditLabel(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd));
+ break;
+ case ID_TREE_DELETE:
+ keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd), &hKeyRoot);
+ if (keyPath == 0 || *keyPath == 0)
+ {
+ MessageBeep(MB_ICONHAND);
+ }
+ else if (DeleteKey(hWnd, hKeyRoot, keyPath))
+ DeleteNode(g_pChildWnd->hTreeWnd, 0);
+ break;
+ case ID_TREE_EXPORT:
+ ExportRegistryFile(g_pChildWnd->hTreeWnd);
+ break;
+ case ID_TREE_PERMISSIONS:
+ keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetSelection(g_pChildWnd->hTreeWnd), &hKeyRoot);
+ RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
+ break;
+ case ID_SWITCH_PANELS:
+ {
+ BOOL bShiftDown = GetKeyState(VK_SHIFT) < 0;
+ HWND hwndItem = GetNextDlgTabItem(g_pChildWnd->hWnd, GetFocus(), bShiftDown);
+ if (hwndItem == g_pChildWnd->hAddressBarWnd)
+ PostMessageW(hwndItem, EM_SETSEL, 0, -1);
+ SetFocus(hwndItem);
+ }
+ break;
+
+ case ID_ADDRESS_FOCUS:
+ SendMessageW(g_pChildWnd->hAddressBarWnd, EM_SETSEL, 0, -1);
+ SetFocus(g_pChildWnd->hAddressBarWnd);
+ break;
+
default:
if ((LOWORD(wParam) >= ID_FAVORITES_MIN) && (LOWORD(wParam) <= ID_FAVORITES_MAX))
{
mii.fMask = MIIM_TYPE;
mii.fType = MFT_STRING;
mii.dwTypeData = szFavorite;
- mii.cch = COUNT_OF(szFavorite);
+ mii.cch = ARRAY_SIZE(szFavorite);
if (GetMenuItemInfo(hMenu, LOWORD(wParam) - ID_FAVORITES_MIN, TRUE, &mii))
{
ChooseFavorite(szFavorite);
}
}
+ else if ((LOWORD(wParam) >= ID_TREE_SUGGESTION_MIN) && (LOWORD(wParam) <= ID_TREE_SUGGESTION_MAX))
+ {
+ WORD wID = LOWORD(wParam);
+ LPCWSTR s = Suggestions;
+ while(wID > ID_TREE_SUGGESTION_MIN)
+ {
+ if (*s)
+ s += wcslen(s) + 1;
+ wID--;
+ }
+ SelectNode(g_pChildWnd->hTreeWnd, s);
+ }
else
{
result = FALSE;
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
+ RECT rc;
switch (message)
{
case WM_CREATE:
+ // For now, the Help dialog item is disabled because of lacking of HTML Help support
+ EnableMenuItem(GetMenu(hWnd), ID_HELP_HELPTOPICS, MF_BYCOMMAND | MF_GRAYED);
+ GetClientRect(hWnd, &rc);
CreateWindowExW(0, szChildClass, NULL, WS_CHILD | WS_VISIBLE,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- hWnd, (HMENU)0, hInst, 0);
+ rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
+ hWnd, (HMENU)0, hInst, 0);
break;
case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam))
return DefWindowProcW(hWnd, message, wParam, lParam);
break;
case WM_ACTIVATE:
- if (LOWORD(hWnd))
+ if (LOWORD(hWnd) && g_pChildWnd)
SetFocus(g_pChildWnd->hWnd);
break;
case WM_SIZE:
SendMessageW(g_pChildWnd->hTreeWnd, WM_SYSCOLORCHANGE, 0, 0);
break;
case WM_DESTROY:
- WinHelpW(hWnd, getAppName(), HELP_QUIT, 0);
+ WinHelpW(hWnd, L"regedit", HELP_QUIT, 0);
SaveSettings();
PostQuitMessage(0);
default: