Today I am faced with an issue of incrementing and decrementing my updown controls in WINAPI.
I have an image below of my updown control. It is buddied with an edit control
What I would want this control is to increment/decrement by 1 respectively when the arrow keys are pressed. I have tried the style: UDS_ARROWKEYS, but it doesn't work leading me to believe there's another method to solve this problem.
I have written a snippet to reproduce the image above.
HWND edit1 = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"250", WS_VISIBLE | WS_CHILD | ES_CENTER | ES_NUMBER...
HWND upDown1 = CreateWindow(L"MSCTLS_UPDOWN32", L"", WS_VISIBLE | WS_CHILD | UDS_ALIGNRIGHT...
SendMessage(upDown1, UDM_SETBUDDY, reinterpret_cast<WPARAM>(edit1), static_cast<LPARAM>(NULL));
Enable the UDS_SETBUDDYINT
style on the Up-Down control:
UDS_SETBUDDYINT
Causes the up-down control to set the text of the buddy window (using theWM_SETTEXT
message) when the position changes. The text consists of the position formatted as a decimal or hexadecimal string.
This is stated in the Up-Down Control Overviews documentation:
Up-Down Control Styles
...
An up-down control with theUDS_SETBUDDYINT
style sets the caption of its buddy window whenever the current position changes. The control inserts a thousands separator between every three digits of a decimal string unless theUDS_NOTHOUSANDS
style is specified. If the buddy window is a list box, an up-down control sets its current selection instead of its caption.You can specify the
UDS_ARROWKEYS
style to provide a keyboard interface for an up-down control. If this style is specified, the control processes the up and down arrow keys. The control also subclasses the buddy window so that it can process these keys when the buddy window has the focus.
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.