home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / U11D_Progr2073356302007.psc / ProgressBar.ctl < prev    next >
Text File  |  2007-06-30  |  30KB  |  1,069 lines

  1. VERSION 5.00
  2. Begin VB.UserControl ProgressBar 
  3.    AutoRedraw      =   -1  'True
  4.    ClientHeight    =   300
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   4425
  8.    ScaleHeight     =   20
  9.    ScaleMode       =   3  'Pixel
  10.    ScaleWidth      =   295
  11.    ToolboxBitmap   =   "ProgressBar.ctx":0000
  12. End
  13. Attribute VB_Name = "ProgressBar"
  14. Attribute VB_GlobalNameSpace = False
  15. Attribute VB_Creatable = True
  16. Attribute VB_PredeclaredId = False
  17. Attribute VB_Exposed = False
  18. Option Explicit
  19.  
  20. Public Enum U_TextAlignments
  21.     [Left Top] = 1
  22.     [Left Middle] = 2
  23.     [Left Bottom] = 3
  24.     [Center Top] = 4
  25.     [Center Middle] = 5
  26.     [Center Bottom] = 6
  27.     [Right Top] = 7
  28.     [Right Middle] = 8
  29.     [Right Bottom] = 9
  30. End Enum
  31.  
  32. Public Enum U_TextEffects
  33.     [Normal] = 1
  34.     [Embossed] = 2
  35.     [Engraved] = 3
  36.     [OutLine] = 4
  37.     [Shadow] = 5
  38. End Enum
  39.  
  40. Public Enum U_OrientationsS
  41.     [Horizontal] = 1
  42.     [Vertical] = 2
  43.  
  44. End Enum
  45.  
  46. Public Enum U_TextStyles
  47.     [PBValue] = 1
  48.     [PBPercentage] = 2
  49.     [CustomText] = 3
  50.     [PBNoneText] = 4
  51. End Enum
  52.  
  53. Private Type BITMAPINFOHEADER
  54.     biSize As Long
  55.     biWidth As Long
  56.     biHeight As Long
  57.     biPlanes As Integer
  58.     biBitCount As Integer
  59.     biCompression As Long
  60.     biSizeImage As Long
  61.     biXPelsPerMeter As Long
  62.     biYPelsPerMeter As Long
  63.     biClrUsed As Long
  64.     biClrImportant As Long
  65. End Type
  66.  
  67. Private Type RGBQUAD
  68.     rgbBlue As Byte
  69.     rgbGreen As Byte
  70.     rgbRed As Byte
  71.     rgbReserved As Byte
  72. End Type
  73.  
  74. Private Type BITMAPINFO
  75.     bmiHeader As BITMAPINFOHEADER
  76.     bmiColors As RGBQUAD
  77. End Type
  78.  
  79. Private Type cRGB
  80.     Blue As Byte
  81.     Green As Byte
  82.     Red As Byte
  83. End Type
  84.  
  85. Enum U_Themes
  86.     [IceOrange] = 1
  87.     [IceYellow] = 2
  88.     [IceGreen] = 3
  89.     [IceCyan] = 4
  90.     [IceBangel] = 5
  91.     [IcePurple] = 6
  92.     [IceRed] = 7
  93.     [IceBlue] = 8
  94.     [Vista] = 9
  95.     [Custome] = 10
  96. End Enum
  97. Private Type GRADIENT_RECT
  98.     UpperLeft As Long
  99.     LowerRight As Long
  100. End Type
  101.  
  102. Public Enum GRADIENT_DIRECT
  103.     [Left to Right] = &H0
  104.     [Top to Bottom] = &H1
  105. End Enum
  106.  
  107. Private Type TRIVERTEX
  108.     X As Long
  109.     Y As Long
  110.     Red As Integer
  111.     Green As Integer
  112.     Blue As Integer
  113.     Alpha As Integer
  114. End Type
  115.  
  116. Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
  117. Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
  118. Private Declare Function RoundRect Lib "gdi32" (ByVal hDC As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
  119. Private Declare Function SetDIBitsToDevice Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, Bits As Any, BitsInfo As BITMAPINFO, ByVal wUsage As Long) As Long
  120. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
  121. Private Declare Function GradientFillRect Lib "msimg32" Alias "GradientFill" (ByVal hDC As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_RECT, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long
  122. Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  123.  
  124. Private Type RECT
  125.         Left As Long
  126.         Top As Long
  127.         Right As Long
  128.         Bottom As Long
  129. End Type
  130.  
  131. Const GRADIENT_FILL_RECT_H As Long = &H0
  132. Const GRADIENT_FILL_RECT_V  As Long = &H1
  133. Private Const BI_RGB = 0&
  134. Private Const DIB_RGB_COLORS = 0
  135.  
  136. Private U_TextStyle As U_TextStyles
  137. Private U_Theme As U_Themes
  138. Private U_Orientation As U_OrientationsS
  139. Private U_Text As String
  140. Private U_TextColor As OLE_COLOR
  141. Private U_TextAlign As U_TextAlignments
  142. Private U_TextFont As Font
  143. Private U_TextEC As OLE_COLOR
  144. Private U_TextEffect As U_TextEffects
  145. Private U_RoundV As Long
  146. Private U_Min As Long
  147. Private U_Value As Long
  148. Private U_Max As Long
  149. Private U_Enabled As Boolean
  150. Private c(16) As Long
  151. Private U_PBSCC1 As OLE_COLOR
  152. Private U_PBSCC2 As OLE_COLOR
  153. Private Sub UserControl_Resize()
  154. Bar_Draw
  155. End Sub
  156.  
  157. Public Property Let Value(ByVal NewValue As Long)
  158. Attribute Value.VB_Description = "Progressbar Value."
  159.     If NewValue > U_Max Then NewValue = U_Max
  160.     If NewValue < U_Min Then NewValue = U_Min
  161.     U_Value = NewValue
  162.     
  163.     PropertyChanged "Value"
  164.     Bar_Draw
  165. End Property
  166.  
  167. Public Property Get Value() As Long
  168.     Value = U_Value
  169. End Property
  170.  
  171. Public Property Let Max(ByVal NewValue As Long)
  172. Attribute Max.VB_Description = "Progressbar Max Value."
  173.     If NewValue < 1 Then NewValue = 1
  174.     If NewValue <= U_Min Then NewValue = U_Min + 1
  175.     U_Max = NewValue
  176.     If Value > U_Max Then Value = U_Max
  177.     PropertyChanged "Max"
  178.     Bar_Draw
  179. End Property
  180. Public Property Get Max() As Long
  181.     Max = U_Max
  182. End Property
  183.  
  184. Public Property Let Min(ByVal NewValue As Long)
  185. Attribute Min.VB_Description = "Progressbar Min Value."
  186.     If NewValue >= U_Max Then NewValue = Max - 1
  187.     If NewValue < 0 Then NewValue = 0
  188.     U_Min = NewValue
  189.     If Value < U_Min Then Value = U_Min
  190.     
  191.     PropertyChanged "Min"
  192.     Bar_Draw
  193. End Property
  194. Public Property Get Min() As Long
  195.     Min = U_Min
  196. End Property
  197. Public Property Get RoundedValue() As Long
  198. Attribute RoundedValue.VB_Description = "Progressbar Rounded Corner Value."
  199. RoundedValue = U_RoundV
  200. End Property
  201.  
  202. Public Property Let RoundedValue(ByVal NewValue As Long)
  203. U_RoundV = NewValue
  204. PropertyChanged "RoundedValue"
  205. Bar_Draw
  206. End Property
  207.  
  208.  
  209. Public Property Get Enabled() As Boolean
  210. Attribute Enabled.VB_Description = "Progressbar Enabled/Disabled."
  211. Enabled = U_Enabled
  212. End Property
  213.  
  214. Public Property Let Enabled(ByVal NewValue As Boolean)
  215. U_Enabled = NewValue
  216. PropertyChanged "Enabled"
  217. Bar_Draw
  218. End Property
  219. Private Sub UserControl_InitProperties()
  220.     Max = 100
  221.     Min = 0
  222.     Value = 50
  223.     RoundedValue = 5
  224.     Enabled = True
  225.     Theme = 1
  226.     TextForeColor = vbBlack
  227.     Text = "U11D ProgressBar"
  228.     TextAlignment = [Center Middle]
  229.     TextEffect = Shadow
  230.     TextEffectColor = vbWhite
  231.     TextStyle = CustomText
  232.     Orientations = Horizontal
  233. Set TextFont = Ambient.Font
  234. End Sub
  235. Public Property Let Theme(ByVal NewValue As U_Themes)
  236. Attribute Theme.VB_Description = "Progressbar Styles."
  237.  
  238.     U_Theme = NewValue
  239.     PropertyChanged "Theme"
  240. Bar_Draw
  241. End Property
  242.  
  243. Public Property Get Theme() As U_Themes
  244.     Theme = U_Theme
  245. End Property
  246.  
  247. Public Property Let TextStyle(ByVal NewValue As U_TextStyles)
  248. Attribute TextStyle.VB_Description = "Progressbar Text Style."
  249.     U_TextStyle = NewValue
  250.     PropertyChanged "TextStyle"
  251. Bar_Draw
  252. End Property
  253. Public Property Get TextStyle() As U_TextStyles
  254.     TextStyle = U_TextStyle
  255. End Property
  256.  
  257.  
  258. Public Property Get Orientations() As U_OrientationsS
  259.     Orientations = U_Orientation
  260. End Property
  261.  
  262. Public Property Let Orientations(ByVal NewValue As U_OrientationsS)
  263.     U_Orientation = NewValue
  264.     PropertyChanged "Orientations"
  265. Bar_Draw
  266. End Property
  267.  
  268. Public Property Get TextAlignment() As U_TextAlignments
  269. Attribute TextAlignment.VB_Description = "Progressbar Text Alignment."
  270. TextAlignment = U_TextAlign
  271. End Property
  272.  
  273. Public Property Let TextAlignment(ByVal NewValue As U_TextAlignments)
  274. U_TextAlign = NewValue
  275. PropertyChanged "TextAlignment"
  276. Bar_Draw
  277. End Property
  278.  
  279. Public Property Get Text() As String
  280. Attribute Text.VB_Description = "Progressbar Text."
  281. Text = U_Text
  282. End Property
  283.  
  284. Public Property Let Text(ByVal NewValue As String)
  285. U_Text = NewValue
  286. PropertyChanged "Text"
  287. Bar_Draw
  288. End Property
  289. Public Property Get TextEffectColor() As OLE_COLOR
  290. Attribute TextEffectColor.VB_Description = "Progressbar Text Effect Color."
  291. TextEffectColor = U_TextEC
  292. End Property
  293.  
  294. Public Property Let TextEffectColor(ByVal NewValue As OLE_COLOR)
  295. U_TextEC = NewValue
  296. PropertyChanged "TextEffectColor"
  297. Bar_Draw
  298. End Property
  299.  
  300. Public Property Get TextEffect() As U_TextEffects
  301. Attribute TextEffect.VB_Description = "Progressbar Text Effect."
  302. TextEffect = U_TextEffect
  303. End Property
  304.  
  305. Public Property Let TextEffect(ByVal NewValue As U_TextEffects)
  306. U_TextEffect = NewValue
  307. PropertyChanged "TextEffect"
  308. Bar_Draw
  309. End Property
  310.  
  311. Public Property Get TextForeColor() As OLE_COLOR
  312. Attribute TextForeColor.VB_Description = "Progressbar Text Color."
  313. TextForeColor = U_TextColor
  314. End Property
  315.  
  316. Public Property Let TextForeColor(ByVal NewValue As OLE_COLOR)
  317. U_TextColor = NewValue
  318. PropertyChanged "TextForeColor"
  319. Bar_Draw
  320. End Property
  321. Public Property Get TextFont() As Font
  322. Attribute TextFont.VB_Description = "Progressbar Text Font."
  323. Set TextFont = U_TextFont
  324. End Property
  325.  
  326. Public Property Set TextFont(ByVal NewValue As Font)
  327. Set U_TextFont = NewValue
  328. Set UserControl.Font = NewValue
  329. PropertyChanged "TextFont"
  330. Bar_Draw
  331. End Property
  332.  
  333. Public Property Get PBSCustomeColor1() As OLE_COLOR
  334. Attribute PBSCustomeColor1.VB_Description = "Progressbar Style Custome Color 1."
  335. PBSCustomeColor1 = U_PBSCC1
  336. End Property
  337.  
  338. Public Property Let PBSCustomeColor1(ByVal NewValue As OLE_COLOR)
  339. U_PBSCC1 = NewValue
  340. PropertyChanged "PBSCustomeColor1"
  341. Bar_Draw
  342. End Property
  343. Public Property Get PBSCustomeColor2() As OLE_COLOR
  344. Attribute PBSCustomeColor2.VB_Description = "Progressbar Style Custome Color 2."
  345. PBSCustomeColor2 = U_PBSCC2
  346. End Property
  347.  
  348. Public Property Let PBSCustomeColor2(ByVal NewValue As OLE_COLOR)
  349. U_PBSCC2 = NewValue
  350. PropertyChanged "PBSCustomeColor2"
  351. Bar_Draw
  352. End Property
  353. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  354.     On Error Resume Next
  355.     With PropBag
  356.     
  357.     Max = .ReadProperty("Max", 100)
  358.     Min = .ReadProperty("Min", 0)
  359.     Value = .ReadProperty("Value", 50)
  360.     RoundedValue = .ReadProperty("RoundedValue", 5)
  361.     Enabled = .ReadProperty("Enabled", True)
  362.     Theme = .ReadProperty("Theme", 1)
  363.     TextStyle = .ReadProperty("TextStyle", 1)
  364.     Orientations = .ReadProperty("Orientations", Horizontal)
  365.     Text = .ReadProperty("Text", Ambient.DisplayName)
  366.     TextEffectColor = .ReadProperty("TextEffectColor", RGB(200, 200, 200))
  367.     TextEffect = .ReadProperty("TextEffect", 1)
  368.     TextAlignment = .ReadProperty("TextAlignment", 5)
  369.     Set TextFont = .ReadProperty("TextFont", Ambient.Font)
  370.     TextForeColor = .ReadProperty("TextForeColor", 0)
  371.     PBSCustomeColor2 = .ReadProperty("PBSCustomeColor2", vbBlack)
  372.     PBSCustomeColor1 = .ReadProperty("PBSCustomeColor1", vbBlack)
  373.     End With
  374. End Sub
  375.  
  376. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  377.     With PropBag
  378.     .WriteProperty "Orientations", U_Orientation, Horizontal
  379.     .WriteProperty "Max", U_Max, 100
  380.     .WriteProperty "Min", U_Min, 0
  381.     .WriteProperty "Value", U_Value, 50
  382.     .WriteProperty "RoundedValue", U_RoundV, 5
  383.     .WriteProperty "Enabled", U_Enabled, True
  384.     .WriteProperty "Theme", U_Theme, 1
  385.     .WriteProperty "TextStyle", U_TextStyle, 1
  386.     .WriteProperty "TextFont", U_TextFont, Ambient.Font
  387.     .WriteProperty "TextForeColor", U_TextColor, vbBlack
  388.     .WriteProperty "TextAlignment", U_TextAlign, 5
  389.     .WriteProperty "Text", U_Text, ""
  390.     .WriteProperty "TextEffectColor", U_TextEC, RGB(200, 200, 200)
  391.     .WriteProperty "TextEffect", U_TextEffect, 1
  392.     .WriteProperty "PBSCustomeColor2", U_PBSCC2, vbBlack
  393.     .WriteProperty "PBSCustomeColor1", U_PBSCC1, vbBlack
  394.     End With
  395. End Sub
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407. Private Sub Bar_Draw()
  408. On Error Resume Next
  409. Dim I, S, z, Y, q As Long
  410. Dim U_LRECT As Long
  411.  
  412. U_LRECT = CreateRoundRectRgn(0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight, U_RoundV, U_RoundV)
  413. SetWindowRgn UserControl.hWnd, U_LRECT, True
  414.  
  415.     I = U_Max: S = U_Value: z = U_Max
  416.     Y = (S * 100 / z)
  417.     q = (Y * UserControl.ScaleWidth / 100)
  418.     
  419. If Orientations = Vertical Then q = (Y * UserControl.ScaleHeight / 100)
  420.  
  421. CheckTheme
  422.  
  423. If Enabled = False Then
  424. Dim II As Byte
  425. For II = 0 To 16
  426.     c(II) = ColourTOGray(c(II))
  427. Next II
  428. End If
  429.  
  430.  
  431. UserControl.Cls
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438. If U_Orientation = Horizontal Then
  439.  
  440.  
  441.  
  442. GradientTwoColour UserControl.hDC, [Top to Bottom], c(0), c(2), 0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight / 2
  443. GradientTwoColour UserControl.hDC, [Top to Bottom], c(4), c(6), 0, UserControl.ScaleHeight / 2, UserControl.ScaleWidth, UserControl.ScaleHeight
  444.  
  445. 'DrawGradientFourColour UserControl.hDC, 0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight / 2, c(0), c(1), c(2), c(3)
  446. 'DrawGradientFourColour UserControl.hDC, 0, UserControl.ScaleHeight / 2, UserControl.ScaleWidth, UserControl.ScaleHeight / 2 - 1, c(4), c(5), c(6), c(7)
  447.  
  448. If Value >= 1 Then
  449.  
  450. GradientTwoColour UserControl.hDC, [Top to Bottom], c(8), c(10), 0, 0, q, UserControl.ScaleHeight / 2
  451. GradientTwoColour UserControl.hDC, [Top to Bottom], c(12), c(14), 0, UserControl.ScaleHeight / 2, q, UserControl.ScaleHeight
  452. 'DrawGradientFourColour UserControl.hDC, 0, 0, q, UserControl.ScaleHeight / 2, c(8), c(9), c(10), c(11)
  453. 'DrawGradientFourColour UserControl.hDC, 0, UserControl.ScaleHeight / 2, q, UserControl.ScaleHeight / 2 - 1, c(12), c(13), c(14), c(15)
  454. End If
  455.  
  456.  
  457.  
  458. ElseIf U_Orientation = Vertical Then
  459.  
  460. GradientTwoColour UserControl.hDC, [Left to Right], c(0), c(2), 0, 0, UserControl.ScaleWidth / 2, UserControl.ScaleHeight
  461. GradientTwoColour UserControl.hDC, [Left to Right], c(4), c(6), UserControl.ScaleWidth / 2, 0, UserControl.ScaleWidth, UserControl.ScaleHeight
  462.  
  463. 'DrawGradientFourColour UserControl.hDC, 0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight / 2, c(0), c(1), c(2), c(3)
  464. 'DrawGradientFourColour UserControl.hDC, 0, UserControl.ScaleHeight / 2, UserControl.ScaleWidth, UserControl.ScaleHeight / 2 - 1, c(4), c(5), c(6), c(7)
  465.  
  466. If Value >= 1 Then
  467.  
  468. GradientTwoColour UserControl.hDC, [Left to Right], c(8), c(10), 0, 0, UserControl.ScaleWidth / 2, q
  469. GradientTwoColour UserControl.hDC, [Left to Right], c(12), c(14), UserControl.ScaleWidth / 2, 0, UserControl.ScaleWidth, q
  470. 'DrawGradientFourColour UserControl.hDC, 0, 0, q, UserControl.ScaleHeight / 2, c(8), c(9), c(10), c(11)
  471. 'DrawGradientFourColour UserControl.hDC, 0, UserControl.ScaleHeight / 2, q, UserControl.ScaleHeight / 2 - 1, c(12), c(13), c(14), c(15)
  472. End If
  473. End If
  474.  
  475.  
  476.  
  477.  
  478. UserControl.ForeColor = c(16)
  479. RoundRect UserControl.hDC, 0, 0, UserControl.ScaleWidth - 1, UserControl.ScaleHeight - 1, U_RoundV, U_RoundV
  480.  
  481. If TextStyle = PBValue Then
  482.     DrawCaptionText Value, U_TextAlign
  483. ElseIf TextStyle = PBPercentage Then
  484.     DrawCaptionText Y & "%", U_TextAlign
  485. ElseIf TextStyle = CustomText Then
  486.     DrawCaptionText U_Text, U_TextAlign
  487. ElseIf TextStyle = PBNoneText Then
  488. End If
  489. End Sub
  490.  
  491. Private Sub CheckTheme()
  492. If Theme = 1 Then
  493. 'BACK
  494. c(0) = RGB(248, 246, 242)
  495. c(1) = RGB(248, 246, 242)
  496. c(2) = RGB(233, 227, 211)
  497. c(3) = RGB(233, 227, 211)
  498. '\
  499. c(4) = RGB(226, 215, 182)
  500. c(5) = RGB(226, 215, 182)
  501. c(6) = RGB(239, 233, 215)
  502. c(7) = RGB(239, 233, 215)
  503. 'FRONT
  504. c(8) = RGB(251, 244, 223)
  505. c(9) = RGB(251, 244, 223)
  506. c(10) = RGB(239, 213, 133)
  507. c(11) = RGB(239, 213, 133)
  508. '\
  509. c(12) = RGB(203, 166, 57)
  510. c(13) = RGB(203, 166, 57)
  511. c(14) = RGB(237, 224, 187)
  512. c(15) = RGB(237, 224, 187)
  513. 'FORE COLOUR
  514. c(16) = RGB(204, 168, 62)
  515. ElseIf Theme = 2 Then
  516. 'BACK
  517. c(0) = RGB(247, 248, 242)
  518. c(1) = RGB(247, 248, 242)
  519. c(2) = RGB(231, 233, 211)
  520. c(3) = RGB(231, 233, 211)
  521. '\
  522. c(4) = RGB(222, 226, 182)
  523. c(5) = RGB(222, 226, 182)
  524. c(6) = RGB(237, 239, 215)
  525. c(7) = RGB(237, 239, 215)
  526. 'FRONT
  527. c(8) = RGB(249, 251, 223)
  528. c(9) = RGB(249, 251, 223)
  529. c(10) = RGB(230, 239, 133)
  530. c(11) = RGB(230, 239, 133)
  531. '\
  532. c(12) = RGB(190, 203, 57)
  533. c(13) = RGB(190, 203, 57)
  534. c(14) = RGB(233, 237, 187)
  535. c(15) = RGB(233, 237, 187)
  536. 'FORE COLOUR
  537. c(16) = RGB(192, 204, 62)
  538. ElseIf Theme = 3 Then
  539. 'BACK
  540. c(0) = RGB(242, 248, 243)
  541. c(1) = RGB(242, 248, 243)
  542. c(2) = RGB(211, 233, 213)
  543. c(3) = RGB(211, 233, 213)
  544. '\
  545. c(4) = RGB(182, 226, 186)
  546. c(5) = RGB(182, 226, 186)
  547. c(6) = RGB(215, 239, 217)
  548. c(7) = RGB(215, 239, 217)
  549. 'FRONT
  550. c(8) = RGB(223, 251, 225)
  551. c(9) = RGB(223, 251, 225)
  552. c(10) = RGB(133, 239, 142)
  553. c(11) = RGB(133, 239, 142)
  554. '\
  555. c(12) = RGB(57, 203, 70)
  556. c(13) = RGB(57, 203, 70)
  557. c(14) = RGB(187, 237, 191)
  558. c(15) = RGB(187, 237, 191)
  559. 'FORE COLOUR
  560. c(16) = RGB(62, 204, 74)
  561. ElseIf Theme = 4 Then
  562. 'BACK
  563. c(0) = RGB(242, 248, 247)
  564. c(1) = RGB(242, 248, 247)
  565. c(2) = RGB(211, 233, 231)
  566. c(3) = RGB(211, 233, 231)
  567. '\
  568. c(4) = RGB(182, 226, 222)
  569. c(5) = RGB(182, 226, 222)
  570. c(6) = RGB(215, 239, 237)
  571. c(7) = RGB(215, 239, 237)
  572. 'FRONT
  573. c(8) = RGB(223, 251, 249)
  574. c(9) = RGB(223, 251, 249)
  575. c(10) = RGB(133, 239, 230)
  576. c(11) = RGB(133, 239, 230)
  577. '\
  578. c(12) = RGB(57, 203, 190)
  579. c(13) = RGB(57, 203, 190)
  580. c(14) = RGB(187, 237, 233)
  581. c(15) = RGB(187, 237, 233)
  582. 'FORE COLOUR
  583. c(16) = RGB(62, 204, 192)
  584. ElseIf Theme = 5 Then
  585. 'BACK
  586. c(0) = RGB(243, 242, 248)
  587. c(1) = RGB(243, 242, 248)
  588. c(2) = RGB(213, 211, 233)
  589. c(3) = RGB(213, 211, 233)
  590. '\
  591. c(4) = RGB(186, 182, 226)
  592. c(5) = RGB(186, 182, 226)
  593. c(6) = RGB(217, 215, 239)
  594. c(7) = RGB(217, 215, 239)
  595. 'FRONT
  596. c(8) = RGB(225, 223, 251)
  597. c(9) = RGB(225, 223, 251)
  598. c(10) = RGB(142, 133, 239)
  599. c(11) = RGB(142, 133, 239)
  600. '\
  601. c(12) = RGB(70, 57, 203)
  602. c(13) = RGB(70, 57, 203)
  603. c(14) = RGB(191, 187, 237)
  604. c(15) = RGB(191, 187, 237)
  605. 'FORE COLOUR
  606. c(16) = RGB(74, 62, 204)
  607. ElseIf Theme = 6 Then
  608. 'BACK
  609. c(0) = RGB(248, 242, 247)
  610. c(1) = RGB(248, 242, 247)
  611. c(2) = RGB(233, 211, 231)
  612. c(3) = RGB(233, 211, 231)
  613. '\
  614. c(4) = RGB(226, 182, 222)
  615. c(5) = RGB(226, 182, 222)
  616. c(6) = RGB(239, 215, 237)
  617. c(7) = RGB(239, 215, 237)
  618. 'FRONT
  619. c(8) = RGB(251, 223, 249)
  620. c(9) = RGB(251, 223, 249)
  621. c(10) = RGB(239, 133, 230)
  622. c(11) = RGB(239, 133, 230)
  623. '\
  624. c(12) = RGB(203, 57, 190)
  625. c(13) = RGB(203, 57, 190)
  626. c(14) = RGB(237, 187, 233)
  627. c(15) = RGB(237, 187, 233)
  628. 'FORE COLOUR
  629. c(16) = RGB(204, 62, 192)
  630. ElseIf Theme = 7 Then
  631. 'BACK
  632. c(0) = RGB(248, 242, 242)
  633. c(1) = RGB(248, 242, 242)
  634. c(2) = RGB(233, 211, 211)
  635. c(3) = RGB(233, 211, 211)
  636. '\
  637. c(4) = RGB(226, 182, 182)
  638. c(5) = RGB(226, 182, 182)
  639. c(6) = RGB(239, 215, 215)
  640. c(7) = RGB(239, 215, 215)
  641. 'FRONT
  642. c(8) = RGB(251, 223, 223)
  643. c(9) = RGB(251, 223, 223)
  644. c(10) = RGB(239, 133, 133)
  645. c(11) = RGB(239, 133, 133)
  646. '\
  647. c(12) = RGB(203, 57, 57)
  648. c(13) = RGB(203, 57, 57)
  649. c(14) = RGB(237, 187, 187)
  650. c(15) = RGB(237, 187, 187)
  651. 'FORE COLOUR
  652. c(16) = RGB(204, 62, 62)
  653. ElseIf Theme = 8 Then
  654. 'BACK
  655. c(0) = RGB(250, 253, 254)
  656. c(1) = RGB(250, 253, 254)
  657. c(2) = RGB(228, 243, 252)
  658. c(3) = RGB(228, 243, 252)
  659. '\
  660. c(4) = RGB(199, 230, 249)
  661. c(5) = RGB(199, 230, 249)
  662. c(6) = RGB(237, 247, 253)
  663. c(7) = RGB(237, 247, 253)
  664. 'FRONT
  665. c(8) = RGB(225, 247, 255)
  666. c(9) = RGB(225, 247, 255)
  667. c(10) = RGB(67, 208, 255)
  668. c(11) = RGB(67, 208, 255)
  669. '\
  670. c(12) = RGB(63, 112, 233)
  671. c(13) = RGB(63, 112, 233)
  672. c(14) = RGB(63, 226, 246)
  673. c(15) = RGB(63, 226, 246)
  674. 'FORE COLOUR
  675. c(16) = RGB(23, 139, 211)
  676. ElseIf Theme = 9 Then
  677. 'BACK
  678. c(0) = RGB(231, 243, 232)
  679. c(1) = RGB(231, 243, 232)
  680. c(2) = RGB(225, 219, 225)
  681. c(3) = RGB(225, 219, 225)
  682. '\
  683. c(4) = RGB(179, 189, 179)
  684. c(5) = RGB(179, 189, 179)
  685. c(6) = RGB(226, 238, 226)
  686. c(7) = RGB(226, 238, 226)
  687. 'FRONT
  688. c(8) = RGB(223, 251, 223)
  689. c(9) = RGB(223, 251, 223)
  690. c(10) = RGB(108, 255, 108)
  691. c(11) = RGB(108, 255, 108)
  692. '\
  693. c(12) = RGB(26, 228, 26)
  694. c(13) = RGB(26, 228, 26)
  695. c(14) = RGB(217, 244, 217)
  696. c(15) = RGB(217, 244, 217)
  697. 'FORE COLOUR
  698. c(16) = RGB(188, 184, 188)
  699. ElseIf Theme = 10 Then
  700.  
  701. 'BACK
  702. c(0) = LightenColor(U_PBSCC2, 180)
  703. c(1) = LightenColor(U_PBSCC2, 180)
  704. c(2) = LightenColor(U_PBSCC2, 50)
  705. c(3) = LightenColor(U_PBSCC2, 50)
  706. '\
  707. c(4) = U_PBSCC2
  708. c(5) = U_PBSCC2
  709. c(6) = LightenColor(U_PBSCC2, 80)
  710. c(7) = LightenColor(U_PBSCC2, 80)
  711. 'FRONT
  712. c(8) = LightenColor(U_PBSCC1, 180)
  713. c(9) = LightenColor(U_PBSCC1, 180)
  714. c(10) = LightenColor(U_PBSCC1, 50)
  715. c(11) = LightenColor(U_PBSCC1, 50)
  716. '\
  717. c(12) = U_PBSCC1
  718. c(13) = U_PBSCC1
  719. c(14) = LightenColor(U_PBSCC1, 80)
  720. c(15) = LightenColor(U_PBSCC1, 80)
  721. 'FORE COLOUR
  722. c(16) = U_PBSCC1
  723. End If
  724. End Sub
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783. Private Sub DrawCaptionText(ByVal TextString As String, ByVal Alignment As U_TextAlignments)
  784. Dim lonStartWidth As Long, lonStartHeight As Long
  785. Dim PBTCN, PBTCS As Long
  786.  
  787. If Enabled = True Then
  788. PBTCN = U_TextColor
  789. PBTCS = U_TextEC
  790. Else
  791. PBTCN = ColourTOGray(U_TextColor)
  792. PBTCS = ColourTOGray(U_TextEC)
  793. End If
  794.  
  795. UserControl.ForeColor = PBTCN
  796.  
  797. If Alignment = 1 Then
  798.     lonStartWidth = 1
  799.     lonStartHeight = 0
  800. ElseIf Alignment = 2 Then
  801.     lonStartWidth = 1
  802.     lonStartHeight = (UserControl.ScaleHeight / 2) - (UserControl.TextHeight(TextString) / 2) - 1
  803. ElseIf Alignment = 3 Then
  804.     lonStartWidth = 1
  805.     lonStartHeight = (UserControl.ScaleHeight - UserControl.TextHeight(TextString)) - 1
  806.  
  807. ElseIf Alignment = 4 Then
  808.     lonStartWidth = (UserControl.ScaleWidth / 2) - (UserControl.TextWidth(TextString) / 2) - 1
  809.     lonStartHeight = 0
  810. ElseIf Alignment = 5 Then
  811.     lonStartWidth = (UserControl.ScaleWidth / 2) - (UserControl.TextWidth(TextString) / 2) - 1
  812.     lonStartHeight = (UserControl.ScaleHeight / 2) - (UserControl.TextHeight(TextString) / 2) - 1
  813. ElseIf Alignment = 6 Then
  814.     lonStartWidth = (UserControl.ScaleWidth / 2) - (UserControl.TextWidth(TextString) / 2) - 1
  815.     lonStartHeight = (UserControl.ScaleHeight - UserControl.TextHeight(TextString)) - 1
  816.  
  817.  
  818. ElseIf Alignment = 7 Then
  819.     lonStartWidth = (UserControl.ScaleWidth - UserControl.TextWidth(TextString)) - 3
  820.     lonStartHeight = 0
  821. ElseIf Alignment = 8 Then
  822.     lonStartWidth = (UserControl.ScaleWidth - UserControl.TextWidth(TextString)) - 3
  823.     lonStartHeight = (UserControl.ScaleHeight / 2) - (UserControl.TextHeight(TextString) / 2) - 1
  824. ElseIf Alignment = 9 Then
  825.     lonStartWidth = (UserControl.ScaleWidth - UserControl.TextWidth(TextString)) - 3
  826.     lonStartHeight = (UserControl.ScaleHeight - UserControl.TextHeight(TextString)) - 1
  827. End If
  828.  
  829.  
  830.  
  831.     If U_TextEffect = Normal Then
  832.         UserControl.CurrentX = lonStartWidth
  833.         UserControl.CurrentY = lonStartHeight
  834.         UserControl.Print TextString
  835.     ElseIf U_TextEffect = Engraved Then
  836.         UserControl.ForeColor = PBTCS
  837.         UserControl.CurrentX = lonStartWidth + 1
  838.         UserControl.CurrentY = lonStartHeight + 1
  839.         UserControl.Print TextString
  840.         UserControl.ForeColor = RGB(128, 128, 128)
  841.         UserControl.CurrentX = lonStartWidth - 1
  842.         UserControl.CurrentY = lonStartHeight
  843.         UserControl.Print TextString
  844.         UserControl.ForeColor = PBTCN
  845.         UserControl.CurrentX = lonStartWidth
  846.         UserControl.CurrentY = lonStartHeight
  847.         UserControl.Print TextString
  848.         
  849.     ElseIf U_TextEffect = Embossed Then
  850.         UserControl.ForeColor = PBTCS
  851.         UserControl.CurrentX = lonStartWidth - 1
  852.         UserControl.CurrentY = lonStartHeight - 1
  853.         UserControl.Print TextString
  854.         UserControl.ForeColor = RGB(128, 128, 128)
  855.         UserControl.CurrentX = lonStartWidth + 1
  856.         UserControl.CurrentY = lonStartHeight + 1
  857.         UserControl.Print TextString
  858.         UserControl.ForeColor = PBTCN
  859.         UserControl.CurrentX = lonStartWidth
  860.         UserControl.CurrentY = lonStartHeight
  861.         UserControl.Print TextString
  862.     ElseIf U_TextEffect = OutLine Then
  863.         UserControl.ForeColor = PBTCS
  864.         UserControl.CurrentX = lonStartWidth + 1
  865.         UserControl.CurrentY = lonStartHeight
  866.         UserControl.Print TextString
  867.         UserControl.CurrentX = lonStartWidth - 1
  868.         UserControl.CurrentY = lonStartHeight
  869.         UserControl.Print TextString
  870.         UserControl.CurrentY = lonStartHeight - 1
  871.         UserControl.CurrentX = lonStartWidth
  872.         UserControl.Print TextString
  873.         UserControl.CurrentY = lonStartHeight + 1
  874.         UserControl.CurrentX = lonStartWidth
  875.         UserControl.Print TextString
  876.         UserControl.ForeColor = PBTCN
  877.         UserControl.CurrentX = lonStartWidth
  878.         UserControl.CurrentY = lonStartHeight
  879.         UserControl.Print TextString
  880.         
  881.     ElseIf U_TextEffect = Shadow Then
  882.         UserControl.ForeColor = PBTCS
  883.         UserControl.CurrentX = lonStartWidth + 1
  884.         UserControl.CurrentY = lonStartHeight + 1
  885.         UserControl.Print TextString
  886.         UserControl.ForeColor = PBTCN
  887.         UserControl.CurrentX = lonStartWidth
  888.         UserControl.CurrentY = lonStartHeight
  889.         UserControl.Print TextString
  890.     End If
  891.  
  892.  
  893. End Sub
  894.  
  895. Public Function DrawGradientFourColour(ObjectHDC As Long, Left As Long, Top As Long, Width As Long, Height As Long, TopLeftColour As Long, TopRightColour As Long, BottomLeftColour As Long, BottomRightColour As Long)
  896.     Dim bi24BitInfo     As BITMAPINFO
  897.     Dim bBytes()        As Byte
  898.     Dim LeftGrads()     As cRGB
  899.     Dim RightGrads()    As cRGB
  900.     Dim MiddleGrads()   As cRGB
  901.     Dim TopLeft         As cRGB
  902.     Dim TopRight        As cRGB
  903.     Dim BottomLeft      As cRGB
  904.     Dim BottomRight     As cRGB
  905.     Dim iLoop           As Long
  906.     Dim bytesWidth      As Long
  907.     
  908.     With TopLeft
  909.         .Red = Red(TopLeftColour)
  910.         .Green = Green(TopLeftColour)
  911.         .Blue = Blue(TopLeftColour)
  912.     End With
  913.     
  914.     With TopRight
  915.         .Red = Red(TopRightColour)
  916.         .Green = Green(TopRightColour)
  917.         .Blue = Blue(TopRightColour)
  918.     End With
  919.     
  920.     With BottomLeft
  921.         .Red = Red(BottomLeftColour)
  922.         .Green = Green(BottomLeftColour)
  923.         .Blue = Blue(BottomLeftColour)
  924.     End With
  925.     
  926.     With BottomRight
  927.         .Red = Red(BottomRightColour)
  928.         .Green = Green(BottomRightColour)
  929.         .Blue = Blue(BottomRightColour)
  930.     End With
  931.     
  932.     GradateColours LeftGrads, Height, TopLeft, BottomLeft
  933.     GradateColours RightGrads, Height, TopRight, BottomRight
  934.     
  935.     With bi24BitInfo.bmiHeader
  936.         .biBitCount = 24
  937.         .biCompression = BI_RGB
  938.         .biPlanes = 1
  939.         .biSize = Len(bi24BitInfo.bmiHeader)
  940.         .biWidth = Width
  941.         .biHeight = 1
  942.     End With
  943.     
  944.     ReDim bBytes(1 To bi24BitInfo.bmiHeader.biWidth * bi24BitInfo.bmiHeader.biHeight * 3) As Byte
  945.     
  946.     bytesWidth = (Width) * 3
  947.     
  948.     For iLoop = 0 To Height - 1
  949.         GradateColours MiddleGrads, Width, LeftGrads(iLoop), RightGrads(iLoop)
  950.         CopyMemory bBytes(1), MiddleGrads(0), bytesWidth
  951.         SetDIBitsToDevice ObjectHDC, Left, Top + iLoop, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, 0, 0, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
  952.     Next iLoop
  953.     
  954.     
  955. End Function
  956.  
  957. Private Function GradateColours(cResults() As cRGB, Length As Long, Colour1 As cRGB, Colour2 As cRGB)
  958.     Dim fromR   As Integer
  959.     Dim toR     As Integer
  960.     Dim fromG   As Integer
  961.     Dim toG     As Integer
  962.     Dim fromB   As Integer
  963.     Dim toB     As Integer
  964.     Dim stepR   As Single
  965.     Dim stepG   As Single
  966.     Dim stepB   As Single
  967.     Dim iLoop   As Long
  968.     
  969.     ReDim cResults(0 To Length)
  970.     
  971.     fromR = Colour1.Red
  972.     fromG = Colour1.Green
  973.     fromB = Colour1.Blue
  974.     
  975.     toR = Colour2.Red
  976.     toG = Colour2.Green
  977.     toB = Colour2.Blue
  978.     
  979.     stepR = Divide(toR - fromR, Length)
  980.     stepG = Divide(toG - fromG, Length)
  981.     stepB = Divide(toB - fromB, Length)
  982.     
  983.     For iLoop = 0 To Length
  984.         cResults(iLoop).Red = fromR + (stepR * iLoop)
  985.         cResults(iLoop).Green = fromG + (stepG * iLoop)
  986.         cResults(iLoop).Blue = fromB + (stepB * iLoop)
  987.     Next iLoop
  988. End Function
  989.  
  990. Private Function Blue(Colour As Long) As Long
  991.     Blue = (Colour And &HFF0000) / &H10000
  992. End Function
  993. Private Function Green(Colour As Long) As Long
  994.     Green = (Colour And &HFF00&) / &H100
  995. End Function
  996.  
  997. Private Function Red(Colour As Long) As Long
  998.     Red = (Colour And &HFF&)
  999. End Function
  1000.  
  1001. Private Function Divide(Numerator, Denominator) As Single
  1002.     If Numerator = 0 Or Denominator = 0 Then
  1003.         Divide = 0
  1004.     Else
  1005.         Divide = Numerator / Denominator
  1006.     End If
  1007. End Function
  1008. Public Sub GradientTwoColour(ByVal hDC As Long, ByVal Direction As GRADIENT_DIRECT, ByVal StartColor As Long, ByVal EndColor As Long, Left As Long, Top As Long, Width As Long, Height As Long)
  1009. Dim udtVert(1) As TRIVERTEX, udtGRect As GRADIENT_RECT
  1010. Dim UDTRECT As RECT
  1011. 'hDCObj.ScaleMode = vbPixels
  1012. 'hDCObj.AutoRedraw = True
  1013. SetRect UDTRECT, Left, Top, Width, Height
  1014. With udtVert(0)
  1015.     .X = UDTRECT.Left
  1016.     .Y = UDTRECT.Top
  1017.     .Red = LongToSignedShort(CLng((StartColor And &HFF&) * 256))
  1018.     .Green = LongToSignedShort(CLng(((StartColor And &HFF00&) \ &H100&) * 256))
  1019.     .Blue = LongToSignedShort(CLng(((StartColor And &HFF0000) \ &H10000) * 256))
  1020.     .Alpha = 0&
  1021. End With
  1022.  
  1023. With udtVert(1)
  1024.     .X = UDTRECT.Right
  1025.     .Y = UDTRECT.Bottom
  1026.     .Red = LongToSignedShort(CLng((EndColor And &HFF&) * 256))
  1027.     .Green = LongToSignedShort(CLng(((EndColor And &HFF00&) \ &H100&) * 256))
  1028.     .Blue = LongToSignedShort(CLng(((EndColor And &HFF0000) \ &H10000) * 256))
  1029.     .Alpha = 0&
  1030. End With
  1031.  
  1032. udtGRect.UpperLeft = 0
  1033. udtGRect.LowerRight = 1
  1034.  
  1035. GradientFillRect hDC, udtVert(0), 2, udtGRect, 1, Direction
  1036. End Sub
  1037.  
  1038.  
  1039. Private Function LongToSignedShort(ByVal Unsigned As Long) As Integer
  1040. If Unsigned < 32768 Then
  1041.     LongToSignedShort = CInt(Unsigned)
  1042. Else
  1043.     LongToSignedShort = CInt(Unsigned - &H10000)
  1044. End If
  1045. End Function
  1046.  
  1047.  
  1048. Private Function ColourTOGray(ByVal uColor As Long) As Long
  1049. Dim Red As Long, Blue As Long, Green As Long
  1050. Dim gray As Long
  1051.     Red = uColor Mod 256
  1052.     Green = (uColor Mod 65536) / 256
  1053.     Blue = uColor / 65536
  1054.     gray = (Red + Green + Blue) / 3
  1055.     ColourTOGray = RGB(gray, gray, gray)
  1056. End Function
  1057. Private Function LightenColor(ByVal uColour As ColorConstants, Optional ByVal OffSet As Long = 1) As Long
  1058. Dim intR As Integer, intG As Integer, intB As Integer
  1059. intR = Abs((uColour Mod 256) + OffSet)
  1060. intG = Abs((((uColour And &HFF00) / 256&) Mod 256&) + OffSet)
  1061. intB = Abs(((uColour And &HFF0000) / 65536) + OffSet)
  1062.  
  1063. LightenColor = RGB(intR, intG, intB)
  1064. End Function
  1065. Public Sub About()
  1066. Attribute About.VB_UserMemId = -552
  1067. FrmAbout.Show
  1068. End Sub
  1069.