Here's the (a) explanation ...
http://vbnet.mvps.org/code/comboapi/comboheight.htm
--
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"Kiteman - Canada" <-d*************@shaw.ca> wrote in message
news:tu9pc.477359$oR5.284826@pd7tw3no...
: Thanks very much J French for the "allegedly" Rick Rothstein snippet. It
: worked like a charm.
: Took me a while to figure out what parts were mandatory and what names I
had
: to change to get it to work with my ComboBox name, but it works like a
: charm.
:
: Pardon another question....by using this bit of code, does it require any
: supporting files (such as DLLs) to be installed on the users system when
: they run my .exe?
:
: Tom
:
: "J French" <er*****@nowhere.com> wrote in message
: news:40***************@news.btclick.com...
: > On Fri, 14 May 2004 07:35:44 GMT, "Kiteman - Canada"
: > <-d*************@shaw.ca> wrote:
: >
: > >I have a ComboBox (style 2) with 25 items in it. When I click on the
: arrow
: > >to see the items, I can only see the first 8. I have to scroll to see
: the
: > >others. Is there some way so set how many items will be visible when
: the
: > >menu drops down to eliminate/reduce the scrolling?
: > >
: >
: > This is Rick Rothstein's example
: >
: > It is extremely comprehensive.
: >
: > ' 29/6/03 Rick Rothstein
: >
: > ' Sets height of Simple Combo
: >
: > Option Explicit: DefObj A-Z
: >
: >
: > Private Declare Function SendMessageLong Lib "user32" _
: > Alias "SendMessageA" ( _
: > ByVal hWnd As Long, _
: > ByVal wMsg As Long, _
: > ByVal wParam As Long, _
: > ByVal lParam As Long) As Long
: >
: > Private Declare Function GetWindowRect Lib "user32" ( _
: > ByVal hWnd As Long, _
: > lpRect As RECT) As Long
: >
: > Private Declare Function ScreenToClient Lib "user32" ( _
: > ByVal hWnd As Long, _
: > lpPoint As POINTAPI) As Long
: >
: > Private Declare Function MoveWindow Lib "user32" ( _
: > ByVal hWnd As Long, _
: > ByVal X As Long, _
: > ByVal Y As Long, _
: > ByVal nWidth As Long, _
: > ByVal nHeight As Long, _
: > ByVal bRepaint As Long) As Long
: >
: > Private Const CB_GETITEMHEIGHT = &H154
: >
: > Private Type RECT
: > Left As Long
: > Top As Long
: > Right As Long
: > Bottom As Long
: > End Type
: >
: > Private Type POINTAPI
: > X As Long
: > Y As Long
: > End Type
: >
: > Private Sub Form_Load()
: > Dim L9%
: >
: > For L9 = 1 To 100
: > Combo1.AddItem "Item" + Str(L9)
: > Next
: >
: > End Sub
: >
: >
: > Private Sub Command1_Click()
: > Call SetComboBoxHeight(Combo1, Val(Text1.Text))
: > End Sub
: >
: >
: > Public Sub SetComboBoxHeight( _
: > ComboBoxIn As ComboBox, _
: > NumberOfItemsTall As Long)
: > Dim Point As POINTAPI
: > Dim Rectangle As RECT
: > Dim ComboBoxWidth As Long
: > Dim NewComboBoxHeight As Long
: > Dim EditAreaHeight As Long
: > Dim ListAreaHeight As Long
: >
: > ComboBoxWidth = ComboBoxIn.Width \ Screen.TwipsPerPixelX
: > ListAreaHeight = SendMessageLong( _
: > ComboBoxIn.hWnd, _
: > CB_GETITEMHEIGHT, 0, 0)
: > EditAreaHeight = SendMessageLong( _
: > ComboBoxIn.hWnd, _
: > CB_GETITEMHEIGHT, -1, 0)
: > NewComboBoxHeight = _
: > ListAreaHeight * NumberOfItemsTall + _
: > 2 * EditAreaHeight
: > GetWindowRect ComboBoxIn.hWnd, Rectangle
: > Point.X = Rectangle.Left
: > Point.Y = Rectangle.Top
: > ScreenToClient ComboBoxIn.Container.hWnd, Point
: > MoveWindow ComboBoxIn.hWnd, _
: > Point.X, Point.Y, _
: > ComboBoxWidth, NewComboBoxHeight, True
: > End Sub
: >
: >
:
: