comctl32: Proper fix redrawing the trackbar background with themes enabled.
[wine] / dlls / comctl32 / flatsb.c
1 /*
2  * Flat Scrollbar control
3  *
4  * Copyright 1998, 1999 Eric Kohl
5  * Copyright 1998 Alex Priem
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  *
21  * NOTES
22  *   This is just a dummy control. An author is needed! Any volunteers?
23  *   I will only improve this control once in a while.
24  *     Eric <ekohl@abo.rhein-zeitung.de>
25  *
26  * TODO:
27  *   - All messages.
28  *   - All notifications.
29  *
30  */
31
32 #include <stdarg.h>
33 #include <string.h>
34 #include "windef.h"
35 #include "winbase.h"
36 #include "winerror.h"
37 #include "winuser.h"
38 #include "commctrl.h"
39 #include "comctl32.h"
40 #include "wine/debug.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
43
44 typedef struct
45 {
46     DWORD dwDummy;  /* just to keep the compiler happy ;-) */
47 } FLATSB_INFO, *LPFLATSB_INFO;
48
49 #define FlatSB_GetInfoPtr(hwnd) ((FLATSB_INFO*)GetWindowLongPtrW (hwnd, 0))
50
51
52 /***********************************************************************
53  *              InitializeFlatSB (COMCTL32.@)
54  *
55  * Initializes flat scroll bars for the specified window.
56  *
57  * RETURNS
58  *     Success: Non-zero
59  *     Failure: Zero
60  *
61  * NOTES
62  *     Subclasses specified window so that flat scroll bars may be drawn
63  *     and used.
64  */
65 BOOL WINAPI InitializeFlatSB(HWND hwnd)
66 {
67     TRACE("[%p]\n", hwnd);
68     return FALSE;
69 }
70
71 /***********************************************************************
72  *              UninitializeFlatSB (COMCTL32.@)
73  *
74  * Uninitializes flat scroll bars for the specified window.
75  *
76  * RETURNS
77  *      E_FAIL          if one of the scroll bars is currently in use
78  *      S_FALSE         if InitializeFlatSB() was never called on this hwnd
79  *      S_OK            otherwise
80  *
81  * NOTES
82  *     Removes any subclassing on the specified window so that regular
83  *     scroll bars are drawn and used.
84  */
85 HRESULT WINAPI UninitializeFlatSB(HWND hwnd)
86 {
87     TRACE("[%p]\n", hwnd);
88     return S_FALSE;
89 }
90
91 /***********************************************************************
92  *              FlatSB_GetScrollProp (COMCTL32.@)
93  *
94  * Retrieves flat-scroll-bar-specific properties for the specified window.
95  *
96  * RETURNS
97  *     nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE,
98  *     the return is nonzero if InitializeFlatSB has been called for this window, or
99  *     zero otherwise.
100  */
101 BOOL WINAPI
102 FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
103 {
104     TRACE("[%p] propIndex=%d\n", hwnd, propIndex);
105     return FALSE;
106 }
107
108 /***********************************************************************
109  *              FlatSB_SetScrollProp (COMCTL32.@)
110  *
111  * Sets flat-scroll-bar-specific properties for the specified window.
112  *
113  * RETURNS
114  *     Success: Non-zero
115  *     Failure: Zero
116  */
117 BOOL WINAPI
118 FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
119 {
120     TRACE("[%p] index=%u newValue=%d flag=%d\n", hwnd, index, newValue, flag);
121     return FALSE;
122 }
123
124 /***********************************************************************
125  *      From the Microsoft docs:
126  *      "If flat scroll bars haven't been initialized for the
127  *      window, the flat scroll bar APIs will defer to the corresponding
128  *      standard APIs.  This allows the developer to turn flat scroll
129  *      bars on and off without having to write conditional code."
130  *
131  *      So, if we just call the standard functions until we implement
132  *      the flat scroll bar functions, flat scroll bars will show up and
133  *      behave properly, as though they had simply not been setup to
134  *      have flat properties.
135  *
136  *      Susan <sfarley@codeweavers.com>
137  *
138  */
139
140 /***********************************************************************
141  *              FlatSB_EnableScrollBar (COMCTL32.@)
142  *
143  * See EnableScrollBar.
144  */
145 BOOL WINAPI
146 FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags)
147 {
148     return EnableScrollBar(hwnd, nBar, flags);
149 }
150
151 /***********************************************************************
152  *              FlatSB_ShowScrollBar (COMCTL32.@)
153  *
154  * See ShowScrollBar.
155  */
156 BOOL WINAPI
157 FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow)
158 {
159     return ShowScrollBar(hwnd, nBar, fShow);
160 }
161
162 /***********************************************************************
163  *              FlatSB_GetScrollRange (COMCTL32.@)
164  *
165  * See GetScrollRange.
166  */
167 BOOL WINAPI
168 FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max)
169 {
170     return GetScrollRange(hwnd, nBar, min, max);
171 }
172
173 /***********************************************************************
174  *              FlatSB_GetScrollInfo (COMCTL32.@)
175  *
176  * See GetScrollInfo.
177  */
178 BOOL WINAPI
179 FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info)
180 {
181     return GetScrollInfo(hwnd, nBar, info);
182 }
183
184 /***********************************************************************
185  *              FlatSB_GetScrollPos (COMCTL32.@)
186  *
187  * See GetScrollPos.
188  */
189 INT WINAPI
190 FlatSB_GetScrollPos(HWND hwnd, int nBar)
191 {
192     return GetScrollPos(hwnd, nBar);
193 }
194
195 /***********************************************************************
196  *              FlatSB_SetScrollPos (COMCTL32.@)
197  *
198  * See SetScrollPos.
199  */
200 INT WINAPI
201 FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw)
202 {
203     return SetScrollPos(hwnd, nBar, pos, bRedraw);
204 }
205
206 /***********************************************************************
207  *              FlatSB_SetScrollInfo (COMCTL32.@)
208  *
209  * See SetScrollInfo.
210  */
211 INT WINAPI
212 FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw)
213 {
214     return SetScrollInfo(hwnd, nBar, info, bRedraw);
215 }
216
217 /***********************************************************************
218  *              FlatSB_SetScrollRange (COMCTL32.@)
219  *
220  * See SetScrollRange.
221  */
222 INT WINAPI
223 FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw)
224 {
225     return SetScrollRange(hwnd, nBar, min, max, bRedraw);
226 }
227
228
229 static LRESULT
230 FlatSB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
231 {
232     TRACE("[%p] wParam=%04lx lParam=%08lx\n", hwnd, wParam, lParam);
233     return 0;
234 }
235
236
237 static LRESULT
238 FlatSB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
239 {
240     TRACE("[%p] wParam=%04lx lParam=%08lx\n", hwnd, wParam, lParam);
241     return 0;
242 }
243
244
245 static LRESULT WINAPI
246 FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
247 {
248     if (!FlatSB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
249         return DefWindowProcW( hwnd, uMsg, wParam, lParam );
250
251     switch (uMsg)
252     {
253         case WM_CREATE:
254             return FlatSB_Create (hwnd, wParam, lParam);
255
256         case WM_DESTROY:
257             return FlatSB_Destroy (hwnd, wParam, lParam);
258
259         default:
260             if ((uMsg >= WM_USER) && (uMsg < WM_APP))
261                 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
262                     uMsg, wParam, lParam);
263             return DefWindowProcW (hwnd, uMsg, wParam, lParam);
264     }
265 }
266
267
268 VOID
269 FLATSB_Register (void)
270 {
271     WNDCLASSW wndClass;
272
273     ZeroMemory (&wndClass, sizeof(WNDCLASSW));
274     wndClass.style         = CS_GLOBALCLASS;
275     wndClass.lpfnWndProc   = FlatSB_WindowProc;
276     wndClass.cbClsExtra    = 0;
277     wndClass.cbWndExtra    = sizeof(FLATSB_INFO *);
278     wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROW);
279     wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
280     wndClass.lpszClassName = FLATSB_CLASSW;
281
282     RegisterClassW (&wndClass);
283 }
284
285
286 VOID
287 FLATSB_Unregister (void)
288 {
289     UnregisterClassW (FLATSB_CLASSW, NULL);
290 }