iA piece of internet history. AllAPI.net was made by two Belgian brothers, still in their teens, from 1998 to 2002, and at its peak 180,000 programmers a month came here. We keep it online exactly as it was. Nothing here is maintained anymore.
AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 


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
This site is located at http://allapi.mentalis.org/