[REGEDIT] Fix the search dialog not opening when the root node is selected. Patch by Joachim Henze (reactosfanboy).

Small changes by me.
CORE-13071 #resolve #comment Thanks!

svn path=/trunk/; revision=75458
This commit is contained in:
Mark Jansen 2017-07-30 14:04:44 +00:00
parent 24376e47c4
commit fa95932bfc
3 changed files with 27 additions and 23 deletions

View file

@ -23,7 +23,7 @@ add_rc_deps(regedit.rc ${regedit_rc_deps})
add_executable(regedit ${SOURCE} regedit.rc) add_executable(regedit ${SOURCE} regedit.rc)
set_module_type(regedit win32gui UNICODE) set_module_type(regedit win32gui UNICODE)
target_link_libraries(regedit uuid) target_link_libraries(regedit uuid)
add_importlibs(regedit user32 gdi32 advapi32 ole32 shell32 comctl32 comdlg32 shlwapi msvcrt kernel32) add_importlibs(regedit user32 gdi32 advapi32 ole32 shell32 comctl32 comdlg32 shlwapi msvcrt kernel32 ntdll)
add_pch(regedit regedit.h SOURCE) add_pch(regedit regedit.h SOURCE)
add_cd_file(TARGET regedit DESTINATION reactos FOR all) add_cd_file(TARGET regedit DESTINATION reactos FOR all)
#add_subdirectory(clb) #add_subdirectory(clb)

View file

@ -1033,7 +1033,6 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LPCWSTR valueName; LPCWSTR valueName;
BOOL result = TRUE; BOOL result = TRUE;
REGSAM regsam = KEY_READ; REGSAM regsam = KEY_READ;
LONG lRet;
int item; int item;
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
@ -1125,13 +1124,11 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot); keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
valueName = GetValueName(g_pChildWnd->hListWnd, -1); valueName = GetValueName(g_pChildWnd->hListWnd, -1);
if (keyPath)
if (!keyPath) {
return TRUE; if (RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey) != ERROR_SUCCESS)
hKey = 0;
lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey); }
if (lRet != ERROR_SUCCESS)
hKey = 0;
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
@ -1165,7 +1162,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case ID_EDIT_DELETE: case ID_EDIT_DELETE:
{ {
if (GetFocus() == g_pChildWnd->hListWnd) if (GetFocus() == g_pChildWnd->hListWnd && hKey)
{ {
UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd); UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
if(nSelected >= 1) if(nSelected >= 1)
@ -1201,7 +1198,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
else if (GetFocus() == g_pChildWnd->hTreeWnd) else if (GetFocus() == g_pChildWnd->hTreeWnd)
{ {
if (keyPath == 0 || *keyPath == 0) if (keyPath == NULL || *keyPath == UNICODE_NULL)
{ {
MessageBeep(MB_ICONHAND); MessageBeep(MB_ICONHAND);
} }

View file

@ -23,6 +23,7 @@
#include <strsafe.h> #include <strsafe.h>
const WCHAR g_szGeneralRegKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit"; const WCHAR g_szGeneralRegKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit";
DECLSPEC_IMPORT ULONG WINAPIV DbgPrint(PCH Format,...);
/* /*
VV,VV,VV,VV,WA,WA,WA,WA,WB,WB,WB,WB,R1,R1,R1,R1 VV,VV,VV,VV,WA,WA,WA,WA,WB,WB,WB,WB,R1,R1,R1,R1
@ -122,25 +123,31 @@ extern void SaveSettings(void)
{ {
RegistryBinaryConfig tConfig; RegistryBinaryConfig tConfig;
DWORD iBufferSize = sizeof(tConfig); DWORD iBufferSize = sizeof(tConfig);
WCHAR szBuffer[MAX_PATH]; WCHAR szBuffer[MAX_PATH]; /* FIXME: a complete registry path can be longer than that */
LPCWSTR keyPath, rootName; LPCWSTR keyPath, rootName;
HKEY hRootKey; HKEY hRootKey;
/* Save key position */ /* Save key position */
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
if (keyPath) rootName = get_root_key_name(hRootKey);
{
rootName = get_root_key_name(hRootKey);
/* Load "My Computer" string and complete it */ /* Load "My Computer" string and complete it */
if (LoadStringW(hInst, IDS_MY_COMPUTER, szBuffer, COUNT_OF(szBuffer)) && if (LoadStringW(hInst, IDS_MY_COMPUTER, szBuffer, COUNT_OF(szBuffer)) &&
SUCCEEDED(StringCbCatW(szBuffer, sizeof(szBuffer), L"\\")) && SUCCEEDED(StringCbCatW(szBuffer, sizeof(szBuffer), L"\\")) &&
SUCCEEDED(StringCbCatW(szBuffer, sizeof(szBuffer), rootName)) && SUCCEEDED(StringCbCatW(szBuffer, sizeof(szBuffer), rootName)) &&
SUCCEEDED(StringCbCatW(szBuffer, sizeof(szBuffer), L"\\")) && SUCCEEDED(StringCbCatW(szBuffer, sizeof(szBuffer), L"\\")))
SUCCEEDED(StringCbCatW(szBuffer, sizeof(szBuffer), keyPath))) {
{ HRESULT hr = S_OK;
if (keyPath)
hr = StringCbCatW(szBuffer, sizeof(szBuffer), keyPath);
if (SUCCEEDED(hr))
RegSetValueExW(hKey, L"LastKey", 0, REG_SZ, (LPBYTE)szBuffer, (DWORD)wcslen(szBuffer) * sizeof(WCHAR)); RegSetValueExW(hKey, L"LastKey", 0, REG_SZ, (LPBYTE)szBuffer, (DWORD)wcslen(szBuffer) * sizeof(WCHAR));
} else
DbgPrint("err: (%s:%d): Buffer not big enough for '%S + %S'\n", __FILE__, __LINE__, rootName, keyPath);
}
else
{
DbgPrint("err: (%s:%d): Buffer not big enough for '%S'\n", __FILE__, __LINE__, rootName);
} }
/* Get statusbar settings */ /* Get statusbar settings */