From a10440fe8a31c4cb16d56842aaff183e5f35cfe6 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Mon, 21 Jun 2004 10:24:52 +0000 Subject: [PATCH] merged focus handling code from wine svn path=/trunk/; revision=9794 --- reactos/subsys/system/regedit/En.rc | 2 ++ reactos/subsys/system/regedit/childwnd.c | 19 ++++++------ reactos/subsys/system/regedit/framewnd.c | 4 +++ reactos/subsys/system/regedit/listview.c | 38 +++++++++++++++++++++++- reactos/subsys/system/regedit/main.c | 13 ++++++-- reactos/subsys/system/regedit/resource.h | 3 ++ 6 files changed, 67 insertions(+), 12 deletions(-) diff --git a/reactos/subsys/system/regedit/En.rc b/reactos/subsys/system/regedit/En.rc index c505ccdf1e5..b3680cf3a2d 100644 --- a/reactos/subsys/system/regedit/En.rc +++ b/reactos/subsys/system/regedit/En.rc @@ -263,6 +263,8 @@ BEGIN IDS_QUERY_DELETE_CONFIRM "Confirm Value Delete" IDS_ERR_DELVAL_CAPTION "Error Deleting Values" IDS_ERR_DELETEVALUE "Unable to delete all specified values!" + IDS_ERR_RENVAL_CAPTION "Error Renaming Value" + IDS_ERR_RENVAL_TOEMPTY "Cannot rename %s. The specified value name is empty. Try another name and try again." END STRINGTABLE DISCARDABLE diff --git a/reactos/subsys/system/regedit/childwnd.c b/reactos/subsys/system/regedit/childwnd.c index 1306c0b9dc6..2a71a889988 100644 --- a/reactos/subsys/system/regedit/childwnd.c +++ b/reactos/subsys/system/regedit/childwnd.c @@ -101,6 +101,7 @@ static void OnPaint(HWND hWnd) static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + ChildWnd* pChildWnd = g_pChildWnd; switch (LOWORD(wParam)) { /* Parse the menu selections: */ case ID_REGISTRY_EXIT: @@ -109,6 +110,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case ID_VIEW_REFRESH: /* TODO */ break; + case ID_SWITCH_PANELS: + pChildWnd->nFocusPanel = !pChildWnd->nFocusPanel; + SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd); + break; default: return FALSE; } @@ -275,10 +280,6 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa HKEY hRootKey; keyPath = GetItemPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey); - if(!hRootKey) - { - RefreshListView(pChildWnd->hListWnd, 0, NULL); - } if (keyPath) { RefreshListView(pChildWnd->hListWnd, hRootKey, keyPath); rootName = get_root_key_name(hRootKey); @@ -292,10 +293,10 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa } break; case NM_SETFOCUS: - pChildWnd->nFocusPanel = 1; + pChildWnd->nFocusPanel = 0; break; default: - goto def; + return 0; } } else { @@ -303,12 +304,12 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa { switch (((LPNMHDR)lParam)->code) { case NM_SETFOCUS: - pChildWnd->nFocusPanel = 0; + pChildWnd->nFocusPanel = 1; break; default: - if(ListWndNotifyProc(pChildWnd->hListWnd, wParam, lParam, &Result)) + if(!ListWndNotifyProc(pChildWnd->hListWnd, wParam, lParam, &Result)) { - return Result; + goto def; } break; } diff --git a/reactos/subsys/system/regedit/framewnd.c b/reactos/subsys/system/regedit/framewnd.c index b2c90e61cde..c29c8a107aa 100644 --- a/reactos/subsys/system/regedit/framewnd.c +++ b/reactos/subsys/system/regedit/framewnd.c @@ -658,6 +658,10 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa case WM_MENUSELECT: OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam); break; + case WM_ACTIVATE: + if (LOWORD(hWnd)) + SetFocus(g_pChildWnd->hWnd); + break; case WM_DESTROY: WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0); PostQuitMessage(0); diff --git a/reactos/subsys/system/regedit/listview.c b/reactos/subsys/system/regedit/listview.c index 20c249ea08d..edeb07e0f34 100644 --- a/reactos/subsys/system/regedit/listview.c +++ b/reactos/subsys/system/regedit/listview.c @@ -408,7 +408,9 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result) SendMessage(hFrameWnd, WM_COMMAND, MAKEWPARAM(ID_EDIT_MODIFY, 0), 0); } return TRUE; - + case NM_SETFOCUS: + g_pChildWnd->nFocusPanel = 0; + break; case LVN_BEGINLABELEDIT: { PLINE_INFO lineinfo; @@ -429,6 +431,40 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result) *Result = TRUE; return TRUE; } + case LVN_ENDLABELEDIT: + { + PLINE_INFO lineinfo; + Info = (NMLVDISPINFO*)lParam; + if(Info && Info->item.pszText) + { + lineinfo = (PLINE_INFO)Info->item.lParam; + if(!lineinfo->name || !_tcscmp(lineinfo->name, _T(""))) + { + *Result = FALSE; + } + else + { + LONG ret; + //if((ret = RenameValue(lineinfo->name, Info->item.pszText)) != ERROR_SUCCESS) + { + TCHAR msg[128], caption[128]; + + LoadString(hInst, IDS_ERR_RENVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR)); + if(_tcslen(Info->item.pszText) == 0) + { + LoadString(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, sizeof(msg)/sizeof(TCHAR)); + } + else + _stprintf(msg, _T("rename from %s to %s"), lineinfo->name, Info->item.pszText); + MessageBox(0, msg, NULL, 0); + *Result = TRUE; + } + } + } + else + *Result = TRUE; + return TRUE; + } } return FALSE; } diff --git a/reactos/subsys/system/regedit/main.c b/reactos/subsys/system/regedit/main.c index 57018d3eacf..520dd787060 100644 --- a/reactos/subsys/system/regedit/main.c +++ b/reactos/subsys/system/regedit/main.c @@ -147,6 +147,15 @@ void ExitInstance(HINSTANCE hInstance) DestroyMenu(hMenuFrame); } +BOOL TranslateChildTabMessage(MSG *msg) +{ + if (msg->message != WM_KEYDOWN) return FALSE; + if (msg->wParam != VK_TAB) return FALSE; + if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE; + PostMessage(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0); + return TRUE; +} + int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, @@ -189,8 +198,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, /* Main message loop */ while (GetMessage(&msg, (HWND)NULL, 0, 0)) { - if (!TranslateAccelerator(msg.hwnd, hAccel, &msg) && - !IsDialogMessage(hFrameWnd, &msg)) { + if (!TranslateAccelerator(msg.hwnd, hAccel, &msg) + && !TranslateChildTabMessage(&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/reactos/subsys/system/regedit/resource.h b/reactos/subsys/system/regedit/resource.h index cc201340810..f3f45b677ee 100644 --- a/reactos/subsys/system/regedit/resource.h +++ b/reactos/subsys/system/regedit/resource.h @@ -124,6 +124,9 @@ #define IDS_QUERY_DELETE_CONFIRM 32853 #define IDS_ERR_DELVAL_CAPTION 32854 #define IDS_ERR_DELETEVALUE 32855 +#define IDS_ERR_RENVAL_CAPTION 32856 +#define IDS_ERR_RENVAL_TOEMPTY 32857 +#define ID_SWITCH_PANELS 32871 #define IDS_FLT_REGFILES 31001 #define IDS_FLT_REGFILES_FLT 31002