ownerdrawn button fix

Aric Stewart aric at codeweavers.com
Fri Aug 3 10:48:28 CDT 2001


There is a potentially big problem with how we draw buttons. We directly
call the drawing code in a number of places. However with ownerdrawn
buttons this can cause great problems, especially during destruction. 

A full fix would be to make sure we never call the paint function
directly. However the only time this seems to actually cause a crash is
with owner drawn. This patch corrected the problem with owner drawn so
that we do not have to retest everything with buttons.

-aric
-------------- next part --------------
Index: controls/button.c
===================================================================
RCS file: /cvstrees/crossover/wine/controls/button.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 button.c
--- controls/button.c	2001/05/03 23:41:23	1.1.1.1
+++ controls/button.c	2001/08/03 15:43:13
@@ -144,7 +144,12 @@
         }
 
     case WM_ENABLE:
-        PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
+        if (style != BS_OWNERDRAW)
+        {
+            PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
+        }
+        else
+	        InvalidateRect( hWnd, NULL, TRUE );
         break;
 
     case WM_CREATE:
@@ -259,13 +264,23 @@
         if (unicode) DEFWND_SetTextW( wndPtr, (LPCWSTR)lParam );
         else DEFWND_SetTextA( wndPtr, (LPCSTR)lParam );
 	if( wndPtr->dwStyle & WS_VISIBLE )
+        if (style != BS_OWNERDRAW)
+        {
             PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
+        }
+        else
+	        InvalidateRect( hWnd, NULL, TRUE );
         return 1; /* success. FIXME: check text length */
 
     case WM_SETFONT:
         infoPtr->hFont = (HFONT16)wParam;
         if (lParam && (wndPtr->dwStyle & WS_VISIBLE)) 
-	    PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
+        if (style != BS_OWNERDRAW)
+        {
+	        PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
+        }
+        else
+	        InvalidateRect( hWnd, NULL, TRUE );
         break;
 
     case WM_GETFONT:
@@ -283,12 +298,20 @@
                           MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd);
         }
         infoPtr->state |= BUTTON_HASFOCUS;
-        PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
+        if (style != BS_OWNERDRAW)
+        {
+            PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
+        }
+        else
+	        InvalidateRect( hWnd, NULL, TRUE );
         break;
 
     case WM_KILLFOCUS:
         infoPtr->state &= ~BUTTON_HASFOCUS;
-	PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
+    if (style != BS_OWNERDRAW)
+    {
+	    PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
+    }
 	InvalidateRect( hWnd, NULL, TRUE );
         break;
 
@@ -305,7 +328,12 @@
 
         /* Only redraw if lParam flag is set.*/
         if (lParam)
-           PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
+            if (style != BS_OWNERDRAW)
+            {
+                PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
+            }
+            else
+	            InvalidateRect( hWnd, NULL, TRUE );
 
         break;
 
@@ -364,7 +392,12 @@
 		    wndPtr->dwStyle &= ~WS_TABSTOP;
 	    }
             infoPtr->state = (infoPtr->state & ~3) | wParam;
-            PAINT_BUTTON( wndPtr, style, ODA_SELECT );
+            if (style != BS_OWNERDRAW)
+            {
+                PAINT_BUTTON( wndPtr, style, ODA_SELECT );
+            }
+            else
+	            InvalidateRect( hWnd, NULL, TRUE );
         }
         if ((style == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED))
             BUTTON_CheckAutoRadioButton( wndPtr );
@@ -386,7 +419,12 @@
             if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
             infoPtr->state &= ~BUTTON_HIGHLIGHTED;
         }
-        PAINT_BUTTON( wndPtr, style, ODA_SELECT );
+        if (style != BS_OWNERDRAW)
+        {
+            PAINT_BUTTON( wndPtr, style, ODA_SELECT );
+        }
+        else
+	        InvalidateRect( hWnd, NULL, TRUE );
         break;
 
     case WM_NCHITTEST:


More information about the wine-patches mailing list