1

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.

andlabs
  • 11,290
  • 1
  • 31
  • 52
  • 1
    Why not just move the up/down control by the same delta as the buddy window? Personally I would not expect either to resize after creation, just to be repositioned. – icabod Oct 28 '14 at 16:43
  • Hm... I did a small test, and it seems the (0, 0)/0x0 thing does take effect properly, even if I set the buddy control afterward; but they only take effect for the size of the window when the buddy control is assigned. This is a problem for me, as I figure out the size of my controls after the fact, but I could probably work around that somehow... – andlabs Oct 28 '14 at 17:08
  • Update: setting the buddy control anew each time does not work (it works on wine but not on Windows XP). – andlabs Oct 28 '14 at 17:58
  • Updated the question with the above information and additional info. – andlabs Oct 28 '14 at 19:29
  • What happens if you reset the buddy to NULL and then set it again to the proper control? – Jonathan Potter Oct 28 '14 at 20:21
  • No change. I also looked with Spy++ this time, and it shows the updown as being 17x0 at (0, 0). – andlabs Oct 28 '14 at 21:57

0 Answers0