home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / School_Man20924211302007.psc / prischo / ctrl_ListObject.ctl < prev    next >
Text File  |  2007-11-21  |  16KB  |  428 lines

  1. VERSION 5.00
  2. Begin VB.UserControl ctrl_ListObject 
  3.    AutoRedraw      =   -1  'True
  4.    BackStyle       =   0  'Transparent
  5.    ClientHeight    =   2985
  6.    ClientLeft      =   0
  7.    ClientTop       =   0
  8.    ClientWidth     =   2100
  9.    ScaleHeight     =   2985
  10.    ScaleWidth      =   2100
  11.    Begin VB.PictureBox pic_Viewport 
  12.       AutoRedraw      =   -1  'True
  13.       AutoSize        =   -1  'True
  14.       BackColor       =   &H00808080&
  15.       BorderStyle     =   0  'None
  16.       Height          =   735
  17.       Left            =   0
  18.       ScaleHeight     =   735
  19.       ScaleWidth      =   1215
  20.       TabIndex        =   3
  21.       Top             =   600
  22.       Width           =   1215
  23.       Begin VB.PictureBox pic_MouseMove 
  24.          AutoRedraw      =   -1  'True
  25.          AutoSize        =   -1  'True
  26.          BorderStyle     =   0  'None
  27.          Height          =   615
  28.          Left            =   0
  29.          ScaleHeight     =   615
  30.          ScaleWidth      =   1215
  31.          TabIndex        =   4
  32.          Top             =   0
  33.          Visible         =   0   'False
  34.          Width           =   1215
  35.          Begin VB.Label lbl_MouseMove 
  36.             Alignment       =   2  'Center
  37.             BackStyle       =   0  'Transparent
  38.             Caption         =   "Item"
  39.             BeginProperty Font 
  40.                Name            =   "Tahoma"
  41.                Size            =   11.25
  42.                Charset         =   0
  43.                Weight          =   700
  44.                Underline       =   0   'False
  45.                Italic          =   0   'False
  46.                Strikethrough   =   0   'False
  47.             EndProperty
  48.             Height          =   435
  49.             Left            =   0
  50.             TabIndex        =   6
  51.             Top             =   0
  52.             Width           =   330
  53.          End
  54.       End
  55.       Begin VB.Label lbl_Item 
  56.          Alignment       =   2  'Center
  57.          BackStyle       =   0  'Transparent
  58.          Caption         =   "Item"
  59.          BeginProperty Font 
  60.             Name            =   "Tahoma"
  61.             Size            =   8.25
  62.             Charset         =   0
  63.             Weight          =   700
  64.             Underline       =   0   'False
  65.             Italic          =   0   'False
  66.             Strikethrough   =   0   'False
  67.          EndProperty
  68.          Height          =   195
  69.          Index           =   0
  70.          Left            =   0
  71.          TabIndex        =   5
  72.          Top             =   0
  73.          Visible         =   0   'False
  74.          Width           =   330
  75.       End
  76.    End
  77.    Begin VB.PictureBox pic_DownBorder 
  78.       AutoRedraw      =   -1  'True
  79.       AutoSize        =   -1  'True
  80.       BorderStyle     =   0  'None
  81.       Height          =   495
  82.       Left            =   0
  83.       ScaleHeight     =   495
  84.       ScaleWidth      =   1215
  85.       TabIndex        =   2
  86.       Top             =   1200
  87.       Width           =   1215
  88.       Begin VB.Image img_MoveDown 
  89.          Height          =   360
  90.          Left            =   0
  91.          Top             =   0
  92.          Width           =   300
  93.       End
  94.    End
  95.    Begin VB.PictureBox pic_UpBorder 
  96.       AutoRedraw      =   -1  'True
  97.       AutoSize        =   -1  'True
  98.       BorderStyle     =   0  'None
  99.       Height          =   495
  100.       Left            =   0
  101.       ScaleHeight     =   495
  102.       ScaleWidth      =   1215
  103.       TabIndex        =   1
  104.       Top             =   0
  105.       Width           =   1215
  106.       Begin VB.Image img_MoveUp 
  107.          Height          =   360
  108.          Left            =   0
  109.          Top             =   0
  110.          Width           =   300
  111.       End
  112.    End
  113.    Begin VB.PictureBox pic_Source 
  114.       AutoRedraw      =   -1  'True
  115.       AutoSize        =   -1  'True
  116.       BackColor       =   &H00C0C0FF&
  117.       Height          =   495
  118.       Left            =   0
  119.       ScaleHeight     =   435
  120.       ScaleWidth      =   1155
  121.       TabIndex        =   0
  122.       Top             =   1680
  123.       Visible         =   0   'False
  124.       Width           =   1215
  125.    End
  126. End
  127. Attribute VB_Name = "ctrl_ListObject"
  128. Attribute VB_GlobalNameSpace = False
  129. Attribute VB_Creatable = True
  130. Attribute VB_PredeclaredId = False
  131. Attribute VB_Exposed = False
  132. Option Explicit
  133. '
  134. '
  135. '
  136. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  137. Private Const SRCCOPY = &HCC0020
  138.  
  139. Const DefForeColor = 0
  140. Const DefMouseMoveColor = 0
  141. Const DefMouseDownColor = 0
  142.  
  143. Dim v_sSkinPath As String
  144. Dim v_oForeColor As OLE_COLOR
  145. Dim v_oMouseMoveColor As OLE_COLOR
  146. Dim v_oMouseDownColor As OLE_COLOR
  147. Dim v_iItemCount As Integer
  148. Dim v_iLastItem As Integer
  149.  
  150. Event Click(Index As Integer)
  151. Event MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
  152.  
  153. Public Sub DrawMenu()
  154.     Dim v_lRtn As Long
  155.     Dim v_iCenterImgFrequency As Integer
  156.     Dim v_iLoop As Integer
  157.     Dim v_iCurrentY As Integer
  158.  
  159.     With UserControl
  160.         .pic_Source.Picture = LoadPicture(SkinPath & "\img_ListObject.bmp")
  161.         .pic_UpBorder.Width = .Width
  162.         .pic_UpBorder.Height = 360
  163.         
  164.         .pic_UpBorder.Cls
  165.         v_lRtn = BitBlt(.pic_UpBorder.hDC, 0, 0, 20, 24, .pic_Source.hDC, 0, 0, SRCCOPY)
  166.         v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 20)
  167.         If v_iCenterImgFrequency > 0 Then
  168.             For v_iLoop = 1 To v_iCenterImgFrequency
  169.                 v_lRtn = BitBlt(.pic_UpBorder.hDC, v_iLoop * 20, 0, 20, 24, .pic_Source.hDC, 20, 0, SRCCOPY)
  170.             Next v_iLoop
  171.         End If
  172.         v_lRtn = BitBlt(.pic_UpBorder.hDC, (.Width / Screen.TwipsPerPixelX) - 23, 0, 23, 24, .pic_Source.hDC, 44, 0, SRCCOPY)
  173.             
  174.         .pic_DownBorder.Cls
  175.         .pic_DownBorder.Width = .Width
  176.         .pic_DownBorder.Height = 360
  177.         .pic_DownBorder.Top = .Height - .pic_DownBorder.Height
  178.         v_lRtn = BitBlt(.pic_DownBorder.hDC, 0, 0, 20, 24, .pic_Source.hDC, 0, 96, SRCCOPY)
  179.         v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 20)
  180.         If v_iCenterImgFrequency > 0 Then
  181.             For v_iLoop = 1 To v_iCenterImgFrequency
  182.                 v_lRtn = BitBlt(.pic_DownBorder.hDC, v_iLoop * 20, 0, 20, 24, .pic_Source.hDC, 20, 96, SRCCOPY)
  183.             Next v_iLoop
  184.         End If
  185.         v_lRtn = BitBlt(.pic_DownBorder.hDC, (.Width / Screen.TwipsPerPixelX) - 23, 0, 23, 24, .pic_Source.hDC, 44, 96, SRCCOPY)
  186.     
  187.         .pic_Viewport.Top = .pic_UpBorder.Height
  188.         .pic_Viewport.Width = .Width
  189.         .pic_Viewport.Height = .Height - .pic_UpBorder.Height - .pic_DownBorder.Height
  190.         
  191.         .pic_Viewport.Cls
  192.         v_iCurrentY = 0
  193.         While (v_iCurrentY * 15) < (.Height - 720)
  194.             v_lRtn = BitBlt(.pic_Viewport.hDC, 0, v_iCurrentY, 20, 24, .pic_Source.hDC, 0, 24, SRCCOPY)
  195.             v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 20)
  196.             If v_iCenterImgFrequency > 0 Then
  197.                 For v_iLoop = 1 To v_iCenterImgFrequency
  198.                     v_lRtn = BitBlt(.pic_Viewport.hDC, v_iLoop * 20, v_iCurrentY, 20, 24, .pic_Source.hDC, 20, 24, SRCCOPY)
  199.                 Next v_iLoop
  200.             End If
  201.             v_lRtn = BitBlt(.pic_Viewport.hDC, (.Width / Screen.TwipsPerPixelX) - 23, v_iCurrentY, 23, 24, .pic_Source.hDC, 44, 24, SRCCOPY)
  202.             v_iCurrentY = v_iCurrentY + 24
  203.         Wend
  204.     End With
  205. End Sub
  206.  
  207. Public Sub Refresh()
  208.     Dim v_lRtn As Long
  209.     Dim v_iCenterImgFrequency As Integer
  210.     Dim v_iLoop As Integer
  211.     Dim v_iCurrentY As Integer
  212.  
  213.     With UserControl
  214.         .pic_UpBorder.Width = .Width
  215.         .pic_UpBorder.Height = 360
  216.         
  217.         v_lRtn = BitBlt(.pic_UpBorder.hDC, 0, 0, 20, 24, .pic_Source.hDC, 0, 0, SRCCOPY)
  218.         v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 20)
  219.         If v_iCenterImgFrequency > 0 Then
  220.             For v_iLoop = 1 To v_iCenterImgFrequency
  221.                 v_lRtn = BitBlt(.pic_UpBorder.hDC, v_iLoop * 20, 0, 20, 24, .pic_Source.hDC, 20, 0, SRCCOPY)
  222.             Next v_iLoop
  223.         End If
  224.         v_lRtn = BitBlt(.pic_UpBorder.hDC, (.Width / Screen.TwipsPerPixelX) - 23, 0, 23, 24, .pic_Source.hDC, 44, 0, SRCCOPY)
  225.             
  226.         .pic_DownBorder.Width = .Width
  227.         .pic_DownBorder.Height = 360
  228.         .pic_DownBorder.Top = .Height - .pic_DownBorder.Height
  229.         v_lRtn = BitBlt(.pic_DownBorder.hDC, 0, 0, 20, 24, .pic_Source.hDC, 0, 96, SRCCOPY)
  230.         v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 20)
  231.         If v_iCenterImgFrequency > 0 Then
  232.             For v_iLoop = 1 To v_iCenterImgFrequency
  233.                 v_lRtn = BitBlt(.pic_DownBorder.hDC, v_iLoop * 20, 0, 20, 24, .pic_Source.hDC, 20, 96, SRCCOPY)
  234.             Next v_iLoop
  235.         End If
  236.         v_lRtn = BitBlt(.pic_DownBorder.hDC, (.Width / Screen.TwipsPerPixelX) - 23, 0, 23, 24, .pic_Source.hDC, 44, 96, SRCCOPY)
  237.     
  238.         .pic_Viewport.Top = .pic_UpBorder.Height
  239.         .pic_Viewport.Width = .Width
  240.         .pic_Viewport.Height = .Height - .pic_UpBorder.Height - .pic_DownBorder.Height
  241.         
  242.         v_iCurrentY = 0
  243.         While (v_iCurrentY * 15) < (.Height - 720)
  244.             v_lRtn = BitBlt(.pic_Viewport.hDC, 0, v_iCurrentY, 20, 24, .pic_Source.hDC, 0, 24, SRCCOPY)
  245.             v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 20)
  246.             If v_iCenterImgFrequency > 0 Then
  247.                 For v_iLoop = 1 To v_iCenterImgFrequency
  248.                     v_lRtn = BitBlt(.pic_Viewport.hDC, v_iLoop * 20, v_iCurrentY, 20, 24, .pic_Source.hDC, 20, 24, SRCCOPY)
  249.                 Next v_iLoop
  250.             End If
  251.             v_lRtn = BitBlt(.pic_Viewport.hDC, (.Width / Screen.TwipsPerPixelX) - 23, v_iCurrentY, 23, 24, .pic_Source.hDC, 44, 24, SRCCOPY)
  252.             v_iCurrentY = v_iCurrentY + 24
  253.         Wend
  254.     End With
  255. End Sub
  256.  
  257. Public Sub AddItem(m_Item As String)
  258.     With UserControl
  259.         If v_iItemCount <> 0 Then
  260.             Load .lbl_Item(v_iItemCount)
  261.         End If
  262.         .lbl_Item(v_iItemCount).Width = .Width
  263.         .lbl_Item(v_iItemCount).Top = 360 * v_iItemCount + 75
  264.         .lbl_Item(v_iItemCount).Caption = m_Item
  265.         .lbl_Item(v_iItemCount).Visible = True
  266.         v_iItemCount = v_iItemCount + 1
  267.     End With
  268. End Sub
  269.  
  270. Private Sub UnloadItems()
  271.     Dim v_iLoop As Integer
  272.     
  273.     For v_iLoop = 1 To v_iItemCount - 1
  274.         Unload UserControl.lbl_Item(v_iLoop)
  275.     Next v_iLoop
  276. End Sub
  277.  
  278. Public Property Get SkinPath() As String
  279.     SkinPath = v_sSkinPath
  280. End Property
  281.  
  282. Public Property Let SkinPath(ByVal m_SkinPath As String)
  283.     v_sSkinPath = m_SkinPath
  284.     PropertyChanged "SkinPath"
  285. End Property
  286.  
  287. Public Property Get ForeColor() As OLE_COLOR
  288.     ForeColor = v_oForeColor
  289. End Property
  290.  
  291. Public Property Let ForeColor(ByVal m_ForeColor As OLE_COLOR)
  292.     Dim v_iLoop As Integer
  293.     
  294.     v_oForeColor = m_ForeColor
  295.     PropertyChanged "ForeColor"
  296.     
  297.     For v_iLoop = 0 To v_iItemCount - 1
  298.         UserControl.lbl_Item(v_iLoop).ForeColor = v_oForeColor
  299.     Next v_iLoop
  300. End Property
  301.  
  302. Public Property Get MouseMoveColor() As OLE_COLOR
  303.     MouseMoveColor = v_oMouseMoveColor
  304. End Property
  305.  
  306. Public Property Let MouseMoveColor(ByVal m_MouseMoveColor As OLE_COLOR)
  307.     v_oMouseMoveColor = m_MouseMoveColor
  308.     PropertyChanged "MouseMoveColor"
  309. End Property
  310.  
  311. Public Property Get MouseDownColor() As OLE_COLOR
  312.     MouseDownColor = v_oMouseDownColor
  313. End Property
  314.  
  315. Public Property Let MouseDownColor(ByVal m_MouseDownColor As OLE_COLOR)
  316.     v_oMouseDownColor = m_MouseDownColor
  317.     PropertyChanged "MouseDownColor"
  318. End Property
  319.  
  320. Private Sub img_MoveDown_Click()
  321.     Dim v_iLoop As Integer
  322.     
  323.     For v_iLoop = 0 To v_iItemCount - 1
  324.         UserControl.lbl_Item(v_iLoop).Top = UserControl.lbl_Item(v_iLoop).Top - 360
  325.         UserControl.pic_MouseMove.Visible = False
  326.     Next v_iLoop
  327. End Sub
  328.  
  329. Private Sub img_MoveUp_Click()
  330.     Dim v_iLoop As Integer
  331.     
  332.     For v_iLoop = 0 To v_iItemCount - 1
  333.         UserControl.lbl_Item(v_iLoop).Top = UserControl.lbl_Item(v_iLoop).Top + 360
  334.         UserControl.pic_MouseMove.Visible = False
  335.     Next v_iLoop
  336. End Sub
  337.  
  338. Private Sub lbl_Item_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
  339.     Dim v_lRtn As Long
  340.     Dim v_iCenterImgFrequency As Integer
  341.     Dim v_iLoop As Integer
  342.  
  343.     RaiseEvent MouseMove(Index, Button, Shift, x, y)
  344.     v_iLastItem = Index
  345.     With UserControl
  346.         .pic_MouseMove.Width = .Width
  347.         .pic_MouseMove.Height = 360
  348.     
  349.         .pic_MouseMove.Cls
  350.         v_lRtn = BitBlt(.pic_MouseMove.hDC, 0, 0, 20, 24, .pic_Source.hDC, 0, 48, SRCCOPY)
  351.         v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 20)
  352.         If v_iCenterImgFrequency > 0 Then
  353.             For v_iLoop = 1 To v_iCenterImgFrequency
  354.                 v_lRtn = BitBlt(.pic_MouseMove.hDC, v_iLoop * 20, 0, 20, 24, .pic_Source.hDC, 20, 48, SRCCOPY)
  355.             Next v_iLoop
  356.         End If
  357.         v_lRtn = BitBlt(.pic_MouseMove.hDC, (.Width / Screen.TwipsPerPixelX) - 23, 0, 23, 24, .pic_Source.hDC, 44, 48, SRCCOPY)
  358.         
  359.         .pic_MouseMove.Top = .lbl_Item(Index).Top - 75
  360.         .lbl_MouseMove.Caption = .lbl_Item(Index).Caption
  361.         .lbl_MouseMove.ForeColor = MouseMoveColor
  362.         .lbl_MouseMove.Width = .Width
  363.         .lbl_MouseMove.Top = 75
  364.         .pic_MouseMove.Visible = True
  365.     End With
  366. End Sub
  367.  
  368. Private Sub lbl_MouseMove_Click()
  369.     RaiseEvent Click(v_iLastItem)
  370. End Sub
  371.  
  372. Private Sub lbl_MouseMove_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  373.     Dim v_lRtn As Long
  374.     Dim v_iCenterImgFrequency As Integer
  375.     Dim v_iLoop As Integer
  376.  
  377.     With UserControl
  378.         .pic_MouseMove.Width = .Width
  379.         .pic_MouseMove.Height = 360
  380.     
  381.         .pic_MouseMove.Cls
  382.         .lbl_MouseMove.ForeColor = MouseDownColor
  383.         v_lRtn = BitBlt(.pic_MouseMove.hDC, 0, 0, 20, 24, .pic_Source.hDC, 0, 72, SRCCOPY)
  384.         v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 20)
  385.         If v_iCenterImgFrequency > 0 Then
  386.             For v_iLoop = 1 To v_iCenterImgFrequency
  387.                 v_lRtn = BitBlt(.pic_MouseMove.hDC, v_iLoop * 20, 0, 20, 24, .pic_Source.hDC, 20, 72, SRCCOPY)
  388.             Next v_iLoop
  389.         End If
  390.         v_lRtn = BitBlt(.pic_MouseMove.hDC, (.Width / Screen.TwipsPerPixelX) - 23, 0, 23, 24, .pic_Source.hDC, 44, 72, SRCCOPY)
  391.     End With
  392. End Sub
  393.  
  394. Private Sub UserControl_InitProperties()
  395.     v_sSkinPath = App.Path & "\Skins\Titanium"
  396.     v_oForeColor = DefForeColor
  397.     v_oMouseMoveColor = DefMouseMoveColor
  398.     v_oMouseDownColor = DefMouseDownColor
  399. End Sub
  400.  
  401. Private Sub UserControl_Resize()
  402.     Call Refresh
  403. End Sub
  404.  
  405. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  406.     v_sSkinPath = PropBag.ReadProperty("SkinPath", App.Path & "\Skins\Titanium")
  407.     Call DrawMenu
  408.     
  409.     v_oForeColor = PropBag.ReadProperty("ForeColor", DefForeColor)
  410.     UserControl.lbl_Item(0).ForeColor = v_oForeColor
  411.  
  412.     v_oMouseMoveColor = PropBag.ReadProperty("MouseMoveColor", DefMouseMoveColor)
  413.     UserControl.lbl_MouseMove.ForeColor = v_oMouseMoveColor
  414.  
  415.     v_oMouseDownColor = PropBag.ReadProperty("MouseDownColor", DefMouseDownColor)
  416. End Sub
  417.  
  418. Private Sub UserControl_Terminate()
  419.     Call UnloadItems
  420. End Sub
  421.  
  422. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  423.     Call PropBag.WriteProperty("SkinPath", v_sSkinPath, App.Path & "\Skins\Titanium")
  424.     Call PropBag.WriteProperty("ForeColor", v_oForeColor, DefForeColor)
  425.     Call PropBag.WriteProperty("MouseMoveColor", v_oMouseMoveColor, DefMouseMoveColor)
  426.     Call PropBag.WriteProperty("MouseDownColor", v_oMouseDownColor, DefMouseDownColor)
  427. End Sub
  428.