Piotr Caban : comctl32: Fix UDM_SETPOS behavior on out of range values.
Alexandre Julliard
julliard at winehq.org
Wed Oct 16 14:25:50 CDT 2013
Module: wine
Branch: master
Commit: ac31df438acf325fa10ab0cc6e2683e16f81d5ae
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ac31df438acf325fa10ab0cc6e2683e16f81d5ae
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Oct 16 16:34:39 2013 +0200
comctl32: Fix UDM_SETPOS behavior on out of range values.
---
dlls/comctl32/updown.c | 49 +++++++++++++++++++++++++++--------------------
1 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/dlls/comctl32/updown.c b/dlls/comctl32/updown.c
index a42b40f..2373031 100644
--- a/dlls/comctl32/updown.c
+++ b/dlls/comctl32/updown.c
@@ -482,6 +482,32 @@ static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
return 0;
}
+static int UPDOWN_SetPos(UPDOWN_INFO *infoPtr, int pos)
+{
+ int ret = infoPtr->CurVal;
+
+ if(!UPDOWN_InBounds(infoPtr, pos)) {
+ if((infoPtr->MinVal < infoPtr->MaxVal && pos < infoPtr->MinVal)
+ || (infoPtr->MinVal > infoPtr->MaxVal && pos > infoPtr->MinVal))
+ pos = infoPtr->MinVal;
+ else
+ pos = infoPtr->MaxVal;
+ }
+
+ infoPtr->CurVal = pos;
+ UPDOWN_SetBuddyInt(infoPtr);
+
+ if(!UPDOWN_InBounds(infoPtr, ret)) {
+ if((infoPtr->MinVal < infoPtr->MaxVal && ret < infoPtr->MinVal)
+ || (infoPtr->MinVal > infoPtr->MaxVal && ret > infoPtr->MinVal))
+ ret = infoPtr->MinVal;
+ else
+ ret = infoPtr->MaxVal;
+ }
+ return ret;
+}
+
+
/***********************************************************************
* UPDOWN_SetRange
*
@@ -1069,17 +1095,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
}
case UDM_SETPOS:
{
- int temp = (short)LOWORD(lParam);
-
- TRACE("UpDown Ctrl new value(%d), hwnd=%p\n", temp, hwnd);
- if(!UPDOWN_InBounds(infoPtr, temp)) {
- if(temp < infoPtr->MinVal) temp = infoPtr->MinVal;
- if(temp > infoPtr->MaxVal) temp = infoPtr->MaxVal;
- }
- wParam = infoPtr->CurVal;
- infoPtr->CurVal = temp;
- UPDOWN_SetBuddyInt (infoPtr);
- return wParam; /* return prev value */
+ return UPDOWN_SetPos(infoPtr, (short)LOWORD(lParam));
}
case UDM_GETRANGE:
return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
@@ -1109,16 +1125,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
}
case UDM_SETPOS32:
{
- int temp;
-
- if(!UPDOWN_InBounds(infoPtr, (int)lParam)) {
- if((int)lParam < infoPtr->MinVal) lParam = infoPtr->MinVal;
- if((int)lParam > infoPtr->MaxVal) lParam = infoPtr->MaxVal;
- }
- temp = infoPtr->CurVal; /* save prev value */
- infoPtr->CurVal = (int)lParam; /* set the new value */
- UPDOWN_SetBuddyInt (infoPtr);
- return temp; /* return prev value */
+ return UPDOWN_SetPos(infoPtr, (int)lParam);
}
case UDM_GETUNICODEFORMAT:
/* we lie a bit here, we're always using Unicode internally */
More information about the wine-cvs
mailing list