home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / iList46526152002.psc / IList.ctl < prev    next >
Encoding:
Text File  |  2002-01-06  |  17.6 KB  |  596 lines

  1. VERSION 5.00
  2. Begin VB.UserControl IList 
  3.    ClientHeight    =   3570
  4.    ClientLeft      =   0
  5.    ClientTop       =   0
  6.    ClientWidth     =   4335
  7.    ScaleHeight     =   238
  8.    ScaleMode       =   3  'Pixel
  9.    ScaleWidth      =   289
  10.    Begin VB.PictureBox P 
  11.       AutoRedraw      =   -1  'True
  12.       BackColor       =   &H00FFFFFF&
  13.       Height          =   3525
  14.       Left            =   90
  15.       ScaleHeight     =   231
  16.       ScaleMode       =   3  'Pixel
  17.       ScaleWidth      =   282
  18.       TabIndex        =   0
  19.       Top             =   45
  20.       Width           =   4290
  21.       Begin VB.Timer Timer1 
  22.          Enabled         =   0   'False
  23.          Interval        =   3
  24.          Left            =   1035
  25.          Top             =   1890
  26.       End
  27.       Begin VB.VScrollBar Scroll 
  28.          Height          =   2805
  29.          Left            =   4005
  30.          Max             =   0
  31.          TabIndex        =   1
  32.          TabStop         =   0   'False
  33.          Top             =   0
  34.          Width           =   240
  35.       End
  36.    End
  37. End
  38. Attribute VB_Name = "IList"
  39. Attribute VB_GlobalNameSpace = False
  40. Attribute VB_Creatable = True
  41. Attribute VB_PredeclaredId = False
  42. Attribute VB_Exposed = False
  43. Dim CItems As New Collection
  44. 'Default Property Values:
  45. Const m_def_Selected = 0
  46. Const m_def_IconPosX = 0
  47. Const m_def_IconPosY = 0
  48. Const m_def_CaptionPosX = 0
  49. Const m_def_CaptionPosY = 0
  50. Const m_def_TextPosX = 0
  51. Const m_def_TextPosY = 0
  52. Const m_def_ItemHeight = 20
  53. 'Property Variables:
  54.  
  55. Dim m_Selected As Long
  56. Dim m_IconPosX As Long
  57. Dim m_IconPosY As Long
  58. Dim m_CaptionPosX As Long
  59. Dim m_CaptionPosY As Long
  60. Dim m_TextPosX As Long
  61. Dim m_TextPosY As Long
  62. Dim m_ImageList As ImageList
  63. Dim m_ItemHeight As Long
  64.  
  65. Dim Working As Boolean
  66. Dim m_Scroll As Integer
  67. 'Event Declarations:
  68. Event DblClick() 'MappingInfo=P,P,-1,DblClick
  69. Attribute DblClick.VB_Description = "Occurs when the user presses and releases a mouse button and then presses and releases it again over an object."
  70. Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=P,P,-1,KeyDown
  71. Attribute KeyDown.VB_Description = "Occurs when the user presses a key while an object has the focus."
  72. Event KeyPress(KeyAscii As Integer) 'MappingInfo=P,P,-1,KeyPress
  73. Attribute KeyPress.VB_Description = "Occurs when the user presses and releases an ANSI key."
  74. Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=P,P,-1,KeyUp
  75. Attribute KeyUp.VB_Description = "Occurs when the user releases a key while an object has the focus."
  76. Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=P,P,-1,MouseDown
  77. Attribute MouseDown.VB_Description = "Occurs when the user presses the mouse button while an object has the focus."
  78. Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=P,P,-1,MouseMove
  79. Attribute MouseMove.VB_Description = "Occurs when the user moves the mouse."
  80. Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=P,P,-1,MouseUp
  81. Attribute MouseUp.VB_Description = "Occurs when the user releases the mouse button while an object has the focus."
  82. Event Click() 'MappingInfo=P,P,-1,Click
  83. Attribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."
  84.  
  85. Public Event OnSelect()
  86. '#######################################################################
  87. '#######################################################################
  88. Sub AddItem(Caption As String, Text As String, Optional Key As Variant, Optional Icon As Variant)
  89.     Dim Item As New CItem
  90.     Item.Caption = Caption
  91.     Item.Text = Text
  92.     If IsMissing(Icon) Then
  93.         Item.Icon = 0
  94.     Else
  95.         Item.Icon = Icon
  96.     End If
  97.     If IsMissing(Key) Then
  98.         CItems.Add Item
  99.     Else
  100.         CItems.Add Item
  101.     End If
  102.     SetScroll
  103. End Sub
  104. Sub Remove(Key As Variant)
  105.     On Error Resume Next
  106.     CItems.Remove Key
  107.     Redraw
  108.     If Err.Number <> 0 Then
  109.         Err.Raise Err.Number, "IList", Err.Description
  110.     End If
  111. End Sub
  112. Sub Clear()
  113.     Set CItems = Nothing
  114. End Sub
  115. Function Item(Key) As CItem
  116.     On Error Resume Next
  117.     Set Item = CItems.Item(Key)
  118.     
  119.     If Err.Number <> 0 Then
  120.         Err.Raise Err.Number, "IList", Err.Description
  121.     End If
  122. End Function
  123. Function Count() As Long
  124.     Count = CItems.Count
  125. End Function
  126. '#######################################################################
  127. '#######################################################################
  128.  
  129. Private Sub P_Paint()
  130.     Redraw
  131. End Sub
  132.  
  133. Private Sub Scroll_Change()
  134.     Redraw
  135. End Sub
  136.  
  137. Private Sub Scroll_Scroll()
  138.     Redraw
  139. End Sub
  140.  
  141.  
  142.  
  143.  
  144.  
  145. Private Sub Timer1_Timer()
  146.  
  147.  
  148.     Select Case m_Scroll
  149.         Case Is = 1
  150.             P_KeyDown vbKeyUp, 0
  151.        Case Is = 2
  152.             P_KeyDown vbKeyDown, 0
  153.     End Select
  154.  
  155. End Sub
  156.  
  157. Private Sub UserControl_Paint()
  158.     Redraw
  159. End Sub
  160.  
  161. Private Sub UserControl_Resize()
  162.     On Error Resume Next
  163.     Redraw
  164.     P.Move 0, 0, ScaleWidth, ScaleHeight
  165.     Scroll.Move P.ScaleWidth - Scroll.Width, 0, Scroll.Width, P.ScaleHeight
  166.     SetScroll
  167. End Sub
  168.  
  169. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  170. 'MemberInfo=8,0,0,20
  171. Public Property Get ItemHeight() As Long
  172.     ItemHeight = m_ItemHeight
  173. End Property
  174.  
  175. Public Property Let ItemHeight(ByVal New_ItemHeight As Long)
  176.     m_ItemHeight = New_ItemHeight
  177.     PropertyChanged "ItemHeight"
  178. End Property
  179. '#######################################################################
  180. '#######################################################################
  181. 'Initialize Properties for User Control
  182. Private Sub UserControl_InitProperties()
  183.     m_ItemHeight = m_def_ItemHeight
  184.     m_IconPosX = m_def_IconPosX
  185.     m_IconPosY = m_def_IconPosY
  186.     m_CaptionPosX = m_def_CaptionPosX
  187.     m_CaptionPosY = m_def_CaptionPosY
  188.     m_TextPosX = m_def_TextPosX
  189.     m_TextPosY = m_def_TextPosY
  190.     m_Selected = m_def_Selected
  191. '    Set m_FontCaption = Ambient.Font
  192. '    Set m_FontText = Ambient.Font
  193. End Sub
  194. 'Load property values from storage
  195. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  196.  
  197.     m_ItemHeight = PropBag.ReadProperty("ItemHeight", m_def_ItemHeight)
  198.     Set m_ImageList = PropBag.ReadProperty("ImageList", Nothing)
  199.     m_IconPosX = PropBag.ReadProperty("IconPosX", m_def_IconPosX)
  200.     m_IconPosY = PropBag.ReadProperty("IconPosY", m_def_IconPosY)
  201.     m_CaptionPosX = PropBag.ReadProperty("CaptionPosX", m_def_CaptionPosX)
  202.     m_CaptionPosY = PropBag.ReadProperty("CaptionPosY", m_def_CaptionPosY)
  203.     m_TextPosX = PropBag.ReadProperty("TextPosX", m_def_TextPosX)
  204.     m_TextPosY = PropBag.ReadProperty("TextPosY", m_def_TextPosY)
  205.     m_Selected = PropBag.ReadProperty("Selected", m_def_Selected)
  206.     Set MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
  207.     P.MousePointer = PropBag.ReadProperty("MousePointer", 0)
  208.     Set P.Font = PropBag.ReadProperty("Font", Ambient.Font)
  209. End Sub
  210.  
  211. 'Write property values to storage
  212. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  213.     Call PropBag.WriteProperty("ItemHeight", m_ItemHeight, m_def_ItemHeight)
  214.     Call PropBag.WriteProperty("ImageList", m_ImageList, Nothing)
  215.     Call PropBag.WriteProperty("IconPosX", m_IconPosX, m_def_IconPosX)
  216.     Call PropBag.WriteProperty("IconPosY", m_IconPosY, m_def_IconPosY)
  217.     Call PropBag.WriteProperty("CaptionPosX", m_CaptionPosX, m_def_CaptionPosX)
  218.     Call PropBag.WriteProperty("CaptionPosY", m_CaptionPosY, m_def_CaptionPosY)
  219.     Call PropBag.WriteProperty("TextPosX", m_TextPosX, m_def_TextPosX)
  220.     Call PropBag.WriteProperty("TextPosY", m_TextPosY, m_def_TextPosY)
  221.     Call PropBag.WriteProperty("Selected", m_Selected, m_def_Selected)
  222.     Call PropBag.WriteProperty("MouseIcon", MouseIcon, Nothing)
  223.     Call PropBag.WriteProperty("MousePointer", P.MousePointer, 0)
  224.     Call PropBag.WriteProperty("Font", P.Font, Ambient.Font)
  225. End Sub
  226. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  227. 'MemberInfo=9,0,0,0
  228. Public Property Get ImageList() As ImageList
  229.     Set ImageList = m_ImageList
  230. End Property
  231.  
  232. Public Property Set ImageList(ByVal New_ImageList As ImageList)
  233.     Set m_ImageList = New_ImageList
  234.     PropertyChanged "ImageList"
  235. End Property
  236.  
  237.  
  238. Public Sub Redraw()
  239.     
  240.     Dim I As Long
  241.  
  242.     Dim Y As Long
  243.     
  244.     On Error Resume Next
  245.     
  246.     If Selected = 0 Then
  247.         If Count > 0 Then
  248.             Selected = 1
  249.         End If
  250.     End If
  251.     SetScroll
  252.  
  253.     P.Cls
  254.     Dim Ips As Long
  255.     Ips = RoundEx(P.ScaleHeight / m_ItemHeight)
  256.     
  257.     For I = Scroll.Value + 1 To Count
  258.         DrawItem I
  259.         If I > Scroll.Value + Ips + 1 Then Exit For
  260.     Next
  261.     P.Refresh
  262.     Working = False
  263. End Sub
  264.  
  265.  
  266. Sub DrawItem(Index)
  267.  
  268. On Error Resume Next
  269.  
  270. Dim Y As Long
  271. Dim Itm As CItem
  272.  
  273. Set Itm = CItems(Index)
  274. Y = (Index - Scroll.Value - 1) * m_ItemHeight
  275.  
  276. 'Set forecolor and backcolor
  277. If Selected = Index Then
  278.    P.ForeColor = vbHighlightText
  279.    Rectangle 0, Y, P.ScaleWidth, m_ItemHeight
  280. Else
  281.    P.ForeColor = vbButtonText
  282. End If
  283.  
  284. 'Print caption
  285. P.FontBold = True
  286. PrintAt m_CaptionPosX, Y + m_CaptionPosY, Itm.Caption
  287. 'Print text
  288. P.FontBold = False
  289. PrintAt m_TextPosX, Y + m_TextPosY, Itm.Text
  290. 'Draw picture
  291. P.PaintPicture m_ImageList.ListImages(Itm.Icon).ExtractIcon, _
  292.                m_IconPosX, m_IconPosY + Y
  293. End Sub
  294.  
  295.  
  296. 'Api (heh)
  297. Sub PrintAt(X As Long, Y As Long, Text As String)
  298.     P.CurrentX = X
  299.     P.CurrentY = Y
  300.     P.Print Text
  301. End Sub
  302. Sub MoveTo(X, Y)
  303.     P.CurrentX = X
  304.     P.CurrentY = Y
  305. End Sub
  306.  
  307. Sub LineTo(X, Y, Optional Color As Long = 0)
  308.     P.Line -(X, Y), Color
  309. End Sub
  310. Sub TextOut(Text As String)
  311.     P.Print Text
  312. End Sub
  313. Sub Rectangle(X As Long, Y As Long, Width As Long, Height As Long, _
  314.               Optional Color As Long = vbHighlight)
  315.     P.Line (X, Y)-Step(Width, Height), Color, BF
  316. End Sub
  317. Function RoundEx(X)
  318.     If X > CLng(X) Then
  319.         RoundEx = CLng(X) + 1
  320.     Else
  321.         RoundEx = CLng(X)
  322.     End If
  323. End Function
  324.  
  325.  
  326.  
  327.  
  328. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  329. 'MemberInfo=8,0,0,0
  330. Public Property Get IconPosX() As Long
  331.     IconPosX = m_IconPosX
  332. End Property
  333.  
  334. Public Property Let IconPosX(ByVal New_IconPosX As Long)
  335.     m_IconPosX = New_IconPosX
  336.     PropertyChanged "IconPosX"
  337. End Property
  338.  
  339. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  340. 'MemberInfo=8,0,0,0
  341. Public Property Get IconPosY() As Long
  342.     IconPosY = m_IconPosY
  343. End Property
  344.  
  345. Public Property Let IconPosY(ByVal New_IconPosY As Long)
  346.     m_IconPosY = New_IconPosY
  347.     PropertyChanged "IconPosY"
  348. End Property
  349.  
  350. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  351. 'MemberInfo=8,0,0,0
  352. Public Property Get CaptionPosX() As Long
  353.     CaptionPosX = m_CaptionPosX
  354. End Property
  355.  
  356. Public Property Let CaptionPosX(ByVal New_CaptionPosX As Long)
  357.     m_CaptionPosX = New_CaptionPosX
  358.     PropertyChanged "CaptionPosX"
  359. End Property
  360.  
  361. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  362. 'MemberInfo=8,0,0,0
  363. Public Property Get CaptionPosY() As Long
  364.     CaptionPosY = m_CaptionPosY
  365. End Property
  366.  
  367. Public Property Let CaptionPosY(ByVal New_CaptionPosY As Long)
  368.     m_CaptionPosY = New_CaptionPosY
  369.     PropertyChanged "CaptionPosY"
  370. End Property
  371.  
  372. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  373. 'MemberInfo=8,0,0,0
  374. Public Property Get TextPosX() As Long
  375.     TextPosX = m_TextPosX
  376. End Property
  377.  
  378. Public Property Let TextPosX(ByVal New_TextPosX As Long)
  379.     m_TextPosX = New_TextPosX
  380.     PropertyChanged "TextPosX"
  381. End Property
  382.  
  383. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  384. 'MemberInfo=8,0,0,0
  385. Public Property Get TextPosY() As Long
  386.     TextPosY = m_TextPosY
  387. End Property
  388.  
  389. Public Property Let TextPosY(ByVal New_TextPosY As Long)
  390.     m_TextPosY = New_TextPosY
  391.     PropertyChanged "TextPosY"
  392. End Property
  393.  
  394. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  395. 'MemberInfo=8,0,0,0
  396. Public Property Get Selected() As Long
  397.     Selected = m_Selected
  398. End Property
  399.  
  400. Public Property Let Selected(ByVal New_Selected As Long)
  401.  
  402. Dim Y As Long
  403. Dim T As Long
  404. If New_Selected > Count Then New_Selected = Count
  405.  
  406. If New_Selected <> m_Selected Then
  407.         'Clear
  408.         T = m_Selected
  409.         m_Selected = New_Selected
  410.         
  411.         Y = (T - Scroll.Value - 1) * m_ItemHeight
  412.         Rectangle 0, Y, P.ScaleWidth, m_ItemHeight, vbWhite
  413.         DrawItem T
  414.         DrawItem m_Selected
  415.         
  416.         RaiseEvent OnSelect
  417. End If
  418.  
  419.     PropertyChanged "Selected"
  420. End Property
  421. Sub SetPos(CaptionX As Long, CaptionY As Long, _
  422.            TextX As Long, TextY As Long, _
  423.            IconX As Long, IconY As Long)
  424.     m_CaptionPosX = CaptionX
  425.     m_CaptionPosY = CaptionY
  426.     m_TextPosX = TextX
  427.     m_TextPosY = TextY
  428.     m_IconPosX = IconX
  429.     m_IconPosY = IconY
  430.     Redraw
  431. End Sub
  432.  
  433. Function IsVisible(Index As Long) As Boolean
  434.     Dim Ips As Long
  435.     Ips = (P.ScaleHeight \ m_ItemHeight)
  436.     If Index > Scroll.Value And Index < Scroll.Value + Ips + 1 Then
  437.         IsVisible = True
  438.     End If
  439. End Function
  440.  
  441. Sub ScrollTo(Index As Long)
  442.     Dim Ips As Long
  443.     Ips = (P.ScaleHeight \ m_ItemHeight)
  444.     If Scroll.Visible = False Then Exit Sub
  445.     If Count > Index + Ips Then
  446.         Scroll.Value = Index - 1
  447.     Else
  448.         Scroll.Value = Count - Ips
  449.     End If
  450. End Sub
  451.  
  452.  
  453. Private Sub SetScroll()
  454.     
  455.     Scroll.Max = Count - Int(P.ScaleHeight / m_ItemHeight)
  456.     If Scroll.Max <= 0 Then
  457.         Scroll.Max = 0
  458.         Scroll.Visible = False
  459.     Else
  460.         Scroll.Visible = True
  461.     End If
  462. End Sub
  463.  
  464. Private Sub P_Click()
  465.     RaiseEvent Click
  466.   
  467. End Sub
  468.  
  469. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  470. 'MappingInfo=P,P,-1,hWnd
  471. Public Property Get hWnd() As Long
  472. Attribute hWnd.VB_Description = "Returns a handle (from Microsoft Windows) to an object's window."
  473.     hWnd = P.hWnd
  474. End Property
  475.  
  476. Private Sub P_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  477.     RaiseEvent MouseDown(Button, Shift, X, Y)
  478.     Selected = RoundEx(Y / m_ItemHeight) + Scroll.Value
  479. End Sub
  480.  
  481. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  482. 'MappingInfo=P,P,-1,MouseIcon
  483. Public Property Get MouseIcon() As Picture
  484. Attribute MouseIcon.VB_Description = "Sets a custom mouse icon."
  485.     Set MouseIcon = P.MouseIcon
  486. End Property
  487.  
  488. Public Property Set MouseIcon(ByVal New_MouseIcon As Picture)
  489.     Set P.MouseIcon = New_MouseIcon
  490.     PropertyChanged "MouseIcon"
  491. End Property
  492.  
  493. Private Sub P_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  494.     RaiseEvent MouseMove(Button, Shift, X, Y)
  495.     If Button = 1 Then
  496.         If Y > 0 And Y < P.ScaleHeight Then
  497.             Timer1.Enabled = False
  498.             Selected = RoundEx(Y / m_ItemHeight) + Scroll.Value
  499.         Else
  500.         
  501.             If Y < 0 Then
  502.                 m_Scroll = 1
  503.             ElseIf Y > P.ScaleHeight Then
  504.                 m_Scroll = 2
  505.             End If
  506.             Timer1.Enabled = True
  507.         End If
  508.     End If
  509. End Sub
  510.  
  511. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  512. 'MappingInfo=P,P,-1,MousePointer
  513. Public Property Get MousePointer() As MousePointerConstants
  514. Attribute MousePointer.VB_Description = "Returns/sets the type of mouse pointer displayed when over part of an object."
  515.     MousePointer = P.MousePointer
  516. End Property
  517.  
  518. Public Property Let MousePointer(ByVal New_MousePointer As MousePointerConstants)
  519.     P.MousePointer() = New_MousePointer
  520.     PropertyChanged "MousePointer"
  521. End Property
  522.  
  523. Private Sub P_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  524.     Timer1.Enabled = False
  525.     RaiseEvent MouseUp(Button, Shift, X, Y)
  526. End Sub
  527.  
  528. Private Sub P_DblClick()
  529.     RaiseEvent DblClick
  530. End Sub
  531.  
  532. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  533. 'MappingInfo=P,P,-1,Font
  534. Public Property Get Font() As Font
  535. Attribute Font.VB_Description = "Returns a Font object."
  536. Attribute Font.VB_UserMemId = -512
  537.     Set Font = P.Font
  538. End Property
  539.  
  540. Public Property Set Font(ByVal New_Font As Font)
  541.     Set P.Font = New_Font
  542.     PropertyChanged "Font"
  543. End Property
  544.  
  545. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  546. 'MappingInfo=P,P,-1,hDC
  547. Public Property Get hDC() As Long
  548. Attribute hDC.VB_Description = "Returns a handle (from Microsoft Windows) to the object's device context."
  549.     hDC = P.hDC
  550. End Property
  551.  
  552. Private Sub P_KeyDown(KeyCode As Integer, Shift As Integer)
  553.     RaiseEvent KeyDown(KeyCode, Shift)
  554.     On Error Resume Next
  555.     If Working = True Then Exit Sub
  556.     Select Case KeyCode
  557.         Case Is = vbKeyUp
  558.             If Selected > 1 Then Selected = Selected - 1
  559.             If IsVisible(Selected) = False Then
  560.                 If Scroll.Value > 0 Then
  561.                     'DoEvents
  562.                     Working = True
  563.                     Scroll.Value = Scroll.Value - 1
  564.                 End If
  565.             End If
  566.         Case Is = vbKeyDown
  567.             If Selected < Count Then Selected = Selected + 1
  568.             If IsVisible(Selected) = False Then
  569.                 If Scroll.Value < Scroll.Max Then
  570.                     'DoEvents
  571.                     Working = True
  572.                     Scroll.Value = Scroll.Value + 1
  573.                 End If
  574.             End If
  575.     End Select
  576. End Sub
  577.  
  578. Private Sub P_KeyPress(KeyAscii As Integer)
  579.     RaiseEvent KeyPress(KeyAscii)
  580. End Sub
  581.  
  582. Private Sub P_KeyUp(KeyCode As Integer, Shift As Integer)
  583.     RaiseEvent KeyUp(KeyCode, Shift)
  584. End Sub
  585.  
  586. Public Sub SetCaption(Index, Caption As String)
  587.     CItems(Index).Caption = Caption
  588.     DrawItem Index
  589. End Sub
  590.  
  591.  
  592. Public Sub SetText(Index, Text As String)
  593.     CItems(Index).Text = Text
  594.     DrawItem Index
  595. End Sub
  596.