December 16, 2000

Determine when a ComboBox’s area is being closed

The ComboBox control exposes the DropDown event, that lets you determine when its list area is being opened. However, VB doesn’t offer any simple way to understand when the list area is being closed. You can achieve this by intercepting the WM_COMMAND message that the ComboBox control sends to its

ListBoxEnsureVisible – Ensure that a ListBox element is visible

‘ ensure that a listbox item is visible’ if the second argument is omitted, the index of current item is used” NOTE: uses the ListBoxVisibleItems functionSub ListBoxEnsureVisible(lst As ListBox, Optional ByVal itemIndex As Long = -1) Dim visibleCount As Long ‘ provide a default for the 2nd argument If itemIndex

Ensure that a form’s TextBox and ComboBox controls have same height

In general you don’t have any control on a ComboBox’s Height property, because it is determined automatically by VB depending on the font used for the ComboBox control. If you have a form that contains both TextBox and ComboBox controls, you should ensure that all your single-line TextBox controls are

ComboBoxSetHeight – Set a new height for the list portion of a ComboBox control

Private Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate Declare Function GetWindowRect Lib “user32” (ByVal hWnd As Long, _ lpRect As RECT) As LongPrivate Declare Function ScreenToClientAny Lib “user32” Alias “ScreenToClient” _ (ByVal hWnd As Long, lpPoint As Any) As LongPrivate Declare Function