comctl32/updown: Fix control behaviour for UDS_SETBUDDYINT style.
This commit is contained in:
parent
2f9d29b42b
commit
4efa9f5e43
|
@ -567,6 +567,7 @@ static void test_UDS_SETBUDDYINT(void)
|
||||||
HWND updown;
|
HWND updown;
|
||||||
DWORD style, ret;
|
DWORD style, ret;
|
||||||
CHAR text[10];
|
CHAR text[10];
|
||||||
|
BOOL b;
|
||||||
|
|
||||||
/* creating without UDS_SETBUDDYINT */
|
/* creating without UDS_SETBUDDYINT */
|
||||||
updown = create_updown_control(0);
|
updown = create_updown_control(0);
|
||||||
|
@ -577,24 +578,37 @@ static void test_UDS_SETBUDDYINT(void)
|
||||||
ok(style & UDS_SETBUDDYINT, "Expected UDS_SETBUDDY to be set\n");
|
ok(style & UDS_SETBUDDYINT, "Expected UDS_SETBUDDY to be set\n");
|
||||||
SendMessage(updown, UDM_SETPOS, 0, 20);
|
SendMessage(updown, UDM_SETPOS, 0, 20);
|
||||||
GetWindowTextA(edit, text, sizeof(text)/sizeof(CHAR));
|
GetWindowTextA(edit, text, sizeof(text)/sizeof(CHAR));
|
||||||
todo_wine ok(lstrlenA(text) == 0, "Expected empty string\n");
|
ok(lstrlenA(text) == 0, "Expected empty string\n");
|
||||||
DestroyWindow(updown);
|
DestroyWindow(updown);
|
||||||
|
|
||||||
/* creating with UDS_SETBUDDYINT */
|
/* creating with UDS_SETBUDDYINT */
|
||||||
updown = create_updown_control(UDS_SETBUDDYINT);
|
updown = create_updown_control(UDS_SETBUDDYINT);
|
||||||
GetWindowTextA(edit, text, sizeof(text)/sizeof(CHAR));
|
GetWindowTextA(edit, text, sizeof(text)/sizeof(CHAR));
|
||||||
|
/* 50 is initial value here */
|
||||||
ok(lstrcmpA(text, "50") == 0, "Expected '50', got '%s'\n", text);
|
ok(lstrcmpA(text, "50") == 0, "Expected '50', got '%s'\n", text);
|
||||||
/* now remove style flag */
|
/* now remove style flag */
|
||||||
style = GetWindowLongA(updown, GWL_STYLE);
|
style = GetWindowLongA(updown, GWL_STYLE);
|
||||||
SetWindowLongA(updown, GWL_STYLE, style & ~UDS_SETBUDDYINT);
|
SetWindowLongA(updown, GWL_STYLE, style & ~UDS_SETBUDDYINT);
|
||||||
SendMessage(updown, UDM_SETPOS, 0, 20);
|
SendMessage(updown, UDM_SETPOS, 0, 20);
|
||||||
GetWindowTextA(edit, text, sizeof(text)/sizeof(CHAR));
|
GetWindowTextA(edit, text, sizeof(text)/sizeof(CHAR));
|
||||||
todo_wine ok(lstrcmpA(text, "20") == 0, "Expected '20', got '%s'\n", text);
|
ok(lstrcmpA(text, "20") == 0, "Expected '20', got '%s'\n", text);
|
||||||
/* set edit text directly, check position */
|
/* set edit text directly, check position */
|
||||||
strcpy(text, "10");
|
strcpy(text, "10");
|
||||||
SetWindowTextA(edit, text);
|
SetWindowTextA(edit, text);
|
||||||
ret = SendMessageA(updown, UDM_GETPOS32, 0, 0);
|
ret = SendMessageA(updown, UDM_GETPOS32, 0, 0);
|
||||||
todo_wine expect(10, ret);
|
expect(10, ret);
|
||||||
|
strcpy(text, "11");
|
||||||
|
SetWindowTextA(edit, text);
|
||||||
|
ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
|
||||||
|
expect(11, LOWORD(ret));
|
||||||
|
expect(0, HIWORD(ret));
|
||||||
|
/* set to invalid value */
|
||||||
|
strcpy(text, "21st");
|
||||||
|
SetWindowTextA(edit, text);
|
||||||
|
b = FALSE;
|
||||||
|
ret = SendMessageA(updown, UDM_GETPOS32, 0, (LPARAM)&b);
|
||||||
|
expect(11, ret);
|
||||||
|
expect(TRUE, b);
|
||||||
/* set style back */
|
/* set style back */
|
||||||
style = GetWindowLongA(updown, GWL_STYLE);
|
style = GetWindowLongA(updown, GWL_STYLE);
|
||||||
SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
|
SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
|
||||||
|
|
|
@ -86,6 +86,7 @@ typedef struct
|
||||||
#define FLAG_DECR 0x02
|
#define FLAG_DECR 0x02
|
||||||
#define FLAG_MOUSEIN 0x04
|
#define FLAG_MOUSEIN 0x04
|
||||||
#define FLAG_PRESSED 0x08
|
#define FLAG_PRESSED 0x08
|
||||||
|
#define FLAG_BUDDYINT 0x10 /* UDS_SETBUDDYINT was set on creation */
|
||||||
#define FLAG_ARROW (FLAG_INCR | FLAG_DECR)
|
#define FLAG_ARROW (FLAG_INCR | FLAG_DECR)
|
||||||
|
|
||||||
#define BUDDY_TYPE_UNKNOWN 0
|
#define BUDDY_TYPE_UNKNOWN 0
|
||||||
|
@ -267,7 +268,7 @@ static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
|
||||||
WCHAR txt[20], sep, *src, *dst;
|
WCHAR txt[20], sep, *src, *dst;
|
||||||
int newVal;
|
int newVal;
|
||||||
|
|
||||||
if (!((infoPtr->dwStyle & UDS_SETBUDDYINT) && IsWindow(infoPtr->Buddy)))
|
if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/*if the buddy is a list window, we must set curr index */
|
/*if the buddy is a list window, we must set curr index */
|
||||||
|
@ -312,7 +313,7 @@ static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
|
||||||
WCHAR txt[20];
|
WCHAR txt[20];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!((infoPtr->dwStyle & UDS_SETBUDDYINT) && IsWindow(infoPtr->Buddy)))
|
if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
TRACE("set new value(%d) to buddy.\n", infoPtr->CurVal);
|
TRACE("set new value(%d) to buddy.\n", infoPtr->CurVal);
|
||||||
|
@ -520,20 +521,25 @@ static LRESULT CALLBACK
|
||||||
UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
WNDPROC superClassWndProc = (WNDPROC)GetPropW(hwnd, BUDDY_SUPERCLASS_WNDPROC);
|
WNDPROC superClassWndProc = (WNDPROC)GetPropW(hwnd, BUDDY_SUPERCLASS_WNDPROC);
|
||||||
|
HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND);
|
||||||
|
UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(upDownHwnd);
|
||||||
|
|
||||||
TRACE("hwnd=%p, wndProc=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n",
|
TRACE("hwnd=%p, wndProc=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n",
|
||||||
hwnd, superClassWndProc, uMsg, wParam, lParam);
|
hwnd, superClassWndProc, uMsg, wParam, lParam);
|
||||||
|
|
||||||
if (uMsg == WM_KEYDOWN) {
|
switch(uMsg)
|
||||||
HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND);
|
{
|
||||||
|
case WM_KEYDOWN:
|
||||||
UPDOWN_KeyPressed(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam);
|
UPDOWN_KeyPressed(infoPtr, (int)wParam);
|
||||||
if ((wParam == VK_UP) || (wParam == VK_DOWN)) return 0;
|
if ((wParam == VK_UP) || (wParam == VK_DOWN)) return 0;
|
||||||
}
|
break;
|
||||||
else if (uMsg == WM_MOUSEWHEEL) {
|
|
||||||
HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND);
|
|
||||||
|
|
||||||
UPDOWN_MouseWheel(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam);
|
case WM_MOUSEWHEEL:
|
||||||
|
UPDOWN_MouseWheel(infoPtr, (int)wParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CallWindowProcW( superClassWndProc, hwnd, uMsg, wParam, lParam);
|
return CallWindowProcW( superClassWndProc, hwnd, uMsg, wParam, lParam);
|
||||||
|
@ -586,7 +592,7 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
|
||||||
infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
|
infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(infoPtr->dwStyle & UDS_ARROWKEYS){
|
if (infoPtr->dwStyle & UDS_ARROWKEYS) {
|
||||||
/* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property
|
/* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property
|
||||||
when we reset the upDown ctrl buddy to another buddy because it is not
|
when we reset the upDown ctrl buddy to another buddy because it is not
|
||||||
good to break the window proc chain. */
|
good to break the window proc chain. */
|
||||||
|
@ -865,7 +871,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
|
||||||
infoPtr->MaxVal = 0;
|
infoPtr->MaxVal = 0;
|
||||||
infoPtr->Base = 10; /* Default to base 10 */
|
infoPtr->Base = 10; /* Default to base 10 */
|
||||||
infoPtr->Buddy = 0; /* No buddy window yet */
|
infoPtr->Buddy = 0; /* No buddy window yet */
|
||||||
infoPtr->Flags = 0; /* And no flags */
|
infoPtr->Flags = (infoPtr->dwStyle & UDS_SETBUDDYINT) ? FLAG_BUDDYINT : 0;
|
||||||
|
|
||||||
SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER);
|
SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER);
|
||||||
|
|
||||||
|
@ -1045,8 +1051,8 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
|
||||||
|
|
||||||
case UDM_GETPOS:
|
case UDM_GETPOS:
|
||||||
{
|
{
|
||||||
int temp = UPDOWN_GetBuddyInt (infoPtr);
|
BOOL ret = UPDOWN_GetBuddyInt (infoPtr);
|
||||||
return MAKELONG(infoPtr->CurVal, temp ? 0 : 1);
|
return MAKELONG(infoPtr->CurVal, ret ? 0 : 1);
|
||||||
}
|
}
|
||||||
case UDM_SETPOS:
|
case UDM_SETPOS:
|
||||||
{
|
{
|
||||||
|
@ -1083,9 +1089,11 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UDM_GETPOS32:
|
case UDM_GETPOS32:
|
||||||
if ((LPBOOL)lParam != NULL) *((LPBOOL)lParam) = TRUE;
|
{
|
||||||
|
BOOL ret = UPDOWN_GetBuddyInt (infoPtr);
|
||||||
|
if ((LPBOOL)lParam) *((LPBOOL)lParam) = !ret;
|
||||||
return infoPtr->CurVal;
|
return infoPtr->CurVal;
|
||||||
|
}
|
||||||
case UDM_SETPOS32:
|
case UDM_SETPOS32:
|
||||||
{
|
{
|
||||||
int temp;
|
int temp;
|
||||||
|
|
Loading…
Reference in New Issue