AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

Set the dropdown width of a combobox

This sub sends a message to a combo box, setting the width of the drop down area. It is only a wrapper for the SendMessage API function. Pass it the combo box, and the new width, and it will send the appropriate message.

Declarations

Paste this into the declarations section of a module:

Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Long) As Long

Public Const CB_SETDROPPEDWIDTH = &H160

Procedure

Public Sub SetComboWidth(oComboBox As ComboBox, _
lWidth As Long)

' lWidth is in pixels

SendMessage oComboBox.hwnd, CB_SETDROPPEDWIDTH, lWidth, 0

End Sub

Notes

Use this sub where you like: it does not have to be in the combo's dropdown event.  Also, this code will not work if you specify a width that is less than the width of the combo box control.  i.e. you can only make the drop down list part of the control wider that the control itself.

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/