[2/2] user32: Use a macro instead of direct values

André Hentschel nerv at dawncrow.de
Mon Aug 9 09:50:30 CDT 2010


pointed out by Nikolay Sivov
---
 dlls/user32/button.c |   19 +++++++++----------
 include/winuser.h    |    2 ++
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index ce482c6..3f9d7ba 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -31,7 +31,6 @@
  *  Styles
  *  - BS_NOTIFY: is it complete?
  *  - BS_RIGHTBUTTON: same as BS_LEFTTEXT
- *  - BS_TYPEMASK
  *
  *  Messages
  *  - WM_CHAR: Checks a (manual or automatic) check box on '+' or '=', clears it on '-' key.
@@ -191,7 +190,7 @@ static inline void set_button_font( HWND hwnd, HFONT font )
 
 static inline UINT get_button_type( LONG window_style )
 {
-    return (window_style & 0x0f);
+    return (window_style & BS_TYPEMASK);
 }
 
 /* paint a button of any type */
@@ -273,8 +272,8 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
         /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
         if (btn_type == BS_USERBUTTON )
         {
-            style = (style & ~0x0f) | BS_PUSHBUTTON;
-            WIN_SetStyle( hWnd, style, 0x0f & ~style );
+            style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON;
+            WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style );
         }
         set_button_state( hWnd, BUTTON_UNCHECKED );
         return 0;
@@ -459,10 +458,10 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
         break;
 
     case BM_SETSTYLE:
-        if ((wParam & 0x0f) >= MAX_BTN_TYPE) break;
-        btn_type = wParam & 0x0f;
-        style = (style & ~0x0f) | btn_type;
-        WIN_SetStyle( hWnd, style, 0x0f & ~style );
+        if ((wParam & BS_TYPEMASK) >= MAX_BTN_TYPE) break;
+        btn_type = wParam & BS_TYPEMASK;
+        style = (style & ~BS_TYPEMASK) | btn_type;
+        WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style );
 
         /* Only redraw if lParam flag is set.*/
         if (lParam)
@@ -547,7 +546,7 @@ static UINT BUTTON_BStoDT( DWORD style, DWORD ex_style )
 
    /* "Convert" pushlike buttons to pushbuttons */
    if (style & BS_PUSHLIKE)
-      style &= ~0x0F;
+      style &= ~BS_TYPEMASK;
 
    if (!(style & BS_MULTILINE))
       dtStyle |= DT_SINGLELINE;
@@ -988,7 +987,7 @@ static void BUTTON_CheckAutoRadioButton( HWND hwnd )
     {
         if (!sibling) break;
         if ((hwnd != sibling) &&
-            ((GetWindowLongW( sibling, GWL_STYLE) & 0x0f) == BS_AUTORADIOBUTTON))
+            ((GetWindowLongW( sibling, GWL_STYLE) & BS_TYPEMASK) == BS_AUTORADIOBUTTON))
             SendMessageW( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 );
         sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
     } while (sibling != start);
diff --git a/include/winuser.h b/include/winuser.h
index d4920c2..ff61d88 100644
--- a/include/winuser.h
+++ b/include/winuser.h
@@ -700,6 +700,8 @@ typedef struct tagWINDOWPLACEMENT
 #define DLGWINDOWEXTRA      30
 
 /* Button control styles */
+#define BS_TYPEMASK            0x0000000FL
+
 #define BS_PUSHBUTTON          0x00000000L
 #define BS_DEFPUSHBUTTON       0x00000001L
 #define BS_CHECKBOX            0x00000002L
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list