source: trunk/src/comctl32/smoothscroll.cpp@ 4342

Last change on this file since 4342 was 4342, checked in by achimha, 25 years ago

added SmoothScroll from WINE

File size: 3.0 KB
Line 
1/* $Id: smoothscroll.cpp,v 1.1 2000-09-29 07:38:53 achimha Exp $ */
2
3/*
4 * Undocumented SmoothScrollWindow function from COMCTL32.DLL
5 *
6 * Copyright 2000 Marcus Meissner <marcus@jet.franken.de>
7 * Copyright 2000 Achim Hasenmueller <achimha@innotek.de>
8 *
9 * TODO
10 * - actually add smooth scrolling
11 */
12
13/* WINE CVS 000929 level */
14
15#include "winbase.h"
16#include "winreg.h"
17#include "winerror.h"
18#include "commctrl.h"
19
20static DWORD smoothscroll = 2;
21
22typedef BOOL (CALLBACK *SCROLLWINDOWEXPROC)(HWND,INT,INT,LPRECT,LPRECT,HRGN,LPRECT,DWORD);
23typedef struct tagSMOOTHSCROLLSTRUCT {
24 DWORD dwSize;
25 DWORD x2;
26 HWND hwnd;
27 DWORD dx;
28
29 DWORD dy;
30 LPRECT lpscrollrect;
31 LPRECT lpcliprect;
32 HRGN hrgnupdate;
33
34 LPRECT lpupdaterect;
35 DWORD flags;
36 DWORD stepinterval;
37 DWORD dx_step;
38
39 DWORD dy_step;
40 SCROLLWINDOWEXPROC scrollfun; /* same parameters as ScrollWindowEx */
41} SMOOTHSCROLLSTRUCT;
42
43/**************************************************************************
44 * SmoothScrollWindow [COMCTL32.382]
45 *
46 * Lots of magic for smooth scrolling windows.
47 *
48 * Currently only scrolls ONCE. The comctl32 implementation uses GetTickCount
49 * and what else to do smooth scrolling.
50 */
51
52BOOL WINAPI SmoothScrollWindow( SMOOTHSCROLLSTRUCT *smooth ) {
53 LPRECT lpupdaterect = smooth->lpupdaterect;
54 HRGN hrgnupdate = smooth->hrgnupdate;
55 RECT tmprect;
56 BOOL ret = TRUE;
57 DWORD flags = smooth->flags;
58
59 if (smooth->dwSize!=sizeof(SMOOTHSCROLLSTRUCT))
60 return FALSE;
61
62 if (!lpupdaterect)
63 lpupdaterect = &tmprect;
64 SetRectEmpty(lpupdaterect);
65
66 if (!(flags & 0x40000)) { /* no override, use system wide defaults */
67 if (smoothscroll == 2) {
68 HKEY hkey;
69
70 smoothscroll = 0;
71 if (!RegOpenKeyA(HKEY_CURRENT_USER,"Control Panel\\Desktop",&hkey)) {
72 DWORD len = 4;
73
74 RegQueryValueExA(hkey,"SmoothScroll",0,0,(LPBYTE)&smoothscroll,&len);
75 RegCloseKey(hkey);
76 }
77 }
78 if (!smoothscroll)
79 flags |= 0x20000;
80 }
81
82 if (flags & 0x20000) { /* are we doing jump scrolling? */
83 if ((smooth->x2 & 1) && smooth->scrollfun)
84 return smooth->scrollfun(
85 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
86 smooth->lpcliprect,hrgnupdate,lpupdaterect,
87 flags & 0xffff
88 );
89 else
90 return ScrollWindowEx(
91 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
92 smooth->lpcliprect,hrgnupdate,lpupdaterect,
93 flags & 0xffff
94 );
95 }
96
97// FIXME("(hwnd=%x,flags=%lx,x2=%lx): should smooth scroll here.\n",
98// smooth->hwnd,flags,smooth->x2
99// );
100 /* FIXME: do timer based smooth scrolling */
101 if ((smooth->x2 & 1) && smooth->scrollfun)
102 return smooth->scrollfun(
103 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
104 smooth->lpcliprect,hrgnupdate,lpupdaterect,
105 flags & 0xffff
106 );
107 else
108 return ScrollWindowEx(
109 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
110 smooth->lpcliprect,hrgnupdate,lpupdaterect,
111 flags & 0xffff
112 );
113 return ret;
114}
Note: See TracBrowser for help on using the repository browser.