https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fed7ee70a662f7c44a7d8…
commit fed7ee70a662f7c44a7d8faa3b00dd74bc6d5f03
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Dec 16 20:46:40 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Dec 16 20:46:40 2023 +0900
[SHIMGVW] Enable middle button dragging (#6173)
---
dll/win32/shimgvw/CMakeLists.txt | 3 ++
dll/win32/shimgvw/res/handdrag.cur | Bin 0 -> 326 bytes
dll/win32/shimgvw/resource.h | 3 ++
dll/win32/shimgvw/shimgvw.c | 70 +++++++++++++++++++++++++++++++++++--
dll/win32/shimgvw/shimgvw.rc | 2 ++
5 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/dll/win32/shimgvw/CMakeLists.txt b/dll/win32/shimgvw/CMakeLists.txt
index 3c2f5a1f3c3..1a4589abd43 100644
--- a/dll/win32/shimgvw/CMakeLists.txt
+++ b/dll/win32/shimgvw/CMakeLists.txt
@@ -9,6 +9,9 @@ list(APPEND SOURCE
${CMAKE_CURRENT_BINARY_DIR}/shimgvw_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/shimgvw.def)
+file(GLOB_RECURSE shimgvw_rc_deps res/*.*)
+add_rc_deps(shimgvw.rc ${shimgvw_rc_deps})
+
add_library(shimgvw MODULE ${SOURCE})
set_module_type(shimgvw win32dll UNICODE)
target_link_libraries(shimgvw wine)
diff --git a/dll/win32/shimgvw/res/handdrag.cur b/dll/win32/shimgvw/res/handdrag.cur
new file mode 100644
index 00000000000..74e5ba6b9c2
Binary files /dev/null and b/dll/win32/shimgvw/res/handdrag.cur differ
diff --git a/dll/win32/shimgvw/resource.h b/dll/win32/shimgvw/resource.h
index 68f91679139..96da8e444cf 100644
--- a/dll/win32/shimgvw/resource.h
+++ b/dll/win32/shimgvw/resource.h
@@ -7,6 +7,9 @@
#define IDI_JPG_ICON 4
#define IDI_PNG_ICON 5
+/* Cursors */
+#define IDC_HANDDRAG 100
+
/* Toolbar images */
#define IDB_PREV_PIC 50
#define IDB_NEXT_PIC 51
diff --git a/dll/win32/shimgvw/shimgvw.c b/dll/win32/shimgvw/shimgvw.c
index b04363ed896..0503449d87c 100644
--- a/dll/win32/shimgvw/shimgvw.c
+++ b/dll/win32/shimgvw/shimgvw.c
@@ -103,6 +103,8 @@ typedef struct tagPREVIEW_DATA
ANIME m_Anime; /* Animation */
INT m_xScrollOffset;
INT m_yScrollOffset;
+ UINT m_nMouseDownMsg;
+ POINT m_ptOrigin;
} PREVIEW_DATA, *PPREVIEW_DATA;
static inline PPREVIEW_DATA
@@ -885,9 +887,56 @@ Preview_EndSlideShow(HWND hwnd)
static VOID
ZoomWnd_OnButtonDown(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
+ PPREVIEW_DATA pData = Preview_GetData(hwnd);
HWND hParent = GetParent(hwnd);
- if (!Preview_IsMainWnd(hParent))
- Preview_EndSlideShow(hParent);
+ if ((uMsg == WM_LBUTTONDOWN) || (uMsg == WM_RBUTTONDOWN))
+ {
+ if (!Preview_IsMainWnd(hParent))
+ Preview_EndSlideShow(hParent);
+ return;
+ }
+
+ pData->m_nMouseDownMsg = uMsg;
+ pData->m_ptOrigin.x = GET_X_LPARAM(lParam);
+ pData->m_ptOrigin.y = GET_Y_LPARAM(lParam);
+ SetCapture(hwnd);
+ SetCursor(LoadCursorW(g_hInstance, MAKEINTRESOURCEW(IDC_HANDDRAG)));
+}
+
+static VOID
+ZoomWnd_OnMouseMove(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ PPREVIEW_DATA pData = Preview_GetData(hwnd);
+ POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+
+ if (pData->m_nMouseDownMsg == WM_MBUTTONDOWN)
+ {
+ INT x = GetScrollPos(hwnd, SB_HORZ) - (pt.x - pData->m_ptOrigin.x);
+ INT y = GetScrollPos(hwnd, SB_VERT) - (pt.y - pData->m_ptOrigin.y);
+ SendMessageW(hwnd, WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
+ SendMessageW(hwnd, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
+ pData->m_ptOrigin = pt;
+ }
+}
+
+static BOOL
+ZoomWnd_OnSetCursor(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ PPREVIEW_DATA pData = Preview_GetData(hwnd);
+ if (pData->m_nMouseDownMsg == WM_MBUTTONDOWN)
+ {
+ SetCursor(LoadCursorW(g_hInstance, MAKEINTRESOURCEW(IDC_HANDDRAG)));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static VOID
+ZoomWnd_OnButtonUp(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ PPREVIEW_DATA pData = Preview_GetData(hwnd);
+ pData->m_nMouseDownMsg = 0;
+ ReleaseCapture();
}
static VOID
@@ -995,6 +1044,23 @@ ZoomWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
ZoomWnd_OnButtonDown(hwnd, uMsg, wParam, lParam);
break;
}
+ case WM_MOUSEMOVE:
+ {
+ ZoomWnd_OnMouseMove(hwnd, uMsg, wParam, lParam);
+ break;
+ }
+ case WM_SETCURSOR:
+ {
+ if (!ZoomWnd_OnSetCursor(hwnd, uMsg, wParam, lParam))
+ return DefWindowProcW(hwnd, uMsg, wParam, lParam);
+ }
+ case WM_LBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_RBUTTONUP:
+ {
+ ZoomWnd_OnButtonUp(hwnd, uMsg, wParam, lParam);
+ break;
+ }
case WM_PAINT:
{
ZoomWnd_OnPaint(pData, hwnd);
diff --git a/dll/win32/shimgvw/shimgvw.rc b/dll/win32/shimgvw/shimgvw.rc
index 58684a5d95b..f42c29154cd 100644
--- a/dll/win32/shimgvw/shimgvw.rc
+++ b/dll/win32/shimgvw/shimgvw.rc
@@ -17,6 +17,8 @@ IDI_APP_ICON ICON "res/main.ico"
IDI_BMP_ICON ICON "res/bmp.ico"
IDI_PNG_ICON ICON "res/png.ico"
+IDC_HANDDRAG CURSOR "res/handdrag.cur"
+
IDB_PREV_PIC BITMAP "res/prev.bmp"
IDB_NEXT_PIC BITMAP "res/next.bmp"
IDB_BEST_FIT BITMAP "res/best_fit.bmp"