Comboboxes
This page covers Combobox tips & tricks.
Contents |
How to set the dropdown list width
For default, the width of the dropdown list is the same as the combobox width.
You can change the width programatically.
To do this you will have to send a message to the Combobox and supply a new width in pixels.
Also the current width in pixels can be determined.
First you have to declare these constants
Number: CB_GETDROPPEDWIDTH = 0x015F Number: CB_SETDROPPEDWIDTH = 0x0160
(More information on CB_GETDROPPEDWIDTH and CB_SETDROPPEDWIDTH)
The next piece of code sets the width of combobox cmbSample to 100 pixels
Call SalSendMsg( cmbSample, CB_SETDROPPEDWIDTH, 100, 0 )
The next piece of code gets the current width of combobox cmbSample in pixels
Set nWidth = SalSendMsg( cmbSample, CB_GETDROPPEDWIDTH, 0, 0 )
The next piece of code doubles the width of combobox cmbSample
Call SalSendMsg( cmbSample, CB_SETDROPPEDWIDTH, SalSendMsg( cmbSample, CB_GETDROPPEDWIDTH, 0, 0 )*2, 0 )
How to programatically open the dropdown list
Open (or close) the dropdown list of a combobox using
Call VisListSetDropDownState( hWndList, bState ) ! bState = TRUE to open ! bState = FALSE to close
How to get the handles of the edit and list parts of a combobox
TODO -> CB_GETCOMBOBOXINFO.
How to set the vertical size of the dropdown list programatically
TODO -> CB_SETMINVISIBLE.
How to set the height of the edit portion and list entries programatically
The height of the edit control portion and the dropdown list entries can be changed.
To do this you will have to send a message to the Combobox and supply a new height in pixels.
Also the current height in pixels can be determined.
First you have to declare these constants
Number: CB_SETITEMHEIGHT = 0x0153 Number: CB_GETITEMHEIGHT = 0x0154
( More information on CB_SETITEMHEIGHT and CB_GETITEMHEIGHT )
To set the height of the edit control portion of combobox cmbSample to 30 pixels
Call SalSendMsg( cmbSample, CB_SETITEMHEIGHT , -1, 30 )
To set the height of the dropdown list entries of combobox cmbSample to 30 pixels
Call SalSendMsg( cmbSample, CB_SETITEMHEIGHT , 0, 30 )
To get the current height of the edit control portion and items of combobox cmbSample in pixels
Set nEditHeight = SalSendMsg( cmbSample, CB_GETITEMHEIGHT , -1, 0) Set nItemHeight = SalSendMsg( cmbSample, CB_GETITEMHEIGHT , 0, 0)