VERSION 5.00
Begin VB.UserControl UserControl1 
   ClientHeight    =   345
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   3150
   ScaleHeight     =   345
   ScaleWidth      =   3150
   Begin VB.ComboBox Combo1 
      Height          =   315
      Left            =   0
      Sorted          =   -1  'True
      TabIndex        =   0
      Top             =   0
      Width           =   3135
   End
End
Attribute VB_Name = "UserControl1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long

Private Const CB_FINDSTRING = &H14C
Private Const CB_SHOWDROPDOWN = &H14F
Private Const CB_FINDSTRINGEXACT = &H158

'Default Property Values:
Const m_def_Appearance = 0
Const m_def_BorderStyle = 0
Const m_def_BackStyle = 0
Const m_def_FillColor = 0
Const m_def_FillStyle = 0
Const m_def_FontTransparent = 0
Const m_def_OLEDropMode = 0
Const m_def_OLEDragMode = 0
Const m_def_Search = True
Const m_def_Dropped = 0
'Property Variables:
Dim m_ActiveControl As Control
Dim m_Appearance As Integer
Dim m_BorderStyle As Integer
Dim m_BackStyle As Integer
Dim m_FillColor As Long
Dim m_FillStyle As Integer
Dim m_FontTransparent As Boolean
Dim m_OLEDropMode As Integer
Dim m_OLEDragMode As Integer
Dim m_Search As Boolean
Dim m_Dropped As Boolean
'Event Declarations:
Event Change() 'MappingInfo=Combo1,Combo1,-1,Change
Attribute Change.VB_Description = "Occurs when the contents of a control have changed."
Event Click() 'MappingInfo=UserControl,UserControl,-1,Click
Attribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."
Event DblClick() 'MappingInfo=UserControl,UserControl,-1,DblClick
Attribute DblClick.VB_Description = "Occurs when the user presses and releases a mouse button and then presses and releases it again over an object."
Event DropDown() 'MappingInfo=Combo1,Combo1,-1,DropDown
Attribute DropDown.VB_Description = "Occurs when the list portion of a ComboBox control is about to drop down."
Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyDown
Attribute KeyDown.VB_Description = "Occurs when the user presses a key while an object has the focus."
Event KeyPress(KeyAscii As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyPress
Attribute KeyPress.VB_Description = "Occurs when the user presses and releases an ANSI key."
Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyUp
Attribute KeyUp.VB_Description = "Occurs when the user releases a key while an object has the focus."
Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseDown
Attribute MouseDown.VB_Description = "Occurs when the user presses the mouse button while an object has the focus."
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseMove
Attribute MouseMove.VB_Description = "Occurs when the user moves the mouse."
Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseUp
Attribute MouseUp.VB_Description = "Occurs when the user releases the mouse button while an object has the focus."
Event OLEStartDrag(Data As DataObject, AllowedEffects As Long)
Attribute OLEStartDrag.VB_Description = "Occurs when an OLE drag/drop operation is initiated either manually or automatically."
Event OLESetData(Data As DataObject, DataFormat As Integer)
Attribute OLESetData.VB_Description = "Occurs at the OLE drag/drop source control when the drop target requests data that was not provided to the DataObject during the OLEDragStart event."
Event OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
Attribute OLEGiveFeedback.VB_Description = "Occurs at the source control of an OLE drag/drop operation when the mouse cursor needs to be changed."
Event OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
Attribute OLEDragOver.VB_Description = "Occurs when the mouse is moved over the control during an OLE drag/drop operation, if its OLEDropMode property is set to manual."
Event OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Attribute OLEDragDrop.VB_Description = "Occurs when data is dropped onto the control via an OLE drag/drop operation, and OLEDropMode is set to manual."
Event OLECompleteDrag(Effect As Long)
Attribute OLECompleteDrag.VB_Description = "Occurs at the OLE drag/drop source control after a manual or automatic drag/drop has been completed or canceled."
Event Resize() 'MappingInfo=UserControl,UserControl,-1,Resize
Attribute Resize.VB_Description = "Occurs when a form is first displayed or the size of an object changes."
Event Scroll() 'MappingInfo=Combo1,Combo1,-1,Scroll
Attribute Scroll.VB_Description = "Occurs when you reposition the scroll box on a control."
Event Validate(Cancel As Boolean) 'MappingInfo=Combo1,Combo1,-1,Validate
Attribute Validate.VB_Description = "Occurs when a control loses focus to a control that causes validation."

Private Sub Combo1_Change()
    RaiseEvent Change

    If m_Search = True Then
        Me.Dropped = SetDroppedStatus(True)
        
        Index = -1
        Do
            Index = FindString(Combo1, Combo1.Text, 0, False)
            If Index = -1 Then Exit Do
            Print Combo1.List(Index)
        Loop
    End If
    
End Sub

Private Function FindString(ctrl As Control, ByVal Search As String, Optional startIndex As Long = -1, Optional ExactMatch As Boolean) As Long
    
        Dim uMsg As Long
        
        If TypeOf ctrl Is ListBox Then
            uMsg = IIf(ExactMatch, LB_FINDSTRINGEXACT, LB_FINDSTRING)
        ElseIf TypeOf ctrl Is ComboBox Then
            uMsg = IIf(ExactMatch, CB_FINDSTRINGEXACT, CB_FINDSTRING)
        End If
        FindString = SendMessageStr(ctrl.hWnd, uMsg, startIndex, Search)
        
End Function

Private Sub Combo1_Click()

    RaiseEvent Click

End Sub

Private Sub UserControl_Resize()
    
    RaiseEvent Resize

    Combo1.Width = UserControl.Width
    UserControl.Height = Combo1.Height

End Sub

Public Property Get ActiveControl() As Object
Attribute ActiveControl.VB_Description = "Returns the control that has focus."
    
    Set ActiveControl = m_ActiveControl

End Property

Public Property Get Appearance() As Integer
Attribute Appearance.VB_Description = "Returns/sets whether or not an object is painted at run time with 3-D effects."
    
    Appearance = m_Appearance

End Property

Public Property Let Appearance(ByVal New_Appearance As Integer)
    
    m_Appearance = New_Appearance
    PropertyChanged "Appearance"

End Property

Public Sub AddItem(ByVal Item As String, Optional ByVal Index As Variant)
Attribute AddItem.VB_Description = "Adds an item to a Listbox or ComboBox control or a row to a Grid control."
    
    Combo1.AddItem Item, Index

End Sub

Public Property Get BackColor() As OLE_COLOR
Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
    
    BackColor = Combo1.BackColor

End Property

Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
    
    Combo1.BackColor() = New_BackColor
    PropertyChanged "BackColor"

End Property

Public Sub Clear()
Attribute Clear.VB_Description = "Clears the contents of a control or the system Clipboard."
    
    Combo1.Clear

End Sub

Private Sub UserControl_Click()
    
    RaiseEvent Click

End Sub

Private Sub UserControl_DblClick()
    
    RaiseEvent DblClick

End Sub

Private Sub Combo1_DropDown()
    
    RaiseEvent DropDown

End Sub

Public Property Get Enabled() As Boolean
Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
    
    Enabled = Combo1.Enabled

End Property

Public Property Let Enabled(ByVal New_Enabled As Boolean)
    
    Combo1.Enabled() = New_Enabled
    PropertyChanged "Enabled"

End Property

Public Property Get Font() As Font
Attribute Font.VB_Description = "Returns a Font object."
Attribute Font.VB_UserMemId = -512
    
    Set Font = Combo1.Font

End Property

Public Property Set Font(ByVal New_Font As Font)
    
    Set Combo1.Font = New_Font
    PropertyChanged "Font"

End Property

Public Property Get ForeColor() As OLE_COLOR
Attribute ForeColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
    
    ForeColor = Combo1.ForeColor

End Property

Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
    
    Combo1.ForeColor() = New_ForeColor
    PropertyChanged "ForeColor"

End Property

Public Property Get hWnd() As Long
Attribute hWnd.VB_Description = "Returns a handle (from Microsoft Windows) to an object's window."
    hWnd = Combo1.hWnd
End Property


Public Property Get ItemData(ByVal Index As Integer) As Long
Attribute ItemData.VB_Description = "Returns/sets a specific number for each item in a ComboBox or ListBox control."
    ItemData = Combo1.ItemData(Index)
End Property

Public Property Let ItemData(ByVal Index As Integer, ByVal New_ItemData As Long)
    Combo1.ItemData(Index) = New_ItemData
    PropertyChanged "ItemData"
End Property

Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
    RaiseEvent KeyDown(KeyCode, Shift)
End Sub

Private Sub UserControl_KeyPress(KeyAscii As Integer)
    RaiseEvent KeyPress(KeyAscii)
End Sub

Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
    RaiseEvent KeyUp(KeyCode, Shift)
End Sub

Public Property Get List(ByVal Index As Integer) As String
Attribute List.VB_Description = "Returns/sets the items contained in a control's list portion."
    List = Combo1.List(Index)
End Property

Public Property Let List(ByVal Index As Integer, ByVal New_List As String)
    Combo1.List(Index) = New_List
    PropertyChanged "List"
End Property

Public Property Get ListCount() As Integer
Attribute ListCount.VB_Description = "Returns the number of items in the list portion of a control."
    ListCount = Combo1.ListCount
End Property

Public Property Get ListIndex() As Integer
Attribute ListIndex.VB_Description = "Returns/sets the index of the currently selected item in the control."
    ListIndex = Combo1.ListIndex
End Property

Public Property Let ListIndex(ByVal New_ListIndex As Integer)
    Combo1.ListIndex() = New_ListIndex
    PropertyChanged "ListIndex"
End Property


Public Property Get Locked() As Boolean
Attribute Locked.VB_Description = "Determines whether a control can be edited."
    Locked = Combo1.Locked
End Property

Public Property Let Locked(ByVal New_Locked As Boolean)
    Combo1.Locked() = New_Locked
    PropertyChanged "Locked"
End Property

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub

Public Property Get MouseIcon() As Picture
Attribute MouseIcon.VB_Description = "Sets a custom mouse icon."
    Set MouseIcon = UserControl.MouseIcon
End Property

Public Property Set MouseIcon(ByVal New_MouseIcon As Picture)
    Set UserControl.MouseIcon = New_MouseIcon
    PropertyChanged "MouseIcon"
End Property

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub

Public Property Get MousePointer() As Integer
Attribute MousePointer.VB_Description = "Returns/sets the type of mouse pointer displayed when over part of an object."
    MousePointer = UserControl.MousePointer
End Property

Public Property Let MousePointer(ByVal New_MousePointer As Integer)
    UserControl.MousePointer() = New_MousePointer
    PropertyChanged "MousePointer"
End Property

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseUp(Button, Shift, X, Y)
End Sub

Public Property Get NewIndex() As Integer
Attribute NewIndex.VB_Description = "Returns the index of the item most recently added to a control."
    NewIndex = Combo1.NewIndex
End Property

Public Property Get OLEDropMode() As Integer
Attribute OLEDropMode.VB_Description = "Returns/Sets whether this object can act as an OLE drop target."
    OLEDropMode = m_OLEDropMode
End Property

Public Property Let OLEDropMode(ByVal New_OLEDropMode As Integer)
    m_OLEDropMode = New_OLEDropMode
    PropertyChanged "OLEDropMode"
End Property

Public Property Get OLEDragMode() As Integer
Attribute OLEDragMode.VB_Description = "Returns/Sets whether this object can act as an OLE drag/drop source, and whether this process is started automatically or under programmatic control."
    OLEDragMode = m_OLEDragMode
End Property

Public Property Let OLEDragMode(ByVal New_OLEDragMode As Integer)
    m_OLEDragMode = New_OLEDragMode
    PropertyChanged "OLEDragMode"
End Property

Public Sub OLEDrag()
Attribute OLEDrag.VB_Description = "Starts an OLE drag/drop event with the given control as the source."

    m_OLEDrag = New_OLEDrag
    PropertyChanged "OLEDrag"
End Sub

Public Sub Refresh()
Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
    UserControl.Refresh
End Sub

Public Sub RemoveItem(ByVal Index As Integer)
Attribute RemoveItem.VB_Description = "Removes an item from a ListBox or ComboBox control or a row from a Grid control."
    Combo1.RemoveItem Index
End Sub

Private Sub Combo1_Scroll()
    RaiseEvent Scroll
End Sub


Public Property Get SelLength() As Long
Attribute SelLength.VB_Description = "Returns/sets the number of characters selected."
    SelLength = Combo1.SelLength
End Property

Public Property Let SelLength(ByVal New_SelLength As Long)
    Combo1.SelLength() = New_SelLength
    PropertyChanged "SelLength"
End Property

Public Property Get SelStart() As Long
Attribute SelStart.VB_Description = "Returns/sets the starting point of text selected."
    SelStart = Combo1.SelStart
End Property

Public Property Let SelStart(ByVal New_SelStart As Long)
    Combo1.SelStart() = New_SelStart
    PropertyChanged "SelStart"
End Property

Public Property Get SelText() As String
Attribute SelText.VB_Description = "Returns/sets the string containing the currently selected text."
    SelText = Combo1.SelText
End Property

Public Property Let SelText(ByVal New_SelText As String)
    Combo1.SelText() = New_SelText
    PropertyChanged "SelText"
End Property

Public Property Get Sorted() As Boolean
Attribute Sorted.VB_Description = "Indicates whether the elements of a control are automatically sorted alphabetically."
    Sorted = Combo1.Sorted
End Property

Public Property Get Style() As Integer
Attribute Style.VB_Description = "Returns/sets a value that determines the type of control and the behavior of its list box portion."
    Style = Combo1.Style
End Property

Public Property Get Text() As String
Attribute Text.VB_Description = "Returns/sets the text contained in the control."
    Text = Combo1.Text
End Property

Public Property Let Text(ByVal New_Text As String)
    Combo1.Text() = New_Text
    PropertyChanged "Text"
End Property

Private Sub Combo1_Validate(Cancel As Boolean)
    RaiseEvent Validate(Cancel)
End Sub

Public Property Get Search() As Boolean
Attribute Search.VB_Description = "Returns/Sets whether the combobox is searchable"
    Search = m_Search
End Property

Public Property Let Search(ByVal New_Search As Boolean)

    m_Search = New_Search
    PropertyChanged "Search"
    
End Property

Public Property Get Dropped() As Boolean
Attribute Dropped.VB_Description = "Returns/Sets state of combobox"

    Dropped = m_Dropped
    
End Property

Public Property Let Dropped(ByVal New_Dropped As Boolean)

    If SetDroppedStatus(New_Dropped) Then m_Dropped = New_Dropped
    PropertyChanged "Dropped"
    
End Property
Private Function SetDroppedStatus(newval As Boolean)
    
    Dim done As Boolean
    
    done = SendMessageStr(Combo1.hWnd, CB_SHOWDROPDOWN, newval, vbNull)
    SetDroppedStatus = done
    
End Function
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
    m_Appearance = m_def_Appearance
    m_BorderStyle = m_def_BorderStyle
    m_BackStyle = m_def_BackStyle
    m_FillColor = m_def_FillColor
    m_FillStyle = m_def_FillStyle
    m_FontTransparent = m_def_FontTransparent
    m_OLEDropMode = m_def_OLEDropMode
    m_OLEDragMode = m_def_OLEDragMode
    m_Search = m_def_Search
    m_Dropped = m_def_Dropped
End Sub
