Dynamically scale DropdownWidth of TadxCommandBarDropDownList

Add-in Express™ Support Service
That's what is more important than anything else

Dynamically scale DropdownWidth of TadxCommandBarDropDownList
 
Daniel Triendl




Posts: 7
Joined: 2010-11-08
How can I dynamically calculate and set TadxCommandBarDropDownList.DropdownWidth to a value that will fully display the longest containing element? Office2010 automatically adjusts the width, but Office2003 doesn't.
Posted 09 Mar, 2012 06:48:51 Top
Andrei Smolin


Add-in Express team


Posts: 14975
Joined: 2006-05-11
Hello Daniel,

The Office object model doesn't provide any means for determining the size of an item shown by a CommandBarCombobox. I've gougled out an attempt to solve this task using Windows API, see here.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Mar, 2012 07:46:53 Top
Daniel Triendl




Posts: 7
Joined: 2010-11-08
Thanks, that works for me. Lot of VB code to call TCanvas.TextWidth tho ;).

Can I depend on the assumption that the font is always Tahoma Size 8 like in your example or do I have to get the correct font also?
Posted 09 Mar, 2012 08:46:16 Top
Andrei Smolin


Add-in Express team


Posts: 14975
Joined: 2006-05-11
I wouldn't rely on any assumption. Windows provides settings allowing you to change e.g. the font size. I wouldn't be surpized that you can change the font itself.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Mar, 2012 09:03:13 Top