Piotr Caban : comctl32: Fix UDM_GETPOS behaviour on out of range values.
Alexandre Julliard
julliard at winehq.org
Fri Jan 10 14:44:52 CST 2014
Module: wine
Branch: stable
Commit: 282205e06c882a7b714eba49d5ac77a182d66737
URL: http://source.winehq.org/git/wine.git/?a=commit;h=282205e06c882a7b714eba49d5ac77a182d66737
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Oct 16 16:34:51 2013 +0200
comctl32: Fix UDM_GETPOS behaviour on out of range values.
(cherry picked from commit e58af930ff2b54e543fceaa35148596e864be220)
---
dlls/comctl32/updown.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/updown.c b/dlls/comctl32/updown.c
index 2373031..0761774 100644
--- a/dlls/comctl32/updown.c
+++ b/dlls/comctl32/updown.c
@@ -482,6 +482,25 @@ static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
return 0;
}
+static int UPDOWN_GetPos(UPDOWN_INFO *infoPtr, BOOL *err)
+{
+ BOOL succ = UPDOWN_GetBuddyInt(infoPtr);
+ int val = infoPtr->CurVal;
+
+ if(!UPDOWN_InBounds(infoPtr, val)) {
+ if((infoPtr->MinVal < infoPtr->MaxVal && val < infoPtr->MinVal)
+ || (infoPtr->MinVal > infoPtr->MaxVal && val > infoPtr->MinVal))
+ val = infoPtr->MinVal;
+ else
+ val = infoPtr->MaxVal;
+
+ succ = FALSE;
+ }
+
+ if(err) *err = !succ;
+ return val;
+}
+
static int UPDOWN_SetPos(UPDOWN_INFO *infoPtr, int pos)
{
int ret = infoPtr->CurVal;
@@ -1090,8 +1109,11 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
case UDM_GETPOS:
{
- BOOL ret = UPDOWN_GetBuddyInt (infoPtr);
- return MAKELONG(infoPtr->CurVal, ret ? 0 : 1);
+ BOOL err;
+ int pos;
+
+ pos = UPDOWN_GetPos(infoPtr, &err);
+ return MAKELONG(pos, err);
}
case UDM_SETPOS:
{
@@ -1119,9 +1141,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
case UDM_GETPOS32:
{
- BOOL ret = UPDOWN_GetBuddyInt (infoPtr);
- if ((LPBOOL)lParam) *((LPBOOL)lParam) = !ret;
- return infoPtr->CurVal;
+ return UPDOWN_GetPos(infoPtr, (BOOL*)lParam);
}
case UDM_SETPOS32:
{
More information about the wine-cvs
mailing list