Here's one that eludes Google searches, partially because the term 'position' applies to both the position on screen (which is what I am talking about) and the current position of the up/down control (which should probably be called current value and which is not what I'm talking about).
How do I set the proper position and size of an up/down control? The documentation is very vague on this: it says the UDS_ALIGNLEFT
/UDS_ALIGNRIGHT
styles automatically reposition and resize the buddy window, but that seems to only happen on control creation. The sample code also given on MSDN says to give the up-down position (0, 0) and size 0x0, but again, this seems to only affect window creation. This window creation is especially a problem because I set the buddy control after window creation with UDM_SETBUDDY
.
Even more bizarrely, the Windows layout pages (both the current Vista+ pages, the MMC preferred size pages, and the old Microsoft Windows User Experience book) don't specify what the proper size of an up/down control should be!
I did try moving/resizing just the buddy window, but the up-down control did not follow. I tried moving/resizing just the up-down control, but the whole up-down control was made the given size and the buddy control did not follow. I tried moving/resizing the buddy window and then setting the up-down size to 0x0 and position to (0, 0) but that also did not work.
Alternatively, do I need to make the buddy window the parent of the up-down control for this to work? Or would that not work?
I am using Common Controls 6 and have tested on Windows XP and wine.
Thanks.
Updates
As it turns out, setting (0,0)/0x0 does work, even with UDM_SETBUDDY
— but only the first time. I'm not sure if this means "the first time period" or "the first time you set a unique buddy". Repeatedly setting the same buddy with UDM_SETBUDDY
does not work on Windows XP (it does work in wine though, so perhaps I should try again...).
My issue is that I determine the proper size of my controls at the time of resize (since I use DLU calculations). Having a fixed width/height at creation time also does not properly handle the scenario that settings that can affect DLU-to-pixel conversions (DPI changes, font changes, etc.) change during the execution of the program.
I'm starting to wonder if I should just recreate the updown each time, but that sounds unnecessarily expensive and I'll prefer to save that for a last resort.