mirror of
https://github.com/reactos/reactos.git
synced 2025-06-02 07:56:16 +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 <shldisp.h>
|
||||
#include <shlguid.h>
|
||||
|
||||
ChildWnd* g_pChildWnd;
|
||||
static int last_split;
|
||||
|
@ -27,6 +29,63 @@ HBITMAP SizingPattern = 0;
|
|||
HBRUSH SizingBrush = 0;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
WCHAR buffer[MAX_PATH];
|
||||
DWORD style;
|
||||
IAutoComplete *pAutoComplete;
|
||||
|
||||
/* Load "My Computer" string */
|
||||
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);
|
||||
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);
|
||||
g_pChildWnd->hTreeWnd = CreateTreeView(hWnd, g_pChildWnd->szPath, (HMENU) TREE_WINDOW);
|
||||
g_pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW, rc.right - g_pChildWnd->nSplitPos);
|
||||
|
|
|
@ -176,25 +176,36 @@ void ExitInstance(HINSTANCE hInstance)
|
|||
UnloadAclUiDll();
|
||||
}
|
||||
|
||||
BOOL TranslateChildTabMessage(PMSG msg)
|
||||
static BOOL InLabelEdit(HWND hWnd, UINT Msg)
|
||||
{
|
||||
HWND hEdit = (HWND)SendMessageW(hWnd, Msg, 0, 0);
|
||||
return hEdit && IsWindowVisible(hEdit);
|
||||
}
|
||||
|
||||
static BOOL TranslateChildTabMessage(PMSG msg)
|
||||
{
|
||||
if (msg->message != WM_KEYDOWN) return FALSE;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
if (msg->wParam != VK_TAB) return FALSE;
|
||||
if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
|
||||
PostMessageW(hFrameWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
|
||||
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,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
|
@ -205,6 +216,8 @@ int WINAPI wWinMain(HINSTANCE hInstance,
|
|||
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
|
||||
OleInitialize(NULL);
|
||||
|
||||
/* Initialize global strings */
|
||||
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
|
||||
LoadStringW(hInstance, IDC_REGEDIT_FRAME, szFrameClass, ARRAY_SIZE(szFrameClass));
|
||||
|
@ -237,7 +250,7 @@ int WINAPI wWinMain(HINSTANCE hInstance,
|
|||
/* Main message loop */
|
||||
while (GetMessageW(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (!TranslateAcceleratorW(hFrameWnd, hAccel, &msg) &&
|
||||
if (!TranslateRegeditAccelerator(hFrameWnd, hAccel, &msg) &&
|
||||
!TranslateChildTabMessage(&msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _REGEDIT_H
|
||||
#define _REGEDIT_H
|
||||
|
||||
#define COBJMACROS
|
||||
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
|
|
Loading…
Reference in a new issue