flatsb.c 7.42 KB
Newer Older
1 2 3
/*
 * Flat Scrollbar control
 *
4
 * Copyright 1998, 1999 Eric Kohl
5
 * Copyright 1998 Alex Priem
6
 *
7 8 9 10 11 12 13 14 15 16 17 18
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 22 23 24 25 26 27 28 29 30 31
 * NOTES
 *   This is just a dummy control. An author is needed! Any volunteers?
 *   I will only improve this control once in a while.
 *     Eric <ekohl@abo.rhein-zeitung.de>
 *
 * TODO:
 *   - All messages.
 *   - All notifications.
 *
 */

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 45 46 47
typedef struct
{
    DWORD dwDummy;  /* just to keep the compiler happy ;-) */
} FLATSB_INFO, *LPFLATSB_INFO;
48 49


50
/***********************************************************************
51
 *		InitializeFlatSB (COMCTL32.@)
52
 *
53
 * Initializes flat scroll bars for the specified window.
54
 *
55 56 57 58 59 60 61
 * RETURNS
 *     Success: Non-zero
 *     Failure: Zero
 *
 * NOTES
 *     Subclasses specified window so that flat scroll bars may be drawn
 *     and used.
62
 */
63
BOOL WINAPI InitializeFlatSB(HWND hwnd)
64
{
65
    TRACE("[%p]\n", hwnd);
66
    return TRUE;
67 68
}

69
/***********************************************************************
70
 *		UninitializeFlatSB (COMCTL32.@)
71
 *
72 73 74
 * Uninitializes flat scroll bars for the specified window.
 *
 * RETURNS
75
 *	E_FAIL		if one of the scroll bars is currently in use
76
 *	S_FALSE		if InitializeFlatSB() was never called on this hwnd
77 78
 *	S_OK		otherwise
 *
79 80 81
 * NOTES
 *     Removes any subclassing on the specified window so that regular
 *     scroll bars are drawn and used.
82
 */
83
HRESULT WINAPI UninitializeFlatSB(HWND hwnd)
84
{
85
    TRACE("[%p]\n", hwnd);
86
    return S_FALSE;
87 88
}

89
/***********************************************************************
90
 *		FlatSB_GetScrollProp (COMCTL32.@)
91
 *
92
 * Retrieves flat-scroll-bar-specific properties for the specified window.
93
 *
94 95 96 97
 * RETURNS
 *     nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE,
 *     the return is nonzero if InitializeFlatSB has been called for this window, or
 *     zero otherwise.
98
 */
99
BOOL WINAPI
100
FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
101
{
102
    TRACE("[%p] propIndex=%d\n", hwnd, propIndex);
103
    return FALSE;
104 105
}

106
/***********************************************************************
107
 *		FlatSB_SetScrollProp (COMCTL32.@)
108 109 110 111 112 113
 *
 * Sets flat-scroll-bar-specific properties for the specified window.
 *
 * RETURNS
 *     Success: Non-zero
 *     Failure: Zero
114
 */
115
BOOL WINAPI
116
FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
117
{
118
    TRACE("[%p] index=%u newValue=%d flag=%d\n", hwnd, index, newValue, flag);
119
    return FALSE;
120 121
}

122
/***********************************************************************
123 124 125 126 127 128 129
 * 	From the Microsoft docs:
 *	"If flat scroll bars haven't been initialized for the
 *	window, the flat scroll bar APIs will defer to the corresponding
 *	standard APIs.  This allows the developer to turn flat scroll
 *	bars on and off without having to write conditional code."
 *
 *	So, if we just call the standard functions until we implement
130
 *	the flat scroll bar functions, flat scroll bars will show up and
131 132 133 134 135
 *	behave properly, as though they had simply not been setup to
 *	have flat properties.
 *
 *	Susan <sfarley@codeweavers.com>
 *
136
 */
137 138

/***********************************************************************
139
 *		FlatSB_EnableScrollBar (COMCTL32.@)
140 141
 *
 * See EnableScrollBar.
142
 */
143
BOOL WINAPI
144
FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags)
145
{
146
    return EnableScrollBar(hwnd, nBar, flags);
147 148
}

149
/***********************************************************************
150
 *		FlatSB_ShowScrollBar (COMCTL32.@)
151 152
 *
 * See ShowScrollBar.
153
 */
154
BOOL WINAPI
155
FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow)
156
{
157
    return ShowScrollBar(hwnd, nBar, fShow);
158 159
}

160
/***********************************************************************
161
 *		FlatSB_GetScrollRange (COMCTL32.@)
162 163
 *
 * See GetScrollRange.
164
 */
165
BOOL WINAPI
166
FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max)
167
{
168
    return GetScrollRange(hwnd, nBar, min, max);
169 170
}

171
/***********************************************************************
172
 *		FlatSB_GetScrollInfo (COMCTL32.@)
173 174
 *
 * See GetScrollInfo.
175
 */
176
BOOL WINAPI
177
FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info)
178
{
179
    return GetScrollInfo(hwnd, nBar, info);
180 181
}

182
/***********************************************************************
183
 *		FlatSB_GetScrollPos (COMCTL32.@)
184 185
 *
 * See GetScrollPos.
186
 */
187
INT WINAPI
188
FlatSB_GetScrollPos(HWND hwnd, int nBar)
189
{
190
    return GetScrollPos(hwnd, nBar);
191 192
}

193
/***********************************************************************
194
 *		FlatSB_SetScrollPos (COMCTL32.@)
195 196
 *
 * See SetScrollPos.
197
 */
198
INT WINAPI
199
FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw)
200
{
201
    return SetScrollPos(hwnd, nBar, pos, bRedraw);
202 203
}

204
/***********************************************************************
205
 *		FlatSB_SetScrollInfo (COMCTL32.@)
206 207
 *
 * See SetScrollInfo.
208
 */
209
INT WINAPI
210
FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw)
211
{
212
    return SetScrollInfo(hwnd, nBar, info, bRedraw);
213 214
}

215
/***********************************************************************
216
 *		FlatSB_SetScrollRange (COMCTL32.@)
217 218
 *
 * See SetScrollRange.
219
 */
220
INT WINAPI
221
FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw)
222
{
223
    return SetScrollRange(hwnd, nBar, min, max, bRedraw);
224 225 226 227
}


static LRESULT
228
FlatSB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
229
{
230
    TRACE("[%p] wParam %Ix, lParam %Ix\n", hwnd, wParam, lParam);
231 232 233 234 235
    return 0;
}


static LRESULT
236
FlatSB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
237
{
238
    TRACE("[%p] wParam %Ix, lParam %Ix\n", hwnd, wParam, lParam);
239 240 241 242
    return 0;
}


243
static LRESULT WINAPI
244
FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
245
{
246
    if (!GetWindowLongPtrW(hwnd, 0) && (uMsg != WM_CREATE))
247
	return DefWindowProcW( hwnd, uMsg, wParam, lParam );
248

249 250 251
    switch (uMsg)
    {
	case WM_CREATE:
252
	    return FlatSB_Create (hwnd, wParam, lParam);
253 254

	case WM_DESTROY:
255
	    return FlatSB_Destroy (hwnd, wParam, lParam);
256 257

	default:
258
	    if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
259
		ERR("unknown msg %04x, wp %#Ix, lp %#Ix\n", uMsg, wParam, lParam);
260
	    return DefWindowProcW (hwnd, uMsg, wParam, lParam);
261 262 263 264 265
    }
}


VOID
266
FLATSB_Register (void)
267
{
268
    WNDCLASSW wndClass;
269

270
    ZeroMemory (&wndClass, sizeof(WNDCLASSW));
271
    wndClass.style         = CS_GLOBALCLASS;
272
    wndClass.lpfnWndProc   = FlatSB_WindowProc;
273 274
    wndClass.cbClsExtra    = 0;
    wndClass.cbWndExtra    = sizeof(FLATSB_INFO *);
275
    wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROW);
276
    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
277
    wndClass.lpszClassName = FLATSB_CLASSW;
278

279
    RegisterClassW (&wndClass);
280 281 282 283
}


VOID
284
FLATSB_Unregister (void)
285
{
286
    UnregisterClassW (FLATSB_CLASSW, NULL);
287
}