locked
How to get the correct width for a control in win32? RRS feed

  • Question

  • I have a dialog box and (for reasons I wont go into) I will be manually creating some controls via CreateWindow.

    I am reading https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing and for some items like combo boxes and edit controls it says "width of longest item + 30%" or similar. For other controls (labels and check boxes) it gives no width value.

    Given a dialog window handle, a font handle for the font the control will be using and a text string (the label for a check box or label control or the longest anticipated string for an edit or combo box control), how can I figure out what width to use when creating the control (either in dialog units or pixels) in a way that is independent of the font being used and the users settings for resolution and etc? Also is there any size guideline (similar to the above MSDN link) for the common controls such as the up-down control and the combo box ex control to figure out what size those need to be created at when creating them to match the standard Microsoft UI guidelines?

    Monday, January 29, 2018 12:04 AM