shark
April 17th, 2001, 12:30 PM
How to dropdown a datacombo(not a common combobox) programmatically in Visual Basic?
|
Click to See Complete Forum and Search --> : How to dropdown a datacombo programmatically? shark April 17th, 2001, 12:30 PM How to dropdown a datacombo(not a common combobox) programmatically in Visual Basic? Iouri April 17th, 2001, 01:25 PM ' 'Comments 'This code allows you To: 'Drop it down through code: DropDown(cbo As ComboBox, blnShow As Boolean) 'Set the drop down height: SetDropHeight(cbo As ComboBox, lngHeight As Long) 'Set the drop down Width: SetDropWidth(cbo As ComboBox, lngWidth As Long) ' ' 'Code Option Explicit '// Windows API calls 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 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 Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long '// Windows message Private Const WM_USER = &H400 '// Combo and edit box messages Private Const CB_SHOWDROPDOWN = WM_USER + 15 Private Const CB_SETDROPPEDWIDTH = &H160 Private Const EC_LEFTMARGIN = &H1 Private Const EC_RIGHTMARGIN = &H2 Private Const EC_USEFONTINFO = &HFFFF& Private Const EM_SETMARGINS = &HD3& Private Const EM_GETMARGINS = &HD4& Public Sub SetDropWidth(cbo As ComboBox, lngWidth As Long) SendMessageLong cbo.hwnd, CB_SETDROPPEDWIDTH, lngWidth, 0 End Sub Public Sub SetDropHeight(cbo As ComboBox, lngHeight As Long) Dim intScaleMode As Integer '// Store the current scalemode intScaleMode = cbo.Parent.ScaleMode '// Set it to pixels cbo.Parent.ScaleMode = vbPixels '// Move the check box MoveWindow cbo.hwnd, cbo.Left, cbo.Top, cbo.Width, lngHeight, 1 '// Reset the scalemode cbo.Parent.ScaleMode = intScaleMode End Sub Public Sub DropDown(cbo As ComboBox, blnShow As Boolean) If blnShow Then SendMessageLong cbo.hwnd, CB_SHOWDROPDOWN, 1, ByVal 0& Else SendMessageLong cbo.hwnd, CB_SHOWDROPDOWN, 0, ByVal 0& End If End Sub Iouri Boutchkine iouri@hotsheet.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |