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


Guest


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: 18821
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 http://social.msdn.microsoft.com/Forums/is/isvvba/thread/ef9573eb-6771-4687-9931-ba67bce0bc66.


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


Guest


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: 18821
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.


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