Author: hbelusca
Date: Mon Dec 14 22:55:55 2015
New Revision: 70347
URL:
http://svn.reactos.org/svn/reactos?rev=70347&view=rev
Log:
[CLIPBRD]
- Add support for scrolling with the mouse wheel, by Ricardo Hanke.
- No need to check for CloseClipboard failure & display an error message if the
clipboard was successfully opened just before.
- Use ARRAYSIZE macro instead of hardcoding the length of available clipboard format
list.
CORE-10679
Modified:
trunk/reactos/base/applications/clipbrd/clipbrd.c
trunk/reactos/base/applications/clipbrd/cliputils.c
trunk/reactos/base/applications/clipbrd/precomp.h
trunk/reactos/base/applications/clipbrd/scrollutils.c
trunk/reactos/base/applications/clipbrd/scrollutils.h
Modified: trunk/reactos/base/applications/clipbrd/clipbrd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/clipbrd.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/clipbrd.c [iso-8859-1] Mon Dec 14 22:55:55
2015
@@ -12,6 +12,20 @@
CLIPBOARD_GLOBALS Globals;
SCROLLSTATE Scrollstate;
+
+static void UpdateLinesToScroll(void)
+{
+ UINT uLinesToScroll;
+
+ if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &uLinesToScroll, 0))
+ {
+ Globals.uLinesToScroll = 3;
+ }
+ else
+ {
+ Globals.uLinesToScroll = uLinesToScroll;
+ }
+}
static void SaveClipboardToFile(void)
{
@@ -122,7 +136,7 @@
}
else
{
- Globals.uDisplayFormat = uFormat;
+ Globals.uDisplayFormat = uFormat;
}
if (Globals.hDspBmp)
@@ -341,6 +355,12 @@
case WM_KEYDOWN:
{
HandleKeyboardScrollEvents(hWnd, uMsg, wParam, lParam);
+ break;
+ }
+
+ case WM_MOUSEWHEEL:
+ {
+ HandleMouseScrollEvents(hWnd, uMsg, wParam, lParam, &Scrollstate);
break;
}
@@ -472,6 +492,15 @@
case WM_SYSCOLORCHANGE:
{
SetDisplayFormat(Globals.uDisplayFormat);
+ break;
+ }
+
+ case WM_SETTINGCHANGE:
+ {
+ if (wParam == SPI_SETWHEELSCROLLLINES)
+ {
+ UpdateLinesToScroll();
+ }
break;
}
@@ -545,6 +574,8 @@
ShowLastWin32Error(Globals.hMainWnd);
}
+ UpdateLinesToScroll();
+
while (GetMessageW(&msg, 0, 0, 0))
{
if (!TranslateAcceleratorW(Globals.hMainWnd, hAccel, &msg))
Modified: trunk/reactos/base/applications/clipbrd/cliputils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/cliputils.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/cliputils.c [iso-8859-1] Mon Dec 14 22:55:55
2015
@@ -108,17 +108,21 @@
ShowLastWin32Error(Globals.hMainWnd);
}
- if (!CloseClipboard())
- {
- ShowLastWin32Error(Globals.hMainWnd);
- }
+ CloseClipboard();
}
UINT GetAutomaticClipboardFormat(void)
{
- UINT uFormatList[] = {CF_UNICODETEXT, CF_ENHMETAFILE, CF_METAFILEPICT, CF_DIBV5,
CF_DIB, CF_BITMAP};
+ static UINT uFormatList[] = {
+ CF_UNICODETEXT,
+ CF_ENHMETAFILE,
+ CF_METAFILEPICT,
+ CF_DIBV5,
+ CF_DIB,
+ CF_BITMAP
+ };
- return GetPriorityClipboardFormat(uFormatList, 6);
+ return GetPriorityClipboardFormat(uFormatList, ARRAYSIZE(uFormatList));
}
BOOL IsClipboardFormatSupported(UINT uFormat)
Modified: trunk/reactos/base/applications/clipbrd/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/precomp.h [iso-8859-1] Mon Dec 14 22:55:55
2015
@@ -2,6 +2,8 @@
#define _CLIPBRD_PCH_
// #pragma once
+
+#include <limits.h>
#include <windef.h>
#include <winbase.h>
@@ -29,6 +31,7 @@
HMENU hMenu;
UINT uDisplayFormat;
UINT uCheckedItem;
+ UINT uLinesToScroll;
HBITMAP hDspBmp;
} CLIPBOARD_GLOBALS;
Modified: trunk/reactos/base/applications/clipbrd/scrollutils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/scrollutils.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/scrollutils.c [iso-8859-1] Mon Dec 14 22:55:55
2015
@@ -70,6 +70,53 @@
}
}
+void HandleMouseScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LPSCROLLSTATE state)
+{
+ SCROLLINFO si;
+ int Delta;
+ int NewPos;
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_PAGE;
+ GetScrollInfo(hWnd, SB_VERT, &si);
+
+ if (Globals.uLinesToScroll == WHEEL_PAGESCROLL)
+ {
+ NewPos = si.nPage;
+ }
+ else
+ {
+ NewPos = Globals.uLinesToScroll * 5;
+ }
+
+ if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
+ {
+ NewPos = state->CurrentY - NewPos;
+ }
+ else
+ {
+ NewPos = state->CurrentY + NewPos;
+ }
+
+ NewPos = min(state->MaxY, max(0, NewPos));
+
+ if (NewPos == state->CurrentY)
+ {
+ return;
+ }
+
+ Delta = NewPos - state->CurrentY;
+
+ state->CurrentY = NewPos;
+
+ ScrollWindowEx(hWnd, 0, -Delta, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ si.nPos = state->CurrentY;
+ SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
+}
+
void HandleHorizontalScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LPSCROLLSTATE state)
{
SCROLLINFO si;
Modified: trunk/reactos/base/applications/clipbrd/scrollutils.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/scrollutils.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/scrollutils.h [iso-8859-1] Mon Dec 14 22:55:55
2015
@@ -15,6 +15,7 @@
} SCROLLSTATE, *LPSCROLLSTATE;
void HandleKeyboardScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+void HandleMouseScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LPSCROLLSTATE state);
void HandleHorizontalScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LPSCROLLSTATE state);
void HandleVerticalScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LPSCROLLSTATE state);
void UpdateWindowScrollState(HWND hWnd, HBITMAP hBmp, LPSCROLLSTATE lpState);