home *** CD-ROM | disk | FTP | other *** search
Visual Basic user-defined control file | 1998-08-01 | 13.4 KB | 419 lines |
- VERSION 5.00
- Begin VB.UserControl axPicker
- ClientHeight = 2130
- ClientLeft = 0
- ClientTop = 0
- ClientWidth = 6000
- ScaleHeight = 142
- ScaleMode = 3 'Pixel
- ScaleWidth = 400
- ToolboxBitmap = "axPicker.ctx":0000
- Begin VB.Frame fraButtons
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- BorderStyle = 0 'None
- ForeColor = &H80000008&
- Height = 1635
- Left = 2790
- TabIndex = 4
- Top = 360
- Width = 465
- Begin axPicklistControl.axDataButton axButton
- Height = 405
- Index = 1
- Left = 0
- Top = 405
- Width = 450
- _ExtentX = 794
- _ExtentY = 714
- Picture = "axPicker.ctx":0312
- End
- Begin axPicklistControl.axDataButton axButton
- Height = 405
- Index = 2
- Left = 0
- Top = 810
- Width = 450
- _ExtentX = 794
- _ExtentY = 714
- Picture = "axPicker.ctx":0664
- End
- Begin axPicklistControl.axDataButton axButton
- Height = 405
- Index = 3
- Left = 0
- Top = 1215
- Width = 450
- _ExtentX = 794
- _ExtentY = 714
- Picture = "axPicker.ctx":09B6
- End
- Begin axPicklistControl.axDataButton axButton
- Height = 405
- Index = 0
- Left = 0
- Top = 0
- Width = 450
- _ExtentX = 794
- _ExtentY = 714
- Picture = "axPicker.ctx":0D08
- End
- End
- Begin VB.ListBox lstAvailable
- DragIcon = "axPicker.ctx":105A
- Height = 1620
- Left = 135
- MultiSelect = 2 'Extended
- TabIndex = 1
- Top = 360
- Width = 2535
- End
- Begin VB.ListBox lstSelected
- DragIcon = "axPicker.ctx":1364
- Height = 1620
- Left = 3330
- MultiSelect = 2 'Extended
- TabIndex = 0
- Top = 360
- Width = 2535
- End
- Begin VB.Label lblSelected
- Caption = "Selected Items:"
- Height = 195
- Left = 3375
- TabIndex = 3
- Top = 135
- Width = 1095
- End
- Begin VB.Label lblAvailable
- Caption = "Available Items:"
- Height = 195
- Left = 180
- TabIndex = 2
- Top = 135
- Width = 1140
- End
- End
- Attribute VB_Name = "axPicker"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = True
- Const m_def_BorderStyle = 2
-
- Dim m_BorderStyle As Integer, iLast As Integer
-
- Public Enum AxBorderStyles
- [No Border] = 0
- [Single] = 1
- [Thin Raised] = 2
- [Thick Raised] = 3
- [Thin Inset] = 4
- [Thick Inset] = 5
- [Etched] = 6
- [Bump] = 7
- End Enum
-
- Private Sub axButton_Click(index As Integer)
- iLast = -1
- Select Case index
- Case 0
- For i = 0 To lstAvailable.ListCount - 1
- lstSelected.AddItem lstAvailable.List(i)
- Next
- lstAvailable.Clear
-
- Case 1
- If lstAvailable.ListIndex = -1 Then Exit Sub
- For i = lstAvailable.ListCount - 1 To 0 Step -1
- If lstAvailable.Selected(i) = True Then
- iLast = i
- lstSelected.AddItem lstAvailable.List(i)
- lstAvailable.RemoveItem i
- End If
- Next
-
- If lstAvailable.ListCount And iLast >= 0 Then
- If lstAvailable.ListCount - 1 < iLast Then
- lstAvailable.Selected(lstAvailable.ListCount - 1) = True
- Else
- lstAvailable.Selected(iLast) = True
- End If
- End If
-
- Case 2
- If lstSelected.ListIndex = -1 Then Exit Sub
- For i = lstSelected.ListCount - 1 To 0 Step -1
- If lstSelected.Selected(i) = True Then
- iLast = i
- lstAvailable.AddItem lstSelected.List(i)
- lstSelected.RemoveItem i
- End If
- Next
-
- If lstSelected.ListCount And iLast >= 0 Then
- If lstSelected.ListCount - 1 < iLast Then
- lstSelected.Selected(lstSelected.ListCount - 1) = True
- Else
- lstSelected.Selected(iLast) = True
- End If
- End If
-
- Case 3
- For i = 0 To lstSelected.ListCount - 1
- lstAvailable.AddItem lstSelected.List(i)
- Next
- lstSelected.Clear
-
- End Select
-
- End Sub
-
-
- Private Sub lstAvailable_DblClick()
- If lstAvailable.ListIndex = -1 Then Exit Sub
- iLast = lstAvailable.ListIndex
- lstSelected.AddItem lstAvailable.List(lstAvailable.ListIndex)
- lstAvailable.RemoveItem lstAvailable.ListIndex
-
- If lstAvailable.ListCount Then
- If lstAvailable.ListCount - 1 < iLast Then
- lstAvailable.Selected(lstAvailable.ListCount - 1) = True
- Else
- lstAvailable.Selected(iLast) = True
- End If
- End If
- End Sub
-
-
- Private Sub lstSelected_DblClick()
- If lstSelected.ListIndex = -1 Then Exit Sub
- iLast = lstSelected.ListIndex
- lstAvailable.AddItem lstSelected.List(lstSelected.ListIndex)
- lstSelected.RemoveItem lstSelected.ListIndex
-
- If lstSelected.ListCount Then
- If lstSelected.ListCount - 1 < iLast Then
- lstSelected.Selected(lstSelected.ListCount - 1) = True
- Else
- lstSelected.Selected(iLast) = True
- End If
- End If
- End Sub
-
- Private Sub UserControl_Initialize()
- UserControl.Height = 2130: UserControl.Width = 6135
- End Sub
-
- Private Sub UserControl_InitProperties()
- m_BorderStyle = m_def_BorderStyle
-
- End Sub
-
- Private Sub UserControl_Resize()
- 'If lstAvailable.Height + lstAvailable.Top + 10 > 142 Then UserControl.ScaleHeight = lstAvailable.Height + lstAvailable.Top + 10
-
- lstAvailable.Height = UserControl.ScaleHeight - lstAvailable.Top - 10
- lstAvailable.Width = IIf(UserControl.ScaleWidth > 0, Int((UserControl.ScaleWidth - 60) / 2), 0)
-
- lstSelected.Height = UserControl.ScaleHeight - lstAvailable.Top - 10
- lstSelected.Width = IIf(UserControl.ScaleWidth > 0, Int((UserControl.ScaleWidth - 60) / 2), 0)
- lstSelected.Left = lstAvailable.Left + lstAvailable.Width + 40
- lblSelected.Left = lstAvailable.Left + lstAvailable.Width + 42
-
- fraButtons.Left = lstAvailable.Left + lstAvailable.Width + 5
-
- 'UserControl.ScaleHeight = lstAvailable.Height + lstAvailable.Top + 10
- If UserControl.Height < 2130 Then
- UserControl.Height = 2130
- Else
- UserControl.Height = (lstAvailable.Height + lstAvailable.Top + 10) * Screen.TwipsPerPixelY
- End If
-
- ' UserControl.ScaleHeight = lstAvailable.Height + lstAvailable.Top + 10
-
- UserControl.Cls
- UserControl_Paint
-
-
- End Sub
-
- Public Sub AddItemA(item As String, Optional index As Integer)
- Attribute AddItemA.VB_Description = "Add item to available listbox"
- If IsMissing(index) Then
- lstAvailable.AddItem item
- Else
- lstAvailable.AddItem item, index
- End If
- End Sub
- Public Sub AddItemS(item As String, Optional index As Integer)
- Attribute AddItemS.VB_Description = "Add item to selected listbox"
- If IsMissing(index) Then
- lstSelected.AddItem item
- Else
- lstSelected.AddItem item, index
- End If
- End Sub
-
- Public Sub RemoveItemA(ByVal index As Integer)
- Attribute RemoveItemA.VB_Description = "Remove item from available listbox"
- lstAvailable.RemoveItem index
- End Sub
- Public Sub RemoveItemS(ByVal index As Integer)
- Attribute RemoveItemS.VB_Description = "Remove item from selected listbox"
- lstSelected.RemoveItem index
- End Sub
- Public Sub ClearA()
- Attribute ClearA.VB_Description = "Clear available listbox"
- lstAvailable.Clear
- End Sub
- Public Sub ClearS()
- Attribute ClearS.VB_Description = "Clear selected listbox"
- lstSelected.Clear
- End Sub
-
- Public Property Get ListIndexA() As Integer
- Attribute ListIndexA.VB_Description = "Currently selected item in available listbox"
- Attribute ListIndexA.VB_MemberFlags = "400"
- ListIndexA = lstAvailable.ListIndex
- End Property
- Public Property Get ListCountA() As Integer
- Attribute ListCountA.VB_Description = "Count of items in available listbox"
- Attribute ListCountA.VB_MemberFlags = "400"
- ListCountA = lstAvailable.ListCount
- End Property
- Public Property Get ListA(ByVal index As Integer) As String
- Attribute ListA.VB_Description = "String array of items in available listbox"
- Attribute ListA.VB_MemberFlags = "400"
- ListA = lstAvailable.List(index)
- End Property
-
- Public Property Get ListIndexS() As Integer
- Attribute ListIndexS.VB_Description = "Current selected item in selected listbox"
- Attribute ListIndexS.VB_MemberFlags = "400"
- ListIndexS = lstSelected.ListIndex
- End Property
- Public Property Get ListCountS() As Integer
- Attribute ListCountS.VB_Description = "Count of items in selected listbox"
- Attribute ListCountS.VB_MemberFlags = "400"
- ListCountS = lstSelected.ListCount
- End Property
- Public Property Get ListS(ByVal index As Integer) As String
- Attribute ListS.VB_Description = "String array of items in selected listbox"
- Attribute ListS.VB_MemberFlags = "400"
- ListS = lstSelected.List(index)
- End Property
-
- Public Sub ShowAbout()
- Attribute ShowAbout.VB_Description = "Show about box for control"
- Attribute ShowAbout.VB_UserMemId = -552
- frmAbout.Show vbModal
- End Sub
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Enabled
- 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 = UserControl.Enabled
- End Property
-
- Public Property Let Enabled(ByVal New_Enabled As Boolean)
- UserControl.Enabled() = New_Enabled
- PropertyChanged "Enabled"
- End Property
-
- 'Public Property Get MultiSelect() As Boolean
- ' MultiSelect = m_MultiSelect
- 'End Property
-
- 'Public Property Let MultiSelect(ByVal New_MultiSelect As Boolean)
- ' lstAvailable.MultiSelect = IIf(New_MultiSelect, 2, 0)
- ' lstSelected.MultiSelect = IIf(New_MultiSelect, 2, 0)
- ' m_MultiSelect = New_MultiSelect
- ' PropertyChanged "MultiSelect"
- 'End Property
-
- 'Load property values from storage
- Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
-
- UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
- m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
- m_MultiSelect = PropBag.ReadProperty("MultiSelect", False)
- End Sub
-
- 'Write property values to storage
- Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
-
- Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
- Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
- Call PropBag.WriteProperty("MultiSelect", m_MultiSelect, False)
- End Sub
-
- Public Property Get BorderStyle() As AxBorderStyles
- Attribute BorderStyle.VB_Description = "Set border style for control"
- BorderStyle = m_BorderStyle
- End Property
-
- Public Property Let BorderStyle(ByVal New_BorderStyle As AxBorderStyles)
- If Not (m_BorderStyle = New_BorderStyle) Then
- m_BorderStyle = New_BorderStyle
- UserControl.Cls
- UserControl_Paint
- End If
- PropertyChanged "BorderStyle"
- End Property
-
- Private Sub UserControl_Paint()
- Dim di As Long
- Dim rc As RECT
-
- 'draw outside border
-
- Select Case m_BorderStyle
- Case [No Border]
-
- Case [Single]
- di = GetClientRect(UserControl.hwnd, rc)
- di = DrawEdge(UserControl.hDC, rc, BDR_RAISEDOUTER, BF_RECT Or BF_MONO)
-
- Case [Thin Raised]
- di = GetClientRect(UserControl.hwnd, rc)
- di = DrawEdge(UserControl.hDC, rc, BDR_RAISEDINNER, BF_TOPLEFT)
- di = DrawEdge(UserControl.hDC, rc, BDR_RAISEDOUTER, BF_BOTTOMRIGHT)
-
- Case [Thick Raised]
- di = GetClientRect(UserControl.hwnd, rc)
- di = DrawEdge(UserControl.hDC, rc, EDGE_RAISED, BF_TOPLEFT)
- di = DrawEdge(UserControl.hDC, rc, EDGE_RAISED, BF_BOTTOMRIGHT)
-
- Case [Thin Inset]
- di = GetClientRect(UserControl.hwnd, rc)
- di = DrawEdge(UserControl.hDC, rc, BDR_SUNKENINNER, BF_TOPLEFT)
- di = DrawEdge(UserControl.hDC, rc, BDR_SUNKENOUTER, BF_BOTTOMRIGHT)
-
- Case [Thick Inset]
- di = GetClientRect(UserControl.hwnd, rc)
- di = DrawEdge(UserControl.hDC, rc, EDGE_SUNKEN, BF_TOPLEFT)
- di = DrawEdge(UserControl.hDC, rc, EDGE_SUNKEN, BF_BOTTOMRIGHT)
-
- Case [Etched]
- di = GetClientRect(UserControl.hwnd, rc)
- di = DrawEdge(UserControl.hDC, rc, EDGE_ETCHED, BF_TOPLEFT)
- di = DrawEdge(UserControl.hDC, rc, EDGE_ETCHED, BF_BOTTOMRIGHT)
-
- Case [Bump]
- di = GetClientRect(UserControl.hwnd, rc)
- di = DrawEdge(UserControl.hDC, rc, EDGE_BUMP, BF_TOPLEFT)
- di = DrawEdge(UserControl.hDC, rc, EDGE_BUMP, BF_BOTTOMRIGHT)
-
- End Select
-
- End Sub
-
- 'MappingInfo=UserControl,UserControl,-1,Ambient
- Public Property Get Ambient() As AmbientProperties
- Set Ambient = UserControl.Ambient
- End Property
-
-
-
-