home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.UserControl ComboEx
- Appearance = 0 'Flat
- BackColor = &H80000005&
- CanGetFocus = 0 'False
- ClientHeight = 372
- ClientLeft = 0
- ClientTop = 0
- ClientWidth = 2988
- EditAtDesignTime= -1 'True
- ScaleHeight = 31
- ScaleMode = 3 'Pixel
- ScaleWidth = 249
- ToolboxBitmap = "ComboEx.ctx":0000
- Attribute VB_Name = "ComboEx"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = True
- Option Explicit
- Private cmb As ComboBoxEx
- Private mobjImageList As Object
- Private WithEvents mclsCombo As sgwindow.Window
- Attribute mclsCombo.VB_VarHelpID = -1
- Private WithEvents mclsComboEdit As sgwindow.Window
- Attribute mclsComboEdit.VB_VarHelpID = -1
- Private mlListIndex As Integer
- Private Const WM_KEYDOWN = &H100
- Private Const CBN_SELCHANGE = 1
- Private Const CBN_EDITCHANGE = 5
- Private Const CBN_EDITUPDATE = 6
- Private Const CBN_SELENDOK = 9
- 'Default Property Values:
- Const m_def_Text = ""
- Const m_def_Count = 0
- Const m_def_Style = 1
- Const m_def_BackColor = 0
- Const m_def_Enabled = 0
- Const m_def_FontBold = 0
- Const m_def_FontItalic = 0
- Const m_def_FontName = ""
- Const m_def_FontSize = 0
- Const m_def_ForeColor = 0
- Const m_def_MousePointer = 0
- Const m_def_OLEDropMode = 0
- 'Property Variables:
- Dim m_Style As Integer
- Dim m_BackColor As Long
- Dim m_Enabled As Boolean
- Dim m_Font As Font
- Dim m_FontBold As Boolean
- Dim m_FontItalic As Boolean
- Dim m_FontName As String
- Dim m_FontSize As Single
- Dim m_ForeColor As Long
- Dim m_MouseIcon As Picture
- Dim m_MousePointer As Integer
- Dim m_OLEDropMode As Integer
- 'events
- Public Event Change()
- Public Event Click()
- Public Event DblClick()
- Public Event KeyDown(KeyCode As Integer, Shift As Integer)
- Public Event KeyPress(KeyAscii As Integer)
- Public Event KeyUp(KeyCode As Integer, Shift As Integer)
- Public Event OLEDragOver(Data As DataObject, Effect As Integer, Button As Integer, Shift As Integer, X As Integer, Y As Integer, State As Integer)
- Public Event OLEDragDrop(Data As DataObject, Effect As Integer, Button As Integer, Shift As Integer, X As Integer, Y As Integer)
- Public Event OLEGiveFeedback(Effect As Integer, DefaultCursors As Integer)
- Public Event OLEStartDrag(Data As DataObject, AllowedEffects As Integer)
- Public Event OLESetData(Data As DataObject, DataFormat As Integer)
- Public Event OLECompleteDrag(Effect As Integer)
- Public Event Scroll()
- Private Declare Function CMB_SetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
- Public Function AddItem(Text As String, Icon As Integer, _
- Optional Indent As Integer = 0, _
- Optional Index As Integer = -1) As ComboItem
- cmb.Additems Text, Icon, Indent, Index
- Set AddItem = cmb.ComboItems(cmb.ComboItems.Count)
- End Function
- Public Sub SetFocus()
- If cmb.GetComboHwnd <> 0 Then CMB_SetFocus cmb.GetComboHwnd
- End Sub
- Private Sub mclsCombo_Message(ByVal msg As Long, _
- ByVal wParam As Long, ByVal lParam As Long, _
- ByRef result As Long)
- On Error Resume Next
- Select Case msg
- Case wm_COMMAND
- Select Case sgwindow.HighWord(wParam)
- Case CBN_SELCHANGE
- Select Case lParam
- Case cmb.GetComboHwnd
- mlListIndex = cmb.GetSelectedItem
- RaiseEvent Click
- End Select
- Case CBN_EDITCHANGE
- RaiseEvent Change
- Case CBN_SELENDOK
- mlListIndex = cmb.GetSelectedItem
- Case Else
- result = mclsCombo.CallWindowProc(msg, wParam, lParam)
- End Select
-
- Case Else
- result = mclsCombo.CallWindowProc(msg, wParam, lParam)
- End Select
- End Sub
- Private Sub mclsComboEdit_Message(ByVal msg As Long, ByVal wParam As Long, _
- ByVal lParam As Long, ByRef result As Long)
- On Error Resume Next
- Select Case msg
- Case wm_LBUTTONDBLCLK
- RaiseEvent DblClick
- Case WM_KEYDOWN
- RaiseEvent KeyDown(CInt(wParam), 0)
- Case wm_KEYUP
- RaiseEvent KeyUp(CInt(wParam), 0)
- Case Else
- result = mclsCombo.CallWindowProc(msg, wParam, lParam)
- End Select
- End Sub
- Private Sub UserControl_EnterFocus()
- If cmb.GetComboHwnd <> 0 Then CMB_SetFocus cmb.GetComboHwnd
- End Sub
- Private Sub UserControl_Initialize()
- Dim clsControl As New sgwindow.Window
- Dim lWinLong&
- Set cmb = New ComboBoxEx
- Set mclsCombo = New sgwindow.Window
- mclsCombo.hwnd = UserControl.hwnd
- mclsCombo.EnableMessage wm_COMMAND
- mclsCombo.Hooked = True
- If m_Style = 34 Then
- Set mclsComboEdit = New Window
- mclsComboEdit.hwnd = cmb.GetEdithWnd
- mclsComboEdit.EnableMessage wm_LBUTTONDBLCLK
- mclsComboEdit.EnableMessage WM_KEYDOWN
- mclsComboEdit.Hooked = True
- End If
- End Sub
- Private Sub UserControl_Resize()
- On Error Resume Next
- UserControl.Height = cmb.ResizeCombo(UserControl.Width)
- End Sub
- Private Sub UserControl_Terminate()
- Set cmb = Nothing
- Set mclsCombo = Nothing
- End Sub
- Public Property Get List(Index As Integer) As String
- List = cmb.ComboItems.Item(Index + 1).Text
- End Property
- Public Property Let List(Index As Integer, ByVal vNewValue As String)
- cmb.ComboItems.Item(Index + 1).Text = vNewValue
- cmb.RefreshItem Index, vNewValue, _
- cmb.ComboItems(Index + 1).Image, _
- cmb.ComboItems(Index + 1).Indent
- End Property
- Public Property Get Text() As String
- Text = cmb.GetEditString
- End Property
- Public Property Let ImageList(ByVal vNewValue As Object)
- Set mobjImageList = vNewValue
- cmb.ImageList = mobjImageList.HIMAGELIST
- End Property
- Public Property Get BackColor() As Long
- Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
- BackColor = m_BackColor
- End Property
- Public Property Let BackColor(ByVal New_BackColor As Long)
- m_BackColor = New_BackColor
- PropertyChanged "BackColor"
- End Property
- 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 = m_Enabled
- End Property
- Public Property Let Enabled(ByVal New_Enabled As Boolean)
- m_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 = m_Font
- End Property
- Public Property Set Font(ByVal New_Font As Font)
- Set m_Font = New_Font
- PropertyChanged "Font"
- End Property
- Public Property Get FontBold() As Boolean
- Attribute FontBold.VB_Description = "Returns/sets bold font styles."
- FontBold = m_FontBold
- End Property
- Public Property Let FontBold(ByVal New_FontBold As Boolean)
- m_FontBold = New_FontBold
- PropertyChanged "FontBold"
- End Property
- Public Property Get FontItalic() As Boolean
- Attribute FontItalic.VB_Description = "Returns/sets italic font styles."
- FontItalic = m_FontItalic
- End Property
- Public Property Let FontItalic(ByVal New_FontItalic As Boolean)
- m_FontItalic = New_FontItalic
- PropertyChanged "FontItalic"
- End Property
- Public Property Get FontName() As String
- Attribute FontName.VB_Description = "Specifies the name of the font that appears in each row for the given level."
- FontName = m_FontName
- End Property
- Public Property Let FontName(ByVal New_FontName As String)
- m_FontName = New_FontName
- PropertyChanged "FontName"
- End Property
- Public Property Get FontSize() As Single
- Attribute FontSize.VB_Description = "Specifies the size (in points) of the font that appears in each row for the given level."
- FontSize = m_FontSize
- End Property
- Public Property Let FontSize(ByVal New_FontSize As Single)
- m_FontSize = New_FontSize
- PropertyChanged "FontSize"
- End Property
- Public Property Get ForeColor() As Long
- Attribute ForeColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
- ForeColor = m_ForeColor
- End Property
- Public Property Let ForeColor(ByVal New_ForeColor As Long)
- m_ForeColor = New_ForeColor
- PropertyChanged "ForeColor"
- End Property
- Public Property Get MouseIcon() As Picture
- Attribute MouseIcon.VB_Description = "Sets a custom mouse icon."
- Set MouseIcon = m_MouseIcon
- End Property
- Public Property Set MouseIcon(ByVal New_MouseIcon As Picture)
- Set m_MouseIcon = New_MouseIcon
- PropertyChanged "MouseIcon"
- End Property
- 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 = m_MousePointer
- End Property
- Public Property Let MousePointer(ByVal New_MousePointer As Integer)
- m_MousePointer = New_MousePointer
- PropertyChanged "MousePointer"
- End Property
- Public Sub OLEDrag()
- Attribute OLEDrag.VB_Description = "Starts an OLE drag/drop event with the given control as the source."
- End Sub
- 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 ImageList() As Object
- Set ImageList = mobjImageList
- End Property
- Public Function Clear() As Variant
- cmb.Clear
- End Function
- Public Sub Remove(Index As Integer)
- cmb.RemoveItem Index
- End Sub
- 'Initialize Properties for User Control
- Private Sub UserControl_InitProperties()
- m_BackColor = m_def_BackColor
- m_Enabled = m_def_Enabled
- Set m_Font = Ambient.Font
- m_FontBold = m_def_FontBold
- m_FontItalic = m_def_FontItalic
- m_FontName = m_def_FontName
- m_FontSize = m_def_FontSize
- m_ForeColor = m_def_ForeColor
- Set m_MouseIcon = LoadPicture("")
- m_MousePointer = m_def_MousePointer
- m_OLEDropMode = m_def_OLEDropMode
- m_Style = m_def_Style
- End Sub
- 'Load property values from storage
- Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
- m_BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor)
- m_Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)
- Set m_Font = PropBag.ReadProperty("Font", Ambient.Font)
- m_FontBold = PropBag.ReadProperty("FontBold", m_def_FontBold)
- m_FontItalic = PropBag.ReadProperty("FontItalic", m_def_FontItalic)
- m_FontName = PropBag.ReadProperty("FontName", m_def_FontName)
- m_FontSize = PropBag.ReadProperty("FontSize", m_def_FontSize)
- m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
- Set m_MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
- m_MousePointer = PropBag.ReadProperty("MousePointer", m_def_MousePointer)
- m_OLEDropMode = PropBag.ReadProperty("OLEDropMode", m_def_OLEDropMode)
- m_Style = PropBag.ReadProperty("Style", m_def_Style)
- With cmb
- .ParentHwnd = UserControl.hwnd
- .Create m_Style
- End With
- UserControl_Resize
- End Sub
- 'Write property values to storage
- Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
- Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor)
- Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled)
- Call PropBag.WriteProperty("Font", m_Font, Ambient.Font)
- Call PropBag.WriteProperty("FontBold", m_FontBold, m_def_FontBold)
- Call PropBag.WriteProperty("FontItalic", m_FontItalic, m_def_FontItalic)
- Call PropBag.WriteProperty("FontName", m_FontName, m_def_FontName)
- Call PropBag.WriteProperty("FontSize", m_FontSize, m_def_FontSize)
- Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
- Call PropBag.WriteProperty("MouseIcon", m_MouseIcon, Nothing)
- Call PropBag.WriteProperty("MousePointer", m_MousePointer, m_def_MousePointer)
- Call PropBag.WriteProperty("OLEDropMode", m_OLEDropMode, m_def_OLEDropMode)
- Call PropBag.WriteProperty("Style", m_Style, m_def_Style)
- End Sub
- Public Property Get hwnd() As Long
- Attribute hwnd.VB_Description = "Returns a handle (from Microsoft Windows) to an object's window."
- Attribute hwnd.VB_MemberFlags = "400"
- hwnd = cmb.GetComboHwnd
- End Property
- Public Property Get ItemData(Index As Integer) As Long
- Attribute ItemData.VB_MemberFlags = "400"
- ItemData = cmb.ComboItems(Index + 1).ItemData
- End Property
- Public Property Let ItemData(Index As Integer, ByVal New_ItemData As Long)
- cmb.ComboItems(Index + 1).ItemData = New_ItemData
- End Property
- Public Property Get NewIndex() As Integer
- Attribute NewIndex.VB_MemberFlags = "400"
- NewIndex = cmb.NewIndex
- End Property
- Public Property Get ListIndex() As Integer
- Attribute ListIndex.VB_MemberFlags = "400"
- ListIndex = mlListIndex
- End Property
- Public Property Let ListIndex(ByVal New_ListIndex As Integer)
- mlListIndex = New_ListIndex
- cmb.SetIndex mlListIndex
- RaiseEvent Click
- End Property
- Public Property Get ComboItem(Index As Integer) As ComboItem
- Attribute ComboItem.VB_MemberFlags = "400"
- Set ComboItem = cmb.ComboItems.Item(Index + 1)
- End Property
- Public Property Set ComboItem(Index As Integer, ByVal New_Item As ComboItem)
- Set cmb.ComboItems.Item(Index + 1) = New_Item
- End Property
- Public Property Get ListCount() As Integer
- Attribute ListCount.VB_MemberFlags = "400"
- ListCount = cmb.ComboItems.Count
- End Property
- Public Property Get Style() As Integer
- Style = m_Style
- End Property
- Public Property Let Style(ByVal New_Style As Integer)
- If Ambient.UserMode Then Err.Raise 393
- If New_Style < 0 Or New_Style > 3 Then Exit Property
- If m_Style <> New_Style Then
- m_Style = New_Style
-
- 'On Error Resume Next
-
- PropertyChanged "Style"
- cmb.Destroy
-
- cmb.Create m_Style
- UserControl_Resize
- End If
- End Property
-