mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 07:36:05 +00:00
[REGEDIT] Handle Ctrl+Backspace in AddressBar (#7140)
Notes: - Also fixes a bug where Del does not work in the AddressBar nor during Tree/List label edit because it gets eaten by the accelerator. - Removed the code that handles CtrlA in the AddressBar because the Edit control does this out of the box.
This commit is contained in:
parent
075894bc44
commit
28cb0995e6
3 changed files with 92 additions and 12 deletions
|
@ -20,6 +20,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "regedit.h"
|
#include "regedit.h"
|
||||||
|
#include <shldisp.h>
|
||||||
|
#include <shlguid.h>
|
||||||
|
|
||||||
ChildWnd* g_pChildWnd;
|
ChildWnd* g_pChildWnd;
|
||||||
static int last_split;
|
static int last_split;
|
||||||
|
@ -27,6 +29,63 @@ HBITMAP SizingPattern = 0;
|
||||||
HBRUSH SizingBrush = 0;
|
HBRUSH SizingBrush = 0;
|
||||||
WCHAR Suggestions[256];
|
WCHAR Suggestions[256];
|
||||||
|
|
||||||
|
static HRESULT WINAPI DummyEnumStringsQI(LPVOID This, REFIID riid, void**ppv)
|
||||||
|
{
|
||||||
|
if (ppv)
|
||||||
|
*ppv = NULL;
|
||||||
|
if (IsEqualIID(riid, &IID_IEnumString) || IsEqualIID(riid, &IID_IUnknown))
|
||||||
|
{
|
||||||
|
*ppv = This;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI DummyEnumStringsAddRefRelease(LPVOID This)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI DummyEnumStringsNext(LPVOID This, ULONG celt, LPWSTR *parr, ULONG *pceltFetched)
|
||||||
|
{
|
||||||
|
if (pceltFetched)
|
||||||
|
*pceltFetched = 0;
|
||||||
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI DummyEnumStringsSkip(LPVOID This, ULONG celt)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI DummyEnumStringsReset(LPVOID This)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI DummyEnumStringsClone(LPVOID This, void**ppv)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DummyEnumStringsVtbl {
|
||||||
|
LPVOID QI, AddRef, Release, Next, Skip, Reset, Clone;
|
||||||
|
} g_DummyEnumStringsVtbl = {
|
||||||
|
&DummyEnumStringsQI,
|
||||||
|
&DummyEnumStringsAddRefRelease,
|
||||||
|
&DummyEnumStringsAddRefRelease,
|
||||||
|
&DummyEnumStringsNext,
|
||||||
|
&DummyEnumStringsSkip,
|
||||||
|
&DummyEnumStringsReset,
|
||||||
|
&DummyEnumStringsClone
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DummyEnumStrings {
|
||||||
|
struct DummyEnumStringsVtbl *lpVtbl;
|
||||||
|
} g_DummyEnumStrings = {
|
||||||
|
&g_DummyEnumStringsVtbl
|
||||||
|
};
|
||||||
|
|
||||||
extern LPCWSTR get_root_key_name(HKEY hRootKey)
|
extern LPCWSTR get_root_key_name(HKEY hRootKey)
|
||||||
{
|
{
|
||||||
if (hRootKey == HKEY_CLASSES_ROOT) return L"HKEY_CLASSES_ROOT";
|
if (hRootKey == HKEY_CLASSES_ROOT) return L"HKEY_CLASSES_ROOT";
|
||||||
|
@ -338,6 +397,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
HFONT hFont;
|
HFONT hFont;
|
||||||
WCHAR buffer[MAX_PATH];
|
WCHAR buffer[MAX_PATH];
|
||||||
DWORD style;
|
DWORD style;
|
||||||
|
IAutoComplete *pAutoComplete;
|
||||||
|
|
||||||
/* Load "My Computer" string */
|
/* Load "My Computer" string */
|
||||||
LoadStringW(hInst, IDS_MY_COMPUTER, buffer, ARRAY_SIZE(buffer));
|
LoadStringW(hInst, IDS_MY_COMPUTER, buffer, ARRAY_SIZE(buffer));
|
||||||
|
@ -363,6 +423,12 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
IMAGE_ICON, 12, 12, 0);
|
IMAGE_ICON, 12, 12, 0);
|
||||||
SendMessageW(g_pChildWnd->hAddressBtnWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_pChildWnd->hArrowIcon);
|
SendMessageW(g_pChildWnd->hAddressBtnWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_pChildWnd->hArrowIcon);
|
||||||
|
|
||||||
|
if (SUCCEEDED(CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, &IID_IAutoComplete, (void**)&pAutoComplete)))
|
||||||
|
{
|
||||||
|
IAutoComplete_Init(pAutoComplete, g_pChildWnd->hAddressBarWnd, (IUnknown*)&g_DummyEnumStrings, NULL, NULL);
|
||||||
|
IAutoComplete_Release(pAutoComplete);
|
||||||
|
}
|
||||||
|
|
||||||
GetClientRect(hWnd, &rc);
|
GetClientRect(hWnd, &rc);
|
||||||
g_pChildWnd->hTreeWnd = CreateTreeView(hWnd, g_pChildWnd->szPath, (HMENU) TREE_WINDOW);
|
g_pChildWnd->hTreeWnd = CreateTreeView(hWnd, g_pChildWnd->szPath, (HMENU) TREE_WINDOW);
|
||||||
g_pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW, rc.right - g_pChildWnd->nSplitPos);
|
g_pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW, rc.right - g_pChildWnd->nSplitPos);
|
||||||
|
|
|
@ -176,25 +176,36 @@ void ExitInstance(HINSTANCE hInstance)
|
||||||
UnloadAclUiDll();
|
UnloadAclUiDll();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TranslateChildTabMessage(PMSG msg)
|
static BOOL InLabelEdit(HWND hWnd, UINT Msg)
|
||||||
{
|
{
|
||||||
if (msg->message != WM_KEYDOWN) return FALSE;
|
HWND hEdit = (HWND)SendMessageW(hWnd, Msg, 0, 0);
|
||||||
|
return hEdit && IsWindowVisible(hEdit);
|
||||||
/* Allow Ctrl+A on address bar */
|
|
||||||
if ((msg->hwnd == g_pChildWnd->hAddressBarWnd) &&
|
|
||||||
(msg->message == WM_KEYDOWN) &&
|
|
||||||
(msg->wParam == L'A') && (GetKeyState(VK_CONTROL) < 0))
|
|
||||||
{
|
|
||||||
SendMessageW(msg->hwnd, EM_SETSEL, 0, -1);
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL TranslateChildTabMessage(PMSG msg)
|
||||||
|
{
|
||||||
|
if (msg->message != WM_KEYDOWN) return FALSE;
|
||||||
if (msg->wParam != VK_TAB) return FALSE;
|
if (msg->wParam != VK_TAB) return FALSE;
|
||||||
if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
|
if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
|
||||||
PostMessageW(hFrameWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
|
PostMessageW(hFrameWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL TranslateRegeditAccelerator(HWND hWnd, HACCEL hAccTable, PMSG msg)
|
||||||
|
{
|
||||||
|
if (msg->message == WM_KEYDOWN)
|
||||||
|
{
|
||||||
|
if (msg->wParam == VK_DELETE)
|
||||||
|
{
|
||||||
|
if (g_pChildWnd->hAddressBarWnd == msg->hwnd)
|
||||||
|
return FALSE;
|
||||||
|
if (InLabelEdit(g_pChildWnd->hTreeWnd, TVM_GETEDITCONTROL) || InLabelEdit(g_pChildWnd->hListWnd, LVM_GETEDITCONTROL))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TranslateAcceleratorW(hWnd, hAccTable, msg);
|
||||||
|
}
|
||||||
|
|
||||||
int WINAPI wWinMain(HINSTANCE hInstance,
|
int WINAPI wWinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
||||||
LPWSTR lpCmdLine,
|
LPWSTR lpCmdLine,
|
||||||
|
@ -205,6 +216,8 @@ int WINAPI wWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
|
|
||||||
|
OleInitialize(NULL);
|
||||||
|
|
||||||
/* Initialize global strings */
|
/* Initialize global strings */
|
||||||
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
|
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
|
||||||
LoadStringW(hInstance, IDC_REGEDIT_FRAME, szFrameClass, ARRAY_SIZE(szFrameClass));
|
LoadStringW(hInstance, IDC_REGEDIT_FRAME, szFrameClass, ARRAY_SIZE(szFrameClass));
|
||||||
|
@ -237,7 +250,7 @@ int WINAPI wWinMain(HINSTANCE hInstance,
|
||||||
/* Main message loop */
|
/* Main message loop */
|
||||||
while (GetMessageW(&msg, NULL, 0, 0))
|
while (GetMessageW(&msg, NULL, 0, 0))
|
||||||
{
|
{
|
||||||
if (!TranslateAcceleratorW(hFrameWnd, hAccel, &msg) &&
|
if (!TranslateRegeditAccelerator(hFrameWnd, hAccel, &msg) &&
|
||||||
!TranslateChildTabMessage(&msg))
|
!TranslateChildTabMessage(&msg))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef _REGEDIT_H
|
#ifndef _REGEDIT_H
|
||||||
#define _REGEDIT_H
|
#define _REGEDIT_H
|
||||||
|
|
||||||
|
#define COBJMACROS
|
||||||
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||||
#define WIN32_NO_STATUS
|
#define WIN32_NO_STATUS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue