comctl32/updown: Allow ranges with max < min for Up/Down control
Nikolay Sivov
bunglehead at gmail.com
Fri Apr 10 04:00:59 CDT 2009
http://bugs.winehq.org/show_bug.cgi?id=3048
Setting range with max value less then min one allowed for
both UDM_SETRANGE and UDM_SETRANGE32.
Setting min == max isn't handled properly by this patch (and doesn't
without it too).
Correct behaviour is to disable arrows in internal (not window style level)
way. A comment added for that case.
Changelog:
- Allow ranges with max < min for Up/Down control
- Use a single function for both UDM_SETRANGE[32]
>From 9a808eb7f744e95c8f21f9df70b9f288eabdad0a Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Fri, 10 Apr 2009 04:52:27 -0400
Subject: Allow ranges with max < min for Up/Down control
---
dlls/comctl32/updown.c | 40 ++++++++++++++++++++++++++++------------
1 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/dlls/comctl32/updown.c b/dlls/comctl32/updown.c
index d0bc27c..e39e92b 100644
--- a/dlls/comctl32/updown.c
+++ b/dlls/comctl32/updown.c
@@ -63,6 +63,7 @@ typedef struct
INT BuddyType; /* Remembers the buddy type BUDDY_TYPE_* */
INT Flags; /* Internal Flags FLAG_* */
BOOL UnicodeFormat; /* Marks the use of Unicode internally */
+
} UPDOWN_INFO;
/* Control configuration constants */
@@ -470,6 +471,27 @@ static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
}
/***********************************************************************
+ * UPDOWN_SetRange
+ *
+ * Handle UDM_SETRANGE, UDM_SETRANGE32
+ *
+ * FIXME: handle Max == Min properly:
+ * - arrows should be disabled (without WS_DISABLED set),
+ * visually they can't be pressed and don't respond;
+ * - all input messages should still pass in.
+ */
+static LRESULT UPDOWN_SetRange(UPDOWN_INFO *infoPtr, INT Max, INT Min)
+{
+ infoPtr->MaxVal = Max;
+ infoPtr->MinVal = Min;
+
+ TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
+ infoPtr->MinVal, infoPtr->MaxVal, infoPtr->Self);
+
+ return 0;
+}
+
+/***********************************************************************
* UPDOWN_MouseWheel
*
* Handle mouse wheel scrolling
@@ -1045,12 +1067,11 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
case UDM_SETRANGE:
- /* we must have: */
- infoPtr->MaxVal = (short)(lParam); /* UD_MINVAL <= Max <= UD_MAXVAL */
- infoPtr->MinVal = (short)HIWORD(lParam); /* UD_MINVAL <= Min <= UD_MAXVAL */
- /* |Max-Min| <= UD_MAXVAL */
- TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
- infoPtr->MinVal, infoPtr->MaxVal, hwnd);
+ /* we must have:
+ UD_MINVAL <= Max <= UD_MAXVAL
+ UD_MINVAL <= Min <= UD_MAXVAL
+ |Max-Min| <= UD_MAXVAL */
+ UPDOWN_SetRange(infoPtr, (short)lParam, (short)HIWORD(lParam));
break;
case UDM_GETRANGE32:
@@ -1059,12 +1080,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
break;
case UDM_SETRANGE32:
- infoPtr->MinVal = (INT)wParam;
- infoPtr->MaxVal = (INT)lParam;
- if (infoPtr->MaxVal <= infoPtr->MinVal)
- infoPtr->MaxVal = infoPtr->MinVal + 1;
- TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
- infoPtr->MinVal, infoPtr->MaxVal, hwnd);
+ UPDOWN_SetRange(infoPtr, (INT)lParam, (INT)wParam);
break;
case UDM_GETPOS32:
--
1.5.6.5
More information about the wine-patches
mailing list