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