Poor implementation of flatsb. (Reacts to some but not all properites)

Andrew M. Johnston johnstonam at logica.com
Fri Oct 4 01:06:11 CDT 2002


Implements flat scroll bars by sending a set/get property message to the scroll control

This is no "the right implementation".  See previous comments in scroll.c but may be step forward.

The patch was developed without CVS access use patch -p1 from within
the top level wine directory to apply.

Requires: scrollbar.patch

License: X11

Andrew

--- wine-20020904/dlls/comctl32/flatsb.c	Fri Aug  9 09:07:29 2002
+++ wine/dlls/comctl32/flatsb.c	Sat Sep 28 20:40:02 2002
@@ -3,6 +3,7 @@
  *
  * Copyright 1998, 1999 Eric Kohl
  * Copyright 1998 Alex Priem
+ * Copyright 2002 Andrew M. Johnston
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,238 +19,201 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * 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 at abo.rhein-zeitung.de>
- *
- * TODO:
- *   - All messages.
- *   - All notifications.
- *
  */
 
 #include <string.h>
 #include "winbase.h"
 #include "winerror.h"
-#include "commctrl.h"
 #include "wine/debug.h"
+#include "win.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
-
-typedef struct
-{
-    DWORD dwDummy;  /* just to keep the compiler happy ;-) */
-} FLATSB_INFO, *LPFLATSB_INFO;
+#define FSB_GETPROP 0x00e5
+#define FSB_SETPROP 0x00e7
 
-#define FlatSB_GetInfoPtr(hwnd) ((FLATSB_INFO*)GetWindowLongA (hwnd, 0))
+WINE_DEFAULT_DEBUG_CHANNEL(scroll);
 
 
 /***********************************************************************
- *		InitializeFlatSB (COMCTL32.@)
+ *     InitializeFlatSB (COMCTL32.@)
  *
- *	returns nonzero if successful, zero otherwise
+ * returns nonzero if successful, zero otherwise
  *
  */
-BOOL WINAPI InitializeFlatSB(HWND hwnd)
+BOOL WINAPI InitializeFlatSB(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */)
 {
-    TRACE("[%04x]\n", hwnd);
-    FIXME("stub\n");
-    return FALSE;
+	TRACE("[%04x]\n", hwnd);
+	return TRUE;
 }
 
-/***********************************************************************
- *		UninitializeFlatSB (COMCTL32.@)
- *
- *	returns:
- *	E_FAIL		if one of the scroll bars is currently in use
- *	S_FALSE		if InitializeFlatSB was never called on this hwnd
- *	S_OK		otherwise
- *
- */
-HRESULT WINAPI UninitializeFlatSB(HWND hwnd)
-{
-    TRACE("[%04x]\n", hwnd);
-    FIXME("stub\n");
-    return S_FALSE;
-}
 
 /***********************************************************************
- *		FlatSB_GetScrollProp (COMCTL32.@)
+ *      UninitializeFlatSB (COMCTL32.@)
  *
- *	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.
+ * returns:
+ *    E_FAIL   if one of the scroll bars is currently in use
+ *    S_FALSE  if InitializeFlatSB was never called on this hwnd
+ *    S_OK     otherwise
  *
  */
-BOOL WINAPI
-FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
+HRESULT WINAPI UninitializeFlatSB(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */)
 {
-    TRACE("[%04x] propIndex=%d\n", hwnd, propIndex);
-    FIXME("stub\n");
-    return FALSE;
+	TRACE("[%04x]\n", hwnd);
+	return S_OK;
 }
 
-/***********************************************************************
- *		FlatSB_SetScrollProp (COMCTL32.@)
- */
-BOOL WINAPI
-FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
-{
-    TRACE("[%04x] index=%u newValue=%d flag=%d\n", hwnd, index, newValue, flag);
-    FIXME("stub\n");
-    return FALSE;
-}
 
 /***********************************************************************
- * 	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."
+ *      FlatSB_GetScrollProp (COMCTL32.@)
  *
- *	So, if we just call the standard functions until we implement
- *	the flat scroll bar functions, flat scroll bars will show up and
- *	behave properly, as though they had simply not been setup to
- *	have flat properties.
+ * Returns:
+ *  nonzero if successful, or zero otherwise.
  *
- *	Susan <sfarley at codeweavers.com>
+ *  If index is WSB_PROP_HSTYLE, the return is nonzero if InitializeFlatSB
+ *  has been called for this window, or zero otherwise.
  *
  */
-
-/***********************************************************************
- *		FlatSB_EnableScrollBar (COMCTL32.@)
- */
-BOOL WINAPI
-FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags)
+BOOL WINAPI FlatSB_GetScrollProp(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT propIndex /* [in] Index of scroll bar property to be obtained */,
+LPINT prop /* [out] Value of scroll bar property */)
 {
-    return EnableScrollBar(hwnd, nBar, flags);
+	WARN("[poorly implented] hwnd=%04x propIndex=%d\n", hwnd, propIndex);
+	return SendMessageA(hwnd, FSB_GETPROP, propIndex, (INT)prop);
 }
 
-/***********************************************************************
- *		FlatSB_ShowScrollBar (COMCTL32.@)
- */
-BOOL WINAPI
-FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow)
-{
-    return ShowScrollBar(hwnd, nBar, fShow);
-}
 
 /***********************************************************************
- *		FlatSB_GetScrollRange (COMCTL32.@)
+ *      FlatSB_SetScrollProp (COMCTL32.@)
  */
-BOOL WINAPI
-FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max)
+BOOL WINAPI FlatSB_SetScrollProp(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+UINT index /* [in]  Index of scroll bar property to be obtained */,
+INT newValue /* [in] Value of property to be set */,
+BOOL flag /* [in] Redraw the scroll bar immediately */)
 {
-    return GetScrollRange(hwnd, nBar, min, max);
+	WARN("[poorly implented] hwnd=%04x index=%u newValue=%d flag=%d\n",
+		hwnd, index, newValue, flag);
+	SendMessageA(hwnd, FSB_SETPROP, index, newValue);
+	if (flag) SendMessageA(hwnd, WM_PAINT, index, newValue);
+	return 0;
 }
 
+
 /***********************************************************************
- *		FlatSB_GetScrollInfo (COMCTL32.@)
+ *      FlatSB_EnableScrollBar (COMCTL32.@)
+ *
+ * RETURNS STD
  */
 BOOL WINAPI
-FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info)
+FlatSB_EnableScrollBar(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT nBar /* [in] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL */,
+UINT flags /* [in] Flags indicating which scroll bars to enable */)
 {
-    return GetScrollInfo(hwnd, nBar, info);
+	return EnableScrollBar(hwnd, nBar, flags);
 }
 
-/***********************************************************************
- *		FlatSB_GetScrollPos (COMCTL32.@)
- */
-INT WINAPI
-FlatSB_GetScrollPos(HWND hwnd, int nBar)
-{
-    return GetScrollPos(hwnd, nBar);
-}
 
 /***********************************************************************
- *		FlatSB_SetScrollPos (COMCTL32.@)
+ *      FlatSB_ShowScrollBar (COMCTL32.@)
+ *
+ * RETURNS STD
  */
-INT WINAPI
-FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw)
+BOOL WINAPI FlatSB_ShowScrollBar(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT nBar /* [in] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL */,
+BOOL fShow /* [in] TRUE = show, FALSE = hide  */)
 {
-    return SetScrollPos(hwnd, nBar, pos, bRedraw);
+	return ShowScrollBar(hwnd, nBar, fShow);
 }
 
+
 /***********************************************************************
- *		FlatSB_SetScrollInfo (COMCTL32.@)
+ *      FlatSB_GetScrollRange (COMCTL32.@)
+ *
+ * RETURNS STD
  */
-INT WINAPI
-FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw)
+BOOL WINAPI FlatSB_GetScrollRange(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL  */,
+LPINT lpMin /* [out] Where to store minimum value */,
+LPINT lpMax /* [out] Where to store maximum value */)
 {
-    return SetScrollInfo(hwnd, nBar, info, bRedraw);
+	return GetScrollRange(hwnd, nBar, lpMin, lpMin);
 }
 
+
 /***********************************************************************
- *		FlatSB_SetScrollRange (COMCTL32.@)
+ *      FlatSB_GetScrollInfo (COMCTL32.@)
+ *
+ * RETURNS STD
  */
-INT WINAPI
-FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw)
+BOOL WINAPI FlatSB_GetScrollInfo(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */, 
+LPSCROLLINFO info /* [in/out] (fMask specifies which values to retrieve) */)
 {
-    return SetScrollRange(hwnd, nBar, min, max, bRedraw);
+	return GetScrollInfo(hwnd, nBar, info);
 }
 
 
-static LRESULT
-FlatSB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
+/***********************************************************************
+ *      FlatSB_GetScrollPos (COMCTL32.@)
+ *
+ * RETURNS STD
+ */
+INT WINAPI FlatSB_GetScrollPos(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */)
 {
-    TRACE("[%04x] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
-    return 0;
+	return GetScrollPos(hwnd, nBar);
 }
 
 
-static LRESULT
-FlatSB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
+/***********************************************************************
+ *      FlatSB_SetScrollPos (COMCTL32.@)
+ *
+ * RETURNS STD
+ */
+INT WINAPI FlatSB_SetScrollPos(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
+INT nPos /* [in] New value */,
+BOOL bRedraw /* [in] Should scrollbar be redrawn afterwards ? */)
 {
-    TRACE("[%04x] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
-    return 0;
+	return SetScrollPos(hwnd, nBar, nPos, bRedraw);
 }
 
 
-static LRESULT WINAPI
-FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+/***********************************************************************
+ *      FlatSB_SetScrollInfo (COMCTL32.@)
+ *
+ * RETURNS STD
+ */
+INT WINAPI FlatSB_SetScrollInfo(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */, 
+const LPSCROLLINFO info /* [in] Specifies what to change and new values */,
+BOOL bRedraw /* [in] Should scrollbar be redrawn afterwards ? */)
 {
-    if (!FlatSB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
-	return DefWindowProcA( hwnd, uMsg, wParam, lParam );
-
-    switch (uMsg)
-    {
-	case WM_CREATE:
-	    return FlatSB_Create (hwnd, wParam, lParam);
-
-	case WM_DESTROY:
-	    return FlatSB_Destroy (hwnd, wParam, lParam);
-
-	default:
-	    if ((uMsg >= WM_USER) && (uMsg < WM_APP))
-		ERR("unknown msg %04x wp=%08x lp=%08lx\n",
-                    uMsg, wParam, lParam);
-	    return DefWindowProcA (hwnd, uMsg, wParam, lParam);
-    }
-    return 0;
+	return SetScrollInfo(hwnd, nBar, info, bRedraw);
 }
 
 
-VOID
-FLATSB_Register (void)
+/***********************************************************************
+ *      FlatSB_SetScrollRange (COMCTL32.@)
+ *
+ * RETURNS STD
+ */
+INT WINAPI FlatSB_SetScrollRange(
+HWND hwnd /* [in] Handle of window with scrollbar(s) */,
+INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
+INT minVal /* [in] New minimum value */,
+INT maxVal /* [in] New maximum value */,
+BOOL bRedraw /* [in] Should scrollbar be redrawn afterwards ? */)
 {
-    WNDCLASSA wndClass;
-
-    ZeroMemory (&wndClass, sizeof(WNDCLASSA));
-    wndClass.style         = CS_GLOBALCLASS;
-    wndClass.lpfnWndProc   = (WNDPROC)FlatSB_WindowProc;
-    wndClass.cbClsExtra    = 0;
-    wndClass.cbWndExtra    = sizeof(FLATSB_INFO *);
-    wndClass.hCursor       = LoadCursorA (0, IDC_ARROWA);
-    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
-    wndClass.lpszClassName = FLATSB_CLASSA;
-
-    RegisterClassA (&wndClass);
+	return SetScrollRange(hwnd, nBar, minVal, maxVal, bRedraw);
 }
 
-
-VOID
-FLATSB_Unregister (void)
-{
-    UnregisterClassA (FLATSB_CLASSA, (HINSTANCE)NULL);
-}
--- wine-20020904/dlls/comctl32/commctrl.c	Fri Aug  9 09:07:29 2002
+++ wine/dlls/comctl32/commctrl.c	Sat Sep 21 00:50:42 2002
@@ -39,8 +39,6 @@
 extern void COMBOEX_Unregister(void);
 extern void DATETIME_Register(void);
 extern void DATETIME_Unregister(void);
-extern void FLATSB_Register(void);
-extern void FLATSB_Unregister(void);
 extern void HEADER_Register(void);
 extern void HEADER_Unregister(void);
 extern void HOTKEY_Register(void);
@@ -130,7 +128,6 @@
 
             /* register all Win95 common control classes */
             ANIMATE_Register ();
-            FLATSB_Register ();
             HEADER_Register ();
             HOTKEY_Register ();
             LISTVIEW_Register ();
@@ -149,7 +146,6 @@
             ANIMATE_Unregister ();
             COMBOEX_Unregister ();
             DATETIME_Unregister ();
-            FLATSB_Unregister ();
             HEADER_Unregister ();
             HOTKEY_Unregister ();
             IPADDRESS_Unregister ();





More information about the wine-patches mailing list