'Up-Down control doesn't show its position in its buddy window

I created an up-down control by the following code.

HWND hEdit, hUpDown;

hEdit = CreateWindowExW(WS_EX_CLIENTEDGE,
                        L"EDIT",
                        Content.c_str(),
                        ES_LEFT | WS_VISIBLE | WS_CHILD,
                        600,
                        260,
                        100,
                        25,
                        hWndParent,
                        NULL,
                        hInstance,
                        NULL);

INITCOMMONCONTROLSEX iccx;
iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccx.dwICC  = ICC_UPDOWN_CLASS;
InitCommonControlsEx(&iccx);

hUpDown = CreateWindowExW(  0,
                            UPDOWN_CLASSW,
                            L"",
                            UDS_ARROWKEYS | UDS_ALIGNRIGHT | WS_VISIBLE | WS_CHILD,
                            0,
                            0,
                            0,
                            0,
                            hWndParent,
                            NULL,
                            hInstance,
                            NULL);

SendMessageW(hUpDown, UDM_SETBUDDY,   (WPARAM) hEdit, (LPARAM) NULL);
SendMessageW(hUpDown, UDM_SETRANGE32, (WPARAM) 0,     (LPARAM) 100);
Sleep(5000);
SendMessageW(hUpDown, UDM_SETPOS32,   (WPARAM) NULL,  (LPARAM) 20);
Sleep(5000);
SendMessageW(hUpDown, UDM_SETPOS32,   (WPARAM) NULL,  (LPARAM) 60);

I checked the return values of the SendMessageW() functions. They terminate successfully by returning the previous position value as documented.

The created up-down control looks normal:
the created up-down control

The problem is, sending the UDM_SETPOS32 message, clicking the up and down arrows and pressing the up and down keys on the keyboard have no effect. I can't change the contents of the edit control (the buddy window of the up-down control) without directly typing something into it. It just stays empty.

I am able to type anything in it manually by using keyboard:
example text input

How do I change the position/value of this up-down control by pressing keyboard arrow keys, by clicking the arrows in the GUI and by sending UDM_SETPOS32 in the code? What am I missing in my code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source