1 /* 2 * Undocumented SmoothScrollWindow function from COMCTL32.DLL 3 * 4 * Copyright 2000 Marcus Meissner <marcus@jet.franken.de> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 * 20 * TODO 21 * - actually add smooth scrolling 22 */ 23 24 #include "comctl32.h" 25 26 WINE_DEFAULT_DEBUG_CHANNEL(commctrl); 27 28 static DWORD smoothscroll = 2; 29 30 typedef BOOL (CALLBACK *SCROLLWINDOWEXPROC)(HWND,INT,INT,LPRECT,LPRECT,HRGN,LPRECT,DWORD); 31 typedef struct tagSMOOTHSCROLLSTRUCT { 32 DWORD dwSize; 33 DWORD x2; 34 HWND hwnd; 35 DWORD dx; 36 37 DWORD dy; 38 LPRECT lpscrollrect; 39 LPRECT lpcliprect; 40 HRGN hrgnupdate; 41 42 LPRECT lpupdaterect; 43 DWORD flags; 44 DWORD stepinterval; 45 DWORD dx_step; 46 47 DWORD dy_step; 48 SCROLLWINDOWEXPROC scrollfun; /* same parameters as ScrollWindowEx */ 49 } SMOOTHSCROLLSTRUCT; 50 51 /************************************************************************** 52 * SmoothScrollWindow [COMCTL32.382] 53 * 54 * Lots of magic for smooth scrolling windows. 55 * 56 * RETURNS 57 * Success: TRUE 58 * Failure: FALSE 59 * 60 * BUGS 61 * Currently only scrolls ONCE. The comctl32 implementation uses GetTickCount 62 * and what else to do smooth scrolling. 63 */ 64 BOOL WINAPI SmoothScrollWindow( const SMOOTHSCROLLSTRUCT *smooth ) { 65 LPRECT lpupdaterect = smooth->lpupdaterect; 66 HRGN hrgnupdate = smooth->hrgnupdate; 67 RECT tmprect; 68 DWORD flags = smooth->flags; 69 70 if (smooth->dwSize!=sizeof(SMOOTHSCROLLSTRUCT)) 71 return FALSE; 72 73 if (!lpupdaterect) 74 lpupdaterect = &tmprect; 75 SetRectEmpty(lpupdaterect); 76 77 if (!(flags & 0x40000)) { /* no override, use system wide defaults */ 78 if (smoothscroll == 2) { 79 HKEY hkey; 80 81 smoothscroll = 0; 82 if (!RegOpenKeyA(HKEY_CURRENT_USER,"Control Panel\\Desktop",&hkey)) { 83 DWORD len = 4; 84 85 RegQueryValueExA(hkey,"SmoothScroll",0,0,(LPBYTE)&smoothscroll,&len); 86 RegCloseKey(hkey); 87 } 88 } 89 if (!smoothscroll) 90 flags |= 0x20000; 91 } 92 93 if (flags & 0x20000) { /* are we doing jump scrolling? */ 94 if ((smooth->x2 & 1) && smooth->scrollfun) 95 return smooth->scrollfun( 96 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect, 97 smooth->lpcliprect,hrgnupdate,lpupdaterect, 98 flags & 0xffff 99 ); 100 else 101 return ScrollWindowEx( 102 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect, 103 smooth->lpcliprect,hrgnupdate,lpupdaterect, 104 flags & 0xffff 105 ); 106 } 107 108 FIXME("(hwnd=%p,flags=%x,x2=%x): should smooth scroll here.\n", 109 smooth->hwnd,flags,smooth->x2 110 ); 111 /* FIXME: do timer based smooth scrolling */ 112 if ((smooth->x2 & 1) && smooth->scrollfun) 113 return smooth->scrollfun( 114 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect, 115 smooth->lpcliprect,hrgnupdate,lpupdaterect, 116 flags & 0xffff 117 ); 118 else 119 return ScrollWindowEx( 120 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect, 121 smooth->lpcliprect,hrgnupdate,lpupdaterect, 122 flags & 0xffff 123 ); 124 } 125