Setting Combox box dropdown 
Author Message
 Setting Combox box dropdown

Does anyone know what constant to use with sendmessage to set a combo
box's
dropdown list to be 10 instead of the normal 8.

Thanks,
Chris



Sat, 21 Oct 2000 03:00:00 GMT  
 Setting Combox box dropdown

Private Sub Command2_Click()

   Dim pt As POINTAPI
   Dim rc As RECT
   Dim iWidth As Integer
   Dim iHeight As Integer
   Dim oldScaleMode As Integer
   Dim numItemsToDisplay As Integer
   Dim itemHeight As Integer

   numItemsToDisplay = 10

   itemHeight = SendMessageLong(Combo1.hWnd, CB_GETITEMHEIGHT, 0, 0) + 1

  'Change the Scale Mode on the form to Pixels
   oldScaleMode = Form1.ScaleMode
   Form1.ScaleMode = 3
   iWidth = Combo1.Width

  'Set the new height of the combo box
   iHeight = itemHeight * (numItemsToDisplay + 1)
   Form1.ScaleMode = oldScaleMode

  'Get the coordinates relative to the screen
   Call GetWindowRect(Combo1.hWnd, rc)
   pt.x = rc.Left
   pt.y = rc.Top

  'then the coordinates relative to the form.
   Call ScreenToClient(Form1.hWnd, pt)

  'Resize the combo box
   Call MoveWindow(Combo1.hWnd, pt.x, pt.y, Combo1.Width, iHeight, True)

   Form1.ScaleMode = oldScaleMode

End Sub

The API declarations, types and constants are in the API viewer.

--

Randy Birch, MVP Visual Basic
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm

Common Controls Replacement Project Member
http://www.mvps.org/ccrp

:Does anyone know what constant to use with sendmessage to set a combo
:box's
:dropdown list to be 10 instead of the normal 8.
:
:Thanks,
:Chris
:



Sun, 22 Oct 2000 03:00:00 GMT  
 Setting Combox box dropdown

Hi Mr. Randy Birch ,
I have tryied this code and it works fine when increasing the size of the
combo box.
But it does not allow decreasing the size... :(

Is it possible ?

Guy Cohen



Mon, 23 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. how to set read only a dropdown combo box

2. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

3. Set number of items in combo box dropdown

4. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

5. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

6. change contents of boxes after change in combox

7. Combox box Sorting

8. Binding combox box with DBGrid + DB subtotals

9. Combox Box Blues

10. How to put data into the combox box

11. Combox box with the look of Office toolbar

12. Default Combox Box to Upper case?

 

 
Powered by phpBB® Forum Software