From 509bef780104b55060c10f2bf9c0758114305845 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Thu, 18 Oct 2007 23:39:16 +0000 Subject: [PATCH] Allow selecting monitors using the keyboard svn path=/trunk/; revision=29666 --- reactos/dll/cpl/desk/monslctl.c | 80 ++++++++++++++++++++++++++++++++- reactos/dll/cpl/desk/monslctl.h | 7 +++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/reactos/dll/cpl/desk/monslctl.c b/reactos/dll/cpl/desk/monslctl.c index 54106a1fa62..5a37c375d6a 100644 --- a/reactos/dll/cpl/desk/monslctl.c +++ b/reactos/dll/cpl/desk/monslctl.c @@ -626,7 +626,7 @@ MonSelCreate(IN OUT PMONITORSELWND infoPtr) infoPtr->SelectedMonitor = -1; infoPtr->DraggingMonitor = -1; infoPtr->ControlExStyle = MSLM_EX_ALLOWSELECTDISABLED | MSLM_EX_HIDENUMBERONSINGLE | - MSLM_EX_SELECTONRIGHTCLICK; + MSLM_EX_SELECTONRIGHTCLICK | MSLM_EX_SELECTBYARROWKEY; return; } @@ -1251,6 +1251,9 @@ MonitorSelWndProc(IN HWND hwnd, INT Index; POINT pt; + if (!infoPtr->HasFocus) + SetFocus(infoPtr->hSelf); + pt.x = (LONG)LOWORD(lParam); pt.y = (LONG)HIWORD(lParam); @@ -1317,6 +1320,9 @@ MonitorSelWndProc(IN HWND hwnd, } Ret |= DLGC_WANTARROWS; + + if (infoPtr->ControlExStyle & MSLM_EX_SELECTBYNUMKEY) + Ret |= DLGC_WANTCHARS; break; } @@ -1404,6 +1410,78 @@ MonitorSelWndProc(IN HWND hwnd, break; } + case WM_KEYDOWN: + { + INT Index; + + if (infoPtr->ControlExStyle & MSLM_EX_SELECTBYARROWKEY) + { + switch (wParam) + { + case VK_UP: + case VK_LEFT: + { + Index = infoPtr->SelectedMonitor; + + if (infoPtr->MonitorsCount != 0) + { + if (Index < 0) + Index = 0; + else if (Index > 0) + Index--; + } + + if (Index >= 0) + { + MonSelSetCurSelMonitor(infoPtr, + Index, + TRUE); + } + break; + } + + case VK_DOWN: + case VK_RIGHT: + { + Index = infoPtr->SelectedMonitor; + + if (infoPtr->MonitorsCount != 0) + { + if (Index < 0) + Index = (INT)infoPtr->MonitorsCount - 1; + else if (Index < (INT)infoPtr->MonitorsCount - 1) + Index++; + } + + if (infoPtr->SelectedMonitor < infoPtr->MonitorsCount) + { + MonSelSetCurSelMonitor(infoPtr, + Index, + TRUE); + } + break; + } + } + } + break; + } + + case WM_CHAR: + { + if ((infoPtr->ControlExStyle & MSLM_EX_SELECTBYNUMKEY) && + wParam >= '1' && wParam <= '9') + { + INT Index = (INT)(wParam - '1'); + if (Index < (INT)infoPtr->MonitorsCount) + { + MonSelSetCurSelMonitor(infoPtr, + Index, + TRUE); + } + } + break; + } + case MSLM_SETMONITORSINFO: { Ret = MonSelSetMonitorsInfo(infoPtr, diff --git a/reactos/dll/cpl/desk/monslctl.h b/reactos/dll/cpl/desk/monslctl.h index f3a7828995f..28326ea7683 100644 --- a/reactos/dll/cpl/desk/monslctl.h +++ b/reactos/dll/cpl/desk/monslctl.h @@ -7,6 +7,8 @@ #define MSLM_EX_HIDENUMBERONSINGLE 0x4 #define MSLM_EX_HIDENUMBERS 0x8 #define MSLM_EX_SELECTONRIGHTCLICK 0x10 +#define MSLM_EX_SELECTBYNUMKEY 0x20 +#define MSLM_EX_SELECTBYARROWKEY 0x40 /* MONSL_MONINFO Flags */ #define MSL_MIF_DISABLED 0x1 @@ -177,6 +179,11 @@ typedef struct _MONSL_MONNMMONITORCHANGING * * MSLM_EX_SELECTONRIGHTCLICK * Selects a monitor when the user right clicks * on it. + * * MSLM_EX_SELECTBYNUMKEY + * Allows selecting a monitor by using the keys + * '1' to '9'. + * * MSLM_EX_SELECTBYARROWKEY + * Allows selecting a monitor using the arrow keys. * * Returns non-zero value if successful. */