Add the selected extension from file type filter if file name does not
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 "wingdi.h"
38 #include "winuser.h"
39 #include "winnls.h"
40 #include "commctrl.h"
41 #include "wine/debug.h"
42
43 WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
44
45 typedef struct
46 {
47     DWORD dwDummy;  /* just to keep the compiler happy ;-) */
48 } FLATSB_INFO, *LPFLATSB_INFO;
49
50 #define FlatSB_GetInfoPtr(hwnd) ((FLATSB_INFO*)GetWindowLongA (hwnd, 0))
51
52
53 /***********************************************************************
54  *              InitializeFlatSB (COMCTL32.@)
55  *
56  * Initializes flat scroll bars for the specified window.
57  *
58  * RETURNS
59  *     Success: Non-zero
60  *     Failure: Zero
61  *
62  * NOTES
63  *     Subclasses specified window so that flat scroll bars may be drawn
64  *     and used.
65  */
66 BOOL WINAPI InitializeFlatSB(HWND hwnd)
67 {
68     TRACE("[%p]\n", hwnd);
69     return FALSE;
70 }
71
72 /***********************************************************************
73  *              UninitializeFlatSB (COMCTL32.@)
74  *
75  * Uninitializes flat scroll bars for the specified window.
76  *
77  * RETURNS
78  *      E_FAIL          if one of the scroll bars is currently in use
79  *      S_FALSE         if InitializeFlatSB() was never called on this hwnd
80  *      S_OK            otherwise
81  *
82  * NOTES
83  *     Removes any subclassing on the specified window so that regular
84  *     scroll bars are drawn and used.
85  */
86 HRESULT WINAPI UninitializeFlatSB(HWND hwnd)
87 {
88     TRACE("[%p]\n", hwnd);
89     return S_FALSE;
90 }
91
92 /***********************************************************************
93  *              FlatSB_GetScrollProp (COMCTL32.@)
94  *
95  * Retrieves flat-scroll-bar-specific properties for the specified window.
96  *
97  * RETURNS
98  *     nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE,
99  *     the return is nonzero if InitializeFlatSB has been called for this window, or
100  *     zero otherwise.
101  */
102 BOOL WINAPI
103 FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
104 {
105     TRACE("[%p] propIndex=%d\n", hwnd, propIndex);
106     return FALSE;
107 }
108
109 /***********************************************************************
110  *              FlatSB_SetScrollProp (COMCTL32.@)
111  *
112  * Sets flat-scroll-bar-specific properties for the specified window.
113  *
114  * RETURNS
115  *     Success: Non-zero
116  *     Failure: Zero
117  */
118 BOOL WINAPI
119 FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
120 {
121     TRACE("[%p] index=%u newValue=%d flag=%d\n", hwnd, index, newValue, flag);
122     return FALSE;
123 }
124
125 /***********************************************************************
126  *      From the Microsoft docs:
127  *      "If flat scroll bars haven't been initialized for the
128  *      window, the flat scroll bar APIs will defer to the corresponding
129  *      standard APIs.  This allows the developer to turn flat scroll
130  *      bars on and off without having to write conditional code."
131  *
132  *      So, if we just call the standard functions until we implement
133  *      the flat scroll bar functions, flat scroll bars will show up and
134  *      behave properly, as though they had simply not been setup to
135  *      have flat properties.
136  *
137  *      Susan <sfarley@codeweavers.com>
138  *
139  */
140
141 /***********************************************************************
142  *              FlatSB_EnableScrollBar (COMCTL32.@)
143  *
144  * See EnableScrollBar.
145  */
146 BOOL WINAPI
147 FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags)
148 {
149     return EnableScrollBar(hwnd, nBar, flags);
150 }
151
152 /***********************************************************************
153  *              FlatSB_ShowScrollBar (COMCTL32.@)
154  *
155  * See ShowScrollBar.
156  */
157 BOOL WINAPI
158 FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow)
159 {
160     return ShowScrollBar(hwnd, nBar, fShow);
161 }
162
163 /***********************************************************************
164  *              FlatSB_GetScrollRange (COMCTL32.@)
165  *
166  * See GetScrollRange.
167  */
168 BOOL WINAPI
169 FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max)
170 {
171     return GetScrollRange(hwnd, nBar, min, max);
172 }
173
174 /***********************************************************************
175  *              FlatSB_GetScrollInfo (COMCTL32.@)
176  *
177  * See GetScrollInfo.
178  */
179 BOOL WINAPI
180 FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info)
181 {
182     return GetScrollInfo(hwnd, nBar, info);
183 }
184
185 /***********************************************************************
186  *              FlatSB_GetScrollPos (COMCTL32.@)
187  *
188  * See GetScrollPos.
189  */
190 INT WINAPI
191 FlatSB_GetScrollPos(HWND hwnd, int nBar)
192 {
193     return GetScrollPos(hwnd, nBar);
194 }
195
196 /***********************************************************************
197  *              FlatSB_SetScrollPos (COMCTL32.@)
198  *
199  * See SetScrollPos.
200  */
201 INT WINAPI
202 FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw)
203 {
204     return SetScrollPos(hwnd, nBar, pos, bRedraw);
205 }
206
207 /***********************************************************************
208  *              FlatSB_SetScrollInfo (COMCTL32.@)
209  *
210  * See SetScrollInfo.
211  */
212 INT WINAPI
213 FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw)
214 {
215     return SetScrollInfo(hwnd, nBar, info, bRedraw);
216 }
217
218 /***********************************************************************
219  *              FlatSB_SetScrollRange (COMCTL32.@)
220  *
221  * See SetScrollRange.
222  */
223 INT WINAPI
224 FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw)
225 {
226     return SetScrollRange(hwnd, nBar, min, max, bRedraw);
227 }
228
229
230 static LRESULT
231 FlatSB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
232 {
233     TRACE("[%p] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
234     return 0;
235 }
236
237
238 static LRESULT
239 FlatSB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
240 {
241     TRACE("[%p] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
242     return 0;
243 }
244
245
246 static LRESULT WINAPI
247 FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
248 {
249     if (!FlatSB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
250         return DefWindowProcA( hwnd, uMsg, wParam, lParam );
251
252     switch (uMsg)
253     {
254         case WM_CREATE:
255             return FlatSB_Create (hwnd, wParam, lParam);
256
257         case WM_DESTROY:
258             return FlatSB_Destroy (hwnd, wParam, lParam);
259
260         default:
261             if ((uMsg >= WM_USER) && (uMsg < WM_APP))
262                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
263                     uMsg, wParam, lParam);
264             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
265     }
266     return 0;
267 }
268
269
270 VOID
271 FLATSB_Register (void)
272 {
273     WNDCLASSA wndClass;
274
275     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
276     wndClass.style         = CS_GLOBALCLASS;
277     wndClass.lpfnWndProc   = (WNDPROC)FlatSB_WindowProc;
278     wndClass.cbClsExtra    = 0;
279     wndClass.cbWndExtra    = sizeof(FLATSB_INFO *);
280     wndClass.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROW);
281     wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
282     wndClass.lpszClassName = FLATSB_CLASSA;
283
284     RegisterClassA (&wndClass);
285 }
286
287
288 VOID
289 FLATSB_Unregister (void)
290 {
291     UnregisterClassA (FLATSB_CLASSA, NULL);
292 }