comctl32: Fix UDM_GETPOS behaviour on out of range values.

This commit is contained in:
Piotr Caban 2013-10-16 16:34:51 +02:00 committed by Alexandre Julliard
parent ac31df438a
commit e58af930ff
1 changed files with 25 additions and 5 deletions

View File

@ -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:
{