home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / ucStatusBa2079018102007.psc / Controls / ucProgressBar.ctl
Text File  |  2007-08-10  |  54KB  |  999 lines

  1. VERSION 5.00
  2. Begin VB.UserControl ucProgressBar 
  3.    ClientHeight    =   990
  4.    ClientLeft      =   0
  5.    ClientTop       =   0
  6.    ClientWidth     =   3000
  7.    ScaleHeight     =   990
  8.    ScaleWidth      =   3000
  9.    ToolboxBitmap   =   "ucProgressBar.ctx":0000
  10. End
  11. Attribute VB_Name = "ucProgressBar"
  12. Attribute VB_GlobalNameSpace = False
  13. Attribute VB_Creatable = True
  14. Attribute VB_PredeclaredId = False
  15. Attribute VB_Exposed = False
  16. '+  File Description:
  17. '       ucProgressBar - A Selfsubclassed Theme Aware ProgressBar Control which Provides Dynamic Properties
  18. '
  19. '   Product Name:
  20. '       ucProgressBar.ctl
  21. '
  22. '   Compatability:
  23. '       Widnows: 9x, ME, NT, 2K, XP
  24. '
  25. '   Software Developed by:
  26. '       Paul R. Territo, Ph.D
  27. '
  28. '   Based on the following On-Line Articles
  29. '       (Paul Caton - Self-Subclassser)
  30. '           http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=54117&lngWId=1
  31. '       (Mario Flores - Cool XP ProgressBar 2.0)
  32. '           http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=56151&lngWId=1
  33. '       (Randy Birch - IsWinXP)
  34. '           http://vbnet.mvps.org/code/system/getversionex.htm
  35. '
  36. '   Legal Copyright & Trademarks:
  37. '       Copyright ⌐ 2006-2007, by Paul R. Territo, Ph.D, All Rights Reserved Worldwide
  38. '       Trademark Ö 2006-2007, by Paul R. Territo, Ph.D, All Rights Reserved Worldwide
  39. '
  40. '   Comments:
  41. '       No claims or warranties are expressed or implied as to accuracy or fitness
  42. '       for use of this software. Advance Research Systems shall not be liable for
  43. '       any incidental or consequential damages suffered by any use of this software.
  44. '       This software is owned by Paul R. Territo, Ph.D and is sold for use as a
  45. '       license in accordance with the terms of the License Agreement in the
  46. '       accompanying the documentation.
  47. '
  48. '   Contact Information:
  49. '       For Technical Assistance:
  50. '       pwterrito@insightbb.com
  51. '
  52. '-  Modification(s) History:
  53. '
  54. '       25May06 - Initial Usercontrol Build (Modified from Mario Flores Cool XP ProgressBar 2.0)
  55. '               - Added IsWinXP Method to handle non XP OS
  56. '               - Added Classic ScrollBar Style
  57. '               - Added Theme Support to allow Auto Selection
  58. '
  59. '   Build Date & Time: 6/25/2006 10:12:36 PM
  60. Const Major As Long = 2
  61. Const Minor As Long = 1
  62. Const Revision As Long = 32
  63. Const DateTime As String = "6/25/2006 10:12:36 PM "
  64. '
  65. '   Force Declarations
  66. Option Explicit
  67.  
  68. 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
  69. Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
  70. Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
  71. Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Any) As Long
  72. Private Declare Function CreateHatchBrush Lib "gdi32" (ByVal fnStyle As Integer, ByVal COLORREF As Long) As Long
  73. Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
  74. Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
  75. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
  76. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  77. Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
  78. Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hDC As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
  79. Private Declare Function DrawEdge Lib "user32" (ByVal hDC As Long, qrc As RECT, ByVal Edge As Long, ByVal grfFlags As Long) As Long
  80. Private Declare Function FillRect Lib "user32" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  81. Private Declare Function FrameRect Lib "user32" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  82. Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  83. Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
  84. Private Declare Function InflateRect Lib "user32" (lpRect As RECT, ByVal X As Long, ByVal Y As Long) As Long
  85. Private Declare Function LineTo Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
  86. Private Declare Function MoveToEx Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long
  87. Private Declare Function OleTranslateColor Lib "OLEPRO32.DLL" (ByVal OLE_COLOR As Long, ByVal HPALETTE As Long, pccolorref As Long) As Long
  88. Private Declare Function PatBlt Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
  89. Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
  90. Private Declare Function SetBkColor Lib "gdi32" (ByVal hDC As Long, ByVal crColor As Long) As Long
  91. Private Declare Function SetBkMode Lib "gdi32" (ByVal hDC As Long, ByVal nBkMode As Long) As Long
  92. Private Declare Function SetPixelV Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
  93. Private Declare Function SetTextColor Lib "gdi32" (ByVal hDC As Long, ByVal crColor As Long) As Long
  94. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As Any) As Long
  95. Private Declare Function GetCurrentThemeName Lib "uxtheme.dll" (ByVal pszThemeFileName As String, ByVal dwMaxNameChars As Integer, ByVal pszColorBuff As String, ByVal cchMaxColorChars As Integer, ByVal pszSizeBuff As String, ByVal cchMaxSizeChars As Integer) As Long
  96.  
  97. Private Type OSVERSIONINFO
  98.   OSVSize         As Long         'size, in bytes, of this data structure
  99.   dwVerMajor      As Long         'ie NT 3.51, dwVerMajor = 3; NT 4.0, dwVerMajor = 4.
  100.   dwVerMinor      As Long         'ie NT 3.51, dwVerMinor = 51; NT 4.0, dwVerMinor= 0.
  101.   dwBuildNumber   As Long         'NT: build number of the OS
  102.                                   'Win9x: build number of the OS in low-order word.
  103.                                   '       High-order word contains major & minor ver nos.
  104.   PlatformID      As Long         'Identifies the operating system platform.
  105.   szCSDVersion    As String * 128 'NT: string, such as "Service Pack 3"
  106.                                   'Win9x: string providing arbitrary additional information
  107. End Type
  108.  
  109. Private Const VER_PLATFORM_WIN32_NT = 2
  110.  
  111. Public Enum upbThemeEnum
  112.     [upbAuto] = &H0
  113.     [upbClassic] = &H1
  114.     [upbBlue] = &H2
  115.     [upbHomeStead] = &H3
  116.     [upbMetallic] = &H4
  117. End Enum
  118.  
  119. '=====================================================
  120. 'TEXT FORMAT CONST
  121. Const DT_SINGLELINE   As Long = &H20
  122. Const DT_CALCRECT     As Long = &H400
  123. '=====================================================
  124.  
  125. '=====================================================
  126. 'BORDER FIELD CONST
  127. Const BF_BOTTOM = &H8
  128. Const BF_LEFT = &H1
  129. Const BF_RIGHT = &H4
  130. Const BF_TOP = &H2
  131. Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
  132. '=====================================================
  133.  
  134. '=====================================================
  135. 'THE POINTAPI STRUCTURE
  136. Private Type POINTAPI
  137.     X As Long                       ' The POINTAPI structure defines the x- and y-coordinates of a point.
  138.     Y As Long
  139. End Type
  140. '=====================================================
  141.  
  142. '=====================================================
  143. 'THE RECT STRUCTURE
  144. Private Type RECT
  145.     Left      As Long     'The RECT structure defines the coordinates of the upper-left and lower-right corners of a rectangle
  146.     Top       As Long
  147.     Right     As Long
  148.     Bottom    As Long
  149. End Type
  150. '=====================================================
  151.  
  152. '=====================================================
  153. 'THE BRUSHSTYLE ENUM
  154. Public Enum BrushStyle
  155.     HS_HORIZONTAL = 0
  156.     HS_VERTICAL = 1
  157.     HS_FDIAGONAL = 2
  158.     HS_BDIAGONAL = 3
  159.     HS_CROSS = 4
  160.     HS_DIAGCROSS = 5
  161.     HS_SOLID = 6
  162. End Enum
  163. '=====================================================
  164.  
  165. '=====================================================
  166. 'THE COOL XP PROGRESSBAR 2.0 STYLES
  167. Public Enum cScrolling
  168.     ccScrollingStandard = 0
  169.     ccScrollingSmooth = 1
  170.     ccScrollingSearch = 2
  171.     ccScrollingOfficeXP = 3
  172.     ccScrollingPastel = 4
  173.     ccScrollingJavT = 5
  174.     ccScrollingMediaPlayer = 6
  175.     ccScrollingCustomBrush = 7
  176.     ccScrollingPicture = 8
  177.     ccScrollingMetallic = 9
  178.     ccScrollingClassic = 10
  179. End Enum
  180. '=====================================================
  181.  
  182. '=====================================================
  183. 'THE ORIENTATION ENUM
  184. Public Enum cOrientation
  185.     ccOrientationHorizontal = 0
  186.     ccOrientationVertical = 1
  187. End Enum
  188. '=====================================================
  189.  
  190. '----------------------------------------------------
  191. Private m_Color       As OLE_COLOR
  192. Private m_hDC         As Long
  193. Private m_hWnd        As Long        'PROPERTIES VARIABLES
  194. Private m_Max         As Long
  195. Private m_Min         As Long
  196. Private m_Value       As Long
  197. Private m_ShowText    As Boolean
  198. Private m_Scrolling   As cScrolling
  199. Private m_Orientation As cOrientation
  200. Private m_Brush       As BrushStyle
  201. Private m_Picture     As StdPicture
  202. Private m_Theme       As upbThemeEnum
  203. '----------------------------------------------------
  204.  
  205. '----------------------------------------------------
  206. Private m_MemDC    As Boolean
  207. Private m_ThDC     As Long
  208. Private m_hBmp     As Long
  209. Private m_hBmpOld  As Long
  210. Private iFnt       As IFont
  211. Private m_fnt      As IFont          'VARIABLES USED IN PROCESS
  212. Private hFntOld    As Long
  213. Private m_lWidth   As Long
  214. Private m_lHeight  As Long
  215. Private fPercent   As Double
  216. Private tR         As RECT
  217. Private TBR        As RECT
  218. Private TSR        As RECT
  219. Private AT         As RECT
  220. Private lSegmentWidth   As Long
  221. Private lSegmentSpacing As Long
  222.  
  223. '==================================================================================================
  224. ' ucSubclass - A template UserControl for control authors that require self-subclassing without ANY
  225. '              external dependencies. IDE safe.
  226. '
  227. ' Paul_Caton@hotmail.com
  228. ' Copyright free, use and abuse as you see fit.
  229. '
  230. ' v1.0.0000 20040525 First cut.....................................................................
  231. ' v1.1.0000 20040602 Multi-subclassing version.....................................................
  232. ' v1.1.0001 20040604 Optimized the subclass code...................................................
  233. ' v1.1.0002 20040607 Substituted byte arrays for strings for the code buffers......................
  234. ' v1.1.0003 20040618 Re-patch when adding extra hWnds..............................................
  235. ' v1.1.0004 20040619 Optimized to death version....................................................
  236. ' v1.1.0005 20040620 Use allocated memory for code buffers, no need to re-patch....................
  237. ' v1.1.0006 20040628 Better protection in zIdx, improved comments..................................
  238. ' v1.1.0007 20040629 Fixed InIDE patching oops.....................................................
  239. ' v1.1.0008 20040910 Fixed bug in UserControl_Terminate, zSubclass_Proc procedure hidden...........
  240. '==================================================================================================
  241. 'Subclasser declarations
  242.  
  243. Public Event MouseEnter()
  244. Public Event MouseLeave()
  245. Public Event Status(ByVal sStatus As String)
  246.  
  247. Private Const WM_EXITSIZEMOVE           As Long = &H232
  248. Private Const WM_LBUTTONDOWN            As Long = &H201
  249. Private Const WM_LBUTTONUP              As Long = &H202
  250. Private Const WM_MOUSELEAVE             As Long = &H2A3
  251. Private Const WM_MOUSEMOVE              As Long = &H200
  252. Private Const WM_MOVING                 As Long = &H216
  253. Private Const WM_RBUTTONDBLCLK          As Long = &H206
  254. Private Const WM_RBUTTONDOWN            As Long = &H204
  255. Private Const WM_SIZING                 As Long = &H214
  256. Private Const WM_SYSCOLORCHANGE         As Long = &H15
  257. Private Const WM_THEMECHANGED           As Long = &H31A
  258. Private Const WM_USER                   As Long = &H400
  259.  
  260. Private Enum TRACKMOUSEEVENT_FLAGS
  261.   TME_HOVER = &H1&
  262.   TME_LEAVE = &H2&
  263.   TME_QUERY = &H40000000
  264.   TME_CANCEL = &H80000000
  265. End Enum
  266.  
  267. Private Type TRACKMOUSEEVENT_STRUCT
  268.   cbSize                             As Long
  269.   dwFlags                            As TRACKMOUSEEVENT_FLAGS
  270.   hwndTrack                          As Long
  271.   dwHoverTime                        As Long
  272. End Type
  273.  
  274. Private bTrack                       As Boolean
  275. Private bTrackUser32                 As Boolean
  276. Private bInCtrl                      As Boolean
  277. Private bSubClass                    As Boolean
  278.  
  279. Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
  280. Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As String) As Long
  281. Private Declare Function TrackMouseEvent Lib "user32" (lpEventTrack As TRACKMOUSEEVENT_STRUCT) As Long
  282. Private Declare Function TrackMouseEventComCtl Lib "Comctl32" Alias "_TrackMouseEvent" (lpEventTrack As TRACKMOUSEEVENT_STRUCT) As Long
  283.  
  284. Private Enum eMsgWhen
  285.     MSG_AFTER = 1                                                                   'Message calls back after the original (previous) WndProc
  286.     MSG_BEFORE = 2                                                                  'Message calls back before the original (previous) WndProc
  287.     MSG_BEFORE_AND_AFTER = MSG_AFTER Or MSG_BEFORE                                  'Message calls back before and after the original (previous) WndProc
  288. End Enum
  289.  
  290. Private Const ALL_MESSAGES           As Long = -1                                   'All messages added or deleted
  291. Private Const GMEM_FIXED             As Long = 0                                    'Fixed memory GlobalAlloc flag
  292. Private Const GWL_WNDPROC            As Long = -4                                   'Get/SetWindow offset to the WndProc procedure address
  293. Private Const PATCH_04               As Long = 88                                   'Table B (before) address patch offset
  294. Private Const PATCH_05               As Long = 93                                   'Table B (before) entry count patch offset
  295. Private Const PATCH_08               As Long = 132                                  'Table A (after) address patch offset
  296. Private Const PATCH_09               As Long = 137                                  'Table A (after) entry count patch offset
  297.  
  298. Private Type tSubData                                                               'Subclass data type
  299.     hwnd                               As Long                                      'Handle of the window being subclassed
  300.     nAddrSub                           As Long                                      'The address of our new WndProc (allocated memory).
  301.     nAddrOrig                          As Long                                      'The address of the pre-existing WndProc
  302.     nMsgCntA                           As Long                                      'Msg after table entry count
  303.     nMsgCntB                           As Long                                      'Msg before table entry count
  304.     aMsgTblA()                         As Long                                      'Msg after table array
  305.     aMsgTblB()                         As Long                                      'Msg Before table array
  306. End Type
  307.  
  308. Private sc_aSubData()                As tSubData                                    'Subclass data array
  309.  
  310. Private Declare Sub RtlMoveMemory Lib "kernel32" (Destination As Any, Source As Any, ByVal Length As Long)
  311. Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long
  312. Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
  313. Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
  314. Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
  315. Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  316.  
  317. '======================================================================================================
  318. 'Subclass handler - MUST be the first Public routine in this file. That includes public properties also
  319. Public Sub zSubclass_Proc(ByVal bBefore As Boolean, ByRef bHandled As Boolean, ByRef lReturn As Long, ByRef lng_hWnd As Long, ByRef uMsg As Long, ByRef wParam As Long, ByRef lParam As Long)
  320.     'Parameters:
  321.         'bBefore  - Indicates whether the the message is being processed before or after the default handler - only really needed if a message is set to callback both before & after.
  322.         'bHandled - Set this variable to True in a 'before' callback to prevent the message being subsequently processed by the default handler... and if set, an 'after' callback
  323.         'lReturn  - Set this variable as per your intentions and requirements, see the MSDN documentation for each individual message value.
  324.         'hWnd     - The window handle
  325.         'uMsg     - The message number
  326.         'wParam   - Message related data
  327.         'lParam   - Message related data
  328.     'Notes:
  329.         'If you really know what you're doing, it's possible to change the values of the
  330.         'hWnd, uMsg, wParam and lParam parameters in a 'before' callback so that different
  331.         'values get passed to the default handler.. and optionaly, the 'after' callback
  332.     Static bMoving As Boolean
  333.    
  334.     Select Case uMsg
  335.         Case WM_SYSCOLORCHANGE
  336.             Refresh
  337.         
  338.         Case WM_THEMECHANGED
  339.             Refresh
  340.             
  341.     End Select
  342.     
  343. End Sub
  344.  
  345. '======================================================================================================
  346. 'Subclass code - The programmer may call any of the following Subclass_??? routines
  347.  
  348.     'Add a message to the table of those that will invoke a callback. You should Subclass_Subclass first and then add the messages
  349. Private Sub Subclass_AddMsg(ByVal lng_hWnd As Long, ByVal uMsg As Long, Optional ByVal When As eMsgWhen = MSG_AFTER)
  350.     'Parameters:
  351.         'lng_hWnd  - The handle of the window for which the uMsg is to be added to the callback table
  352.         'uMsg      - The message number that will invoke a callback. NB Can also be ALL_MESSAGES, ie all messages will callback
  353.         'When      - Whether the msg is to callback before, after or both with respect to the the default (previous) handler
  354.     With sc_aSubData(zIdx(lng_hWnd))
  355.         If When And eMsgWhen.MSG_BEFORE Then
  356.             Call zAddMsg(uMsg, .aMsgTblB, .nMsgCntB, eMsgWhen.MSG_BEFORE, .nAddrSub)
  357.         End If
  358.         If When And eMsgWhen.MSG_AFTER Then
  359.             Call zAddMsg(uMsg, .aMsgTblA, .nMsgCntA, eMsgWhen.MSG_AFTER, .nAddrSub)
  360.         End If
  361.     End With
  362. End Sub
  363.  
  364. 'Delete a message from the table of those that will invoke a callback.
  365. Private Sub Subclass_DelMsg(ByVal lng_hWnd As Long, ByVal uMsg As Long, Optional ByVal When As eMsgWhen = MSG_AFTER)
  366.     'Parameters:
  367.     'lng_hWnd  - The handle of the window for which the uMsg is to be removed from the callback table
  368.     'uMsg      - The message number that will be removed from the callback table. NB Can also be ALL_MESSAGES, ie all messages will callback
  369.     'When      - Whether the msg is to be removed from the before, after or both callback tables
  370.     With sc_aSubData(zIdx(lng_hWnd))
  371.         If When And eMsgWhen.MSG_BEFORE Then
  372.             Call zDelMsg(uMsg, .aMsgTblB, .nMsgCntB, eMsgWhen.MSG_BEFORE, .nAddrSub)
  373.         End If
  374.         If When And eMsgWhen.MSG_AFTER Then
  375.             Call zDelMsg(uMsg, .aMsgTblA, .nMsgCntA, eMsgWhen.MSG_AFTER, .nAddrSub)
  376.         End If
  377.     End With
  378. End Sub
  379.  
  380. 'Return whether we're running in the IDE.
  381. Private Function Subclass_InIDE() As Boolean
  382.     Debug.Assert zSetTrue(Subclass_InIDE)
  383. End Function
  384.  
  385. 'Start subclassing the passed window handle
  386. Private Function Subclass_Start(ByVal lng_hWnd As Long) As Long
  387.     'Parameters:
  388.     'lng_hWnd  - The handle of the window to be subclassed
  389.     'Returns;
  390.     'The sc_aSubData() index
  391.     Const CODE_LEN              As Long = 204                                       'Length of the machine code in bytes
  392.     Const FUNC_CWP              As String = "CallWindowProcA"                       'We use CallWindowProc to call the original WndProc
  393.     Const FUNC_EBM              As String = "EbMode"                                'VBA's EbMode function allows the machine code thunk to know if the IDE has stopped or is on a breakpoint
  394.     Const FUNC_SWL              As String = "SetWindowLongA"                        'SetWindowLongA allows the cSubclasser machine code thunk to unsubclass the subclasser itself if it detects via the EbMode function that the IDE has stopped
  395.     Const MOD_USER              As String = "user32"                                'Location of the SetWindowLongA & CallWindowProc functions
  396.     Const MOD_VBA5              As String = "vba5"                                  'Location of the EbMode function if running VB5
  397.     Const MOD_VBA6              As String = "vba6"                                  'Location of the EbMode function if running VB6
  398.     Const PATCH_01              As Long = 18                                        'Code buffer offset to the location of the relative address to EbMode
  399.     Const PATCH_02              As Long = 68                                        'Address of the previous WndProc
  400.     Const PATCH_03              As Long = 78                                        'Relative address of SetWindowsLong
  401.     Const PATCH_06              As Long = 116                                       'Address of the previous WndProc
  402.     Const PATCH_07              As Long = 121                                       'Relative address of CallWindowProc
  403.     Const PATCH_0A              As Long = 186                                       'Address of the owner object
  404.     Static aBuf(1 To CODE_LEN)  As Byte                                             'Static code buffer byte array
  405.     Static pCWP                 As Long                                             'Address of the CallWindowsProc
  406.     Static pEbMode              As Long                                             'Address of the EbMode IDE break/stop/running function
  407.     Static pSWL                 As Long                                             'Address of the SetWindowsLong function
  408.     Dim i                       As Long                                             'Loop index
  409.     Dim j                       As Long                                             'Loop index
  410.     Dim nSubIdx                 As Long                                             'Subclass data index
  411.     Dim sHex                    As String                                           'Hex code string
  412.     
  413.     'If it's the first time through here..
  414.     If aBuf(1) = 0 Then
  415.         
  416.         'The hex pair machine code representation.
  417.         sHex = "5589E583C4F85731C08945FC8945F8EB0EE80000000083F802742185C07424E830000000837DF800750AE838000000E84D00" & _
  418.             "00005F8B45FCC9C21000E826000000EBF168000000006AFCFF7508E800000000EBE031D24ABF00000000B900000000E82D00" & _
  419.             "0000C3FF7514FF7510FF750CFF75086800000000E8000000008945FCC331D2BF00000000B900000000E801000000C3E33209" & _
  420.             "C978078B450CF2AF75278D4514508D4510508D450C508D4508508D45FC508D45F85052B800000000508B00FF90A4070000C3"
  421.         
  422.         'Convert the string from hex pairs to bytes and store in the static machine code buffer
  423.         i = 1
  424.         Do While j < CODE_LEN
  425.             j = j + 1
  426.             aBuf(j) = Val("&H" & Mid$(sHex, i, 2))                                  'Convert a pair of hex characters to an eight-bit value and store in the static code buffer array
  427.             i = i + 2
  428.         Loop                                                                        'Next pair of hex characters
  429.         
  430.         'Get API function addresses
  431.         If Subclass_InIDE Then                                                      'If we're running in the VB IDE
  432.             aBuf(16) = &H90                                                         'Patch the code buffer to enable the IDE state code
  433.             aBuf(17) = &H90                                                         'Patch the code buffer to enable the IDE state code
  434.             pEbMode = zAddrFunc(MOD_VBA6, FUNC_EBM)                                 'Get the address of EbMode in vba6.dll
  435.             If pEbMode = 0 Then                                                     'Found?
  436.                 pEbMode = zAddrFunc(MOD_VBA5, FUNC_EBM)                             'VB5 perhaps
  437.             End If
  438.         End If
  439.  
  440.         pCWP = zAddrFunc(MOD_USER, FUNC_CWP)                                        'Get the address of the CallWindowsProc function
  441.         pSWL = zAddrFunc(MOD_USER, FUNC_SWL)                                        'Get the address of the SetWindowLongA function
  442.         ReDim sc_aSubData(0 To 0) As tSubData                                       'Create the first sc_aSubData element
  443.     Else
  444.         nSubIdx = zIdx(lng_hWnd, True)
  445.         If nSubIdx = -1 Then                                                        'If an sc_aSubData element isn't being re-cycled
  446.             nSubIdx = UBound(sc_aSubData()) + 1                                     'Calculate the next element
  447.             ReDim Preserve sc_aSubData(0 To nSubIdx) As tSubData                    'Create a new sc_aSubData element
  448.         End If
  449.         Subclass_Start = nSubIdx
  450.     End If
  451.  
  452.     With sc_aSubData(nSubIdx)
  453.         .hwnd = lng_hWnd                                                            'Store the hWnd
  454.         .nAddrSub = GlobalAlloc(GMEM_FIXED, CODE_LEN)                               'Allocate memory for the machine code WndProc
  455.         .nAddrOrig = SetWindowLongA(.hwnd, GWL_WNDPROC, .nAddrSub)                  'Set our WndProc in place
  456.         Call RtlMoveMemory(ByVal .nAddrSub, aBuf(1), CODE_LEN)                      'Copy the machine code from the static byte array to the code array in sc_aSubData
  457.         Call zPatchRel(.nAddrSub, PATCH_01, pEbMode)                                'Patch the relative address to the VBA EbMode api function, whether we need to not.. hardly worth testing
  458.         Call zPatchVal(.nAddrSub, PATCH_02, .nAddrOrig)                             'Original WndProc address for CallWindowProc, call the original WndProc
  459.         Call zPatchRel(.nAddrSub, PATCH_03, pSWL)                                   'Patch the relative address of the SetWindowLongA api function
  460.         Call zPatchVal(.nAddrSub, PATCH_06, .nAddrOrig)                             'Original WndProc address for SetWindowLongA, unsubclass on IDE stop
  461.         Call zPatchRel(.nAddrSub, PATCH_07, pCWP)                                   'Patch the relative address of the CallWindowProc api function
  462.         Call zPatchVal(.nAddrSub, PATCH_0A, ObjPtr(Me))                             'Patch the address of this object instance into the static machine code buffer
  463.     End With
  464. End Function
  465.  
  466. 'Stop all subclassing
  467. Private Sub Subclass_StopAll()
  468.     Dim i As Long
  469.     
  470.     i = UBound(sc_aSubData())                                                       'Get the upper bound of the subclass data array
  471.     Do While i >= 0                                                                 'Iterate through each element
  472.         With sc_aSubData(i)
  473.             If .hwnd <> 0 Then                                                      'If not previously Subclass_Stop'd
  474.                 Call Subclass_Stop(.hwnd)                                           'Subclass_Stop
  475.             End If
  476.         End With
  477.         i = i - 1                                                                   'Next element
  478.     Loop
  479. End Sub
  480.  
  481. 'Stop subclassing the passed window handle
  482. Private Sub Subclass_Stop(ByVal lng_hWnd As Long)
  483.     'Parameters:
  484.     'lng_hWnd  - The handle of the window to stop being subclassed
  485.     With sc_aSubData(zIdx(lng_hWnd))
  486.         Call SetWindowLongA(.hwnd, GWL_WNDPROC, .nAddrOrig)                         'Restore the original WndProc
  487.         Call zPatchVal(.nAddrSub, PATCH_05, 0)                                      'Patch the Table B entry count to ensure no further 'before' callbacks
  488.         Call zPatchVal(.nAddrSub, PATCH_09, 0)                                      'Patch the Table A entry count to ensure no further 'after' callbacks
  489.         Call GlobalFree(.nAddrSub)                                                  'Release the machine code memory
  490.         .hwnd = 0                                                                   'Mark the sc_aSubData element as available for re-use
  491.         .nMsgCntB = 0                                                               'Clear the before table
  492.         .nMsgCntA = 0                                                               'Clear the after table
  493.         Erase .aMsgTblB                                                             'Erase the before table
  494.         Erase .aMsgTblA                                                             'Erase the after table
  495.     End With
  496. End Sub
  497.  
  498. 'Track the mouse leaving the indicated window
  499. Private Sub TrackMouseLeave(ByVal lng_hWnd As Long)
  500.   Dim tme As TRACKMOUSEEVENT_STRUCT
  501.   
  502.     If bTrack Then
  503.         With tme
  504.             .cbSize = Len(tme)
  505.             .dwFlags = TME_LEAVE
  506.             .hwndTrack = lng_hWnd
  507.         End With
  508.     
  509.         If bTrackUser32 Then
  510.             Call TrackMouseEvent(tme)
  511.         Else
  512.             Call TrackMouseEventComCtl(tme)
  513.         End If
  514.     End If
  515. End Sub
  516.  
  517. '======================================================================================================
  518. 'These z??? routines are exclusively called by the Subclass_??? routines.
  519.  
  520. 'Worker sub for sc_AddMsg
  521. Private Sub zAddMsg(ByVal uMsg As Long, ByRef aMsgTbl() As Long, ByRef nMsgCnt As Long, ByVal When As eMsgWhen, ByVal nAddr As Long)
  522.     Dim nEntry  As Long                                                             'Message table entry index
  523.     Dim nOff1   As Long                                                             'Machine code buffer offset 1
  524.     Dim nOff2   As Long                                                             'Machine code buffer offset 2
  525.     
  526.     If uMsg = ALL_MESSAGES Then                                                     'If all messages
  527.         nMsgCnt = ALL_MESSAGES                                                      'Indicates that all messages will callback
  528.     Else                                                                            'Else a specific message number
  529.         Do While nEntry < nMsgCnt                                                   'For each existing entry. NB will skip if nMsgCnt = 0
  530.             nEntry = nEntry + 1
  531.             
  532.             If aMsgTbl(nEntry) = 0 Then                                             'This msg table slot is a deleted entry
  533.                 aMsgTbl(nEntry) = uMsg                                              'Re-use this entry
  534.                 Exit Sub                                                            'Bail
  535.             ElseIf aMsgTbl(nEntry) = uMsg Then                                      'The msg is already in the table!
  536.                 Exit Sub                                                            'Bail
  537.             End If
  538.         Loop                                                                        'Next entry
  539.         nMsgCnt = nMsgCnt + 1                                                       'New slot required, bump the table entry count
  540.         ReDim Preserve aMsgTbl(1 To nMsgCnt) As Long                                'Bump the size of the table.
  541.         aMsgTbl(nMsgCnt) = uMsg                                                     'Store the message number in the table
  542.     End If
  543.  
  544.     If When = eMsgWhen.MSG_BEFORE Then                                              'If before
  545.         nOff1 = PATCH_04                                                            'Offset to the Before table
  546.         nOff2 = PATCH_05                                                            'Offset to the Before table entry count
  547.     Else                                                                            'Else after
  548.         nOff1 = PATCH_08                                                            'Offset to the After table
  549.         nOff2 = PATCH_09                                                            'Offset to the After table entry count
  550.     End If
  551.  
  552.     If uMsg <> ALL_MESSAGES Then
  553.         Call zPatchVal(nAddr, nOff1, VarPtr(aMsgTbl(1)))                            'Address of the msg table, has to be re-patched because Redim Preserve will move it in memory.
  554.     End If
  555.     Call zPatchVal(nAddr, nOff2, nMsgCnt)                                           'Patch the appropriate table entry count
  556. End Sub
  557.  
  558. 'Return the memory address of the passed function in the passed dll
  559. Private Function zAddrFunc(ByVal sDLL As String, ByVal sProc As String) As Long
  560.     zAddrFunc = GetProcAddress(GetModuleHandleA(sDLL), sProc)
  561.     Debug.Assert zAddrFunc                                                          'You may wish to comment out this line if you're using vb5 else the EbMode GetProcAddress will stop here everytime because we look for vba6.dll first
  562. End Function
  563.  
  564. 'Worker sub for sc_DelMsg
  565. Private Sub zDelMsg(ByVal uMsg As Long, ByRef aMsgTbl() As Long, ByRef nMsgCnt As Long, ByVal When As eMsgWhen, ByVal nAddr As Long)
  566.     Dim nEntry As Long
  567.     
  568.     If uMsg = ALL_MESSAGES Then                                                     'If deleting all messages
  569.         nMsgCnt = 0                                                                 'Message count is now zero
  570.         If When = eMsgWhen.MSG_BEFORE Then                                          'If before
  571.             nEntry = PATCH_05                                                       'Patch the before table message count location
  572.         Else                                                                        'Else after
  573.             nEntry = PATCH_09                                                       'Patch the after table message count location
  574.         End If
  575.         Call zPatchVal(nAddr, nEntry, 0)                                            'Patch the table message count to zero
  576.     Else                                                                            'Else deleteting a specific message
  577.         Do While nEntry < nMsgCnt                                                   'For each table entry
  578.             nEntry = nEntry + 1
  579.             If aMsgTbl(nEntry) = uMsg Then                                          'If this entry is the message we wish to delete
  580.                 aMsgTbl(nEntry) = 0                                                 'Mark the table slot as available
  581.                 Exit Do                                                             'Bail
  582.             End If
  583.         Loop                                                                        'Next entry
  584.     End If
  585. End Sub
  586.  
  587. 'Get the sc_aSubData() array index of the passed hWnd
  588. Private Function zIdx(ByVal lng_hWnd As Long, Optional ByVal bAdd As Boolean = False) As Long
  589.     'Get the upper bound of sc_aSubData() - If you get an error here, you're probably sc_AddMsg-ing before Subclass_Start
  590.     zIdx = UBound(sc_aSubData)
  591.     Do While zIdx >= 0                                                              'Iterate through the existing sc_aSubData() elements
  592.         With sc_aSubData(zIdx)
  593.             If .hwnd = lng_hWnd Then                                                'If the hWnd of this element is the one we're looking for
  594.                 If Not bAdd Then                                                    'If we're searching not adding
  595.                     Exit Function                                                   'Found
  596.                 End If
  597.             ElseIf .hwnd = 0 Then                                                   'If this an element marked for reuse.
  598.                 If bAdd Then                                                        'If we're adding
  599.                     Exit Function                                                   'Re-use it
  600.                 End If
  601.             End If
  602.         End With
  603.     zIdx = zIdx - 1                                                                 'Decrement the index
  604.     Loop
  605.     
  606.     If Not bAdd Then
  607.         Debug.Assert False                                                          'hWnd not found, programmer error
  608.     End If
  609.  
  610. 'If we exit here, we're returning -1, no freed elements were found
  611. End Function
  612.  
  613. 'Patch the machine code buffer at the indicated offset with the relative address to the target address.
  614. Private Sub zPatchRel(ByVal nAddr As Long, ByVal nOffset As Long, ByVal nTargetAddr As Long)
  615.     Call RtlMoveMemory(ByVal nAddr + nOffset, nTargetAddr - nAddr - nOffset - 4, 4)
  616. End Sub
  617.  
  618. 'Patch the machine code buffer at the indicated offset with the passed value
  619. Private Sub zPatchVal(ByVal nAddr As Long, ByVal nOffset As Long, ByVal nValue As Long)
  620.     Call RtlMoveMemory(ByVal nAddr + nOffset, nValue, 4)
  621. End Sub
  622.  
  623. 'Worker function for Subclass_InIDE
  624. Private Function zSetTrue(ByRef bValue As Boolean) As Boolean
  625.     zSetTrue = True
  626.     bValue = True
  627. End Function
  628. '======================================================================================================
  629. '   End SubClass Sections
  630. '======================================================================================================
  631.  
  632. Private Function BlendColor(ByVal oColorFrom As OLE_COLOR, ByVal oColorTo As OLE_COLOR, Optional ByVal Alpha As Long = 128) As Long
  633.     '======================================================================
  634.     'BLENDS 2 COLORS WITH A PREDEFINED ALPHA VALUE
  635.     Dim lCFrom As Long
  636.     Dim lCTo As Long
  637.     Dim lSrcR As Long
  638.     Dim lSrcG As Long
  639.     Dim lSrcB As Long
  640.     Dim lDstR As Long
  641.     Dim lDstG As Long
  642.     Dim lDstB As Long
  643.     
  644.     lCFrom = GetLngColor(oColorFrom)
  645.     lCTo = GetLngColor(oColorTo)
  646.     
  647.     lSrcR = lCFrom And &HFF
  648.     lSrcG = (lCFrom And &HFF00&) \ &H100&
  649.     lSrcB = (lCFrom And &HFF0000) \ &H10000
  650.     lDstR = lCTo And &HFF
  651.     lDstG = (lCTo And &HFF00&) \ &H100&
  652.     lDstB = (lCTo And &HFF0000) \ &H10000
  653.     
  654.     BlendColor = RGB( _
  655.     ((lSrcR * Alpha) / 255) + ((lDstR * (255 - Alpha)) / 255), _
  656.     ((lSrcG * Alpha) / 255) + ((lDstG * (255 - Alpha)) / 255), _
  657.     ((lSrcB * Alpha) / 255) + ((lDstB * (255 - Alpha)) / 255) _
  658.     )
  659.     
  660. End Function
  661.  
  662. Public Property Let BrushStyle(ByVal Style As BrushStyle)
  663.     m_Brush = Style
  664.     PropertyChanged "BrushStyle"
  665. End Property
  666.  
  667. Private Sub CalcBarSize()
  668.     '==========================================================
  669.     '/---Calculate Division Bars & Percent Values
  670.     '==========================================================
  671.     lSegmentWidth = IIf(m_Scrolling = 0, 6, 0) '/-- Windows Default
  672.     lSegmentSpacing = 2                        '/-- Windows Default
  673.     tR.Left = tR.Left + 3
  674.     LSet TBR = tR
  675.     fPercent = m_Value / 98
  676.     If fPercent < 0# Then fPercent = 0#
  677.     If m_Orientation = 0 Then
  678.         '=======================================================================================
  679.         '                                 Calc Horizontal ProgressBar
  680.         '---------------------------------------------------------------------------------------
  681.         TBR.Right = tR.Left + (tR.Right - tR.Left) * fPercent
  682.         TBR.Right = TBR.Right - ((TBR.Right - TBR.Left) Mod (lSegmentWidth + lSegmentSpacing))
  683.         If TBR.Right < tR.Left Then
  684.             TBR.Right = tR.Left
  685.         End If
  686.     Else
  687.         '=======================================================================================
  688.         '                                 Calc Vertical ProgressBar
  689.         '---------------------------------------------------------------------------------------
  690.         fPercent = 1# - fPercent
  691.         TBR.Top = tR.Top + (tR.Bottom - tR.Top) * fPercent
  692.         TBR.Top = TBR.Top - ((TBR.Top - TBR.Bottom) Mod (lSegmentWidth + lSegmentSpacing))
  693.         If TBR.Top > tR.Bottom Then TBR.Top = tR.Bottom
  694.     End If
  695. End Sub
  696.  
  697. Private Sub CalculateAlphaTextRect(ByVal ThisText As String)
  698.     '======================================================================
  699.     'ALPHA TEXT RECT FUNCTION
  700.     
  701.     '//--Calculates the Bounding Rects Of the Text using DT_CALCRECT
  702.     DrawText m_hDC, ThisText, Len(ThisText), AT, DT_CALCRECT
  703.     AT.Left = (tR.Right / 2) - ((AT.Right - AT.Left) / 2)
  704.     AT.Top = (tR.Bottom / 2) - ((AT.Bottom - AT.Top) / 2)
  705. End Sub
  706.  
  707. Public Property Get Color() As OLE_COLOR
  708.     Color = m_Color
  709. End Property
  710.  
  711. Public Property Let Color(ByVal lColor As OLE_COLOR)
  712.     m_Color = GetLngColor(lColor)
  713.     DrawProgressBar
  714. End Property
  715.  
  716. Private Sub DrawAlphaText(ByVal ThisText As String)
  717.     '======================================================================
  718.     'ALPHA TEXT FUNCTION
  719.     
  720.     Set iFnt = Font                             '//--New Font
  721.     hFntOld = SelectObject(m_hDC, iFnt.hFont)   '//--Use the New Font
  722.     SetBkMode m_hDC, 1                          '//--Transparent Text
  723.     '//-- This is When the Text is Drawn
  724.     '//--Gives the Media Player Text Look (Changes Color When Progress is over the Text)
  725.     If (tR.Right * (m_Value / 100)) >= AT.Left Then
  726.         SetTextColor m_hDC, GetLngColor(IIf(m_Scrolling = ccScrollingMediaPlayer, ShiftColorXP(m_Color, 80), vbWhite))
  727.         AT.Left = (tR.Right / 2) - ((AT.Right - AT.Left) / 2)
  728.         AT.Right = (tR.Right * (m_Value / 100))
  729.         DrawText m_hDC, ThisText, Len(ThisText), AT, DT_SINGLELINE
  730.         SelectObject m_hDC, hFntOld
  731.     End If
  732.     
  733. End Sub
  734.  
  735. Private Sub DrawCustomBrushProgressbar()
  736.     '==========================================================
  737.     '/---CUSTOM BRUSH XP STYLE
  738.     '==========================================================
  739.     Dim hBrush As Long
  740.     
  741.     DrawEdge m_hDC, tR, 9, BF_RECT
  742.     With TBR
  743.         .Left = 2
  744.         .Top = 2
  745.         .Bottom = tR.Bottom - 2
  746.         .Right = tR.Left + (tR.Right - tR.Left) * (m_Value / 101)
  747.     End With
  748.     
  749.     hBrush = CreateHatchBrush(m_Brush, GetLngColor(Color))
  750.     SetBkColor m_hDC, ShiftColorXP(m_Color, 140)
  751.     FillRect m_hDC, TBR, hBrush
  752.     DeleteObject hBrush
  753. End Sub
  754.  
  755. Private Sub DrawDivisions()
  756.     '==========================================================
  757.     '/---Draw Division Bars
  758.     '==========================================================
  759.     Dim i As Long
  760.     Dim hBR As Long
  761.     
  762.     hBR = CreateSolidBrush(vbWhite)
  763.     LSet TSR = tR
  764.     If m_Orientation = 0 Then
  765.         '=======================================================================================
  766.         '                                 Draw Horizontal ProgressBar
  767.         '---------------------------------------------------------------------------------------
  768.         For i = TBR.Left + lSegmentWidth To TBR.Right Step lSegmentWidth + lSegmentSpacing
  769.             TSR.Left = i + 1
  770.             TSR.Right = i + 1 + lSegmentSpacing
  771.             FillRect m_hDC, TSR, hBR
  772.         Next i
  773.         '---------------------------------------------------------------------------------------
  774.     Else
  775.         '=======================================================================================
  776.         '                                  Draw Vertical ProgressBar
  777.         '---------------------------------------------------------------------------------------
  778.         For i = TBR.Bottom To TBR.Top + lSegmentWidth Step -(lSegmentWidth + lSegmentSpacing)
  779.             TSR.Top = i - 2
  780.             TSR.Bottom = i - 2 + lSegmentSpacing
  781.             FillRect m_hDC, TSR, hBR
  782.         Next i
  783.         '---------------------------------------------------------------------------------------
  784.     End If
  785.     DeleteObject hBR
  786. End Sub
  787.  
  788. Private Sub DrawFillRectangle(ByRef hRect As RECT, ByVal Color As Long, ByVal MyHdc As Long)
  789.     '======================================================================
  790.     'DRAWS A FILL RECTANGLE AREA OF AN SPECIFIED COLOR
  791.     Dim hBrush As Long
  792.     
  793.     hBrush = CreateSolidBrush(GetLngColor(Color))
  794.     FillRect MyHdc, hRect, hBrush
  795.     DeleteObject hBrush
  796. End Sub
  797.  
  798. Public Sub DrawGradient(lEndColor As Long, lStartColor As Long, ByVal X As Long, ByVal Y As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal hDC As Long, Optional bH As Boolean)
  799.     '======================================================================
  800.     'DRAWS A 2 COLOR GRADIENT AREA WITH A PREDEFINED DIRECTION
  801.     On Error Resume Next
  802.     
  803.     ''Draw a Vertical Gradient in the current HDC
  804.     Dim sR As Single, sG As Single, sB As Single
  805.     Dim eR As Single, eG As Single, eB As Single
  806.     Dim ni As Long
  807.     
  808.     lEndColor = GetLngColor(lEndColor)
  809.     lStartColor = GetLngColor(lStartColor)
  810.     
  811.     sR = (lStartColor And &HFF)
  812.     sG = (lStartColor \ &H100) And &HFF
  813.     sB = (lStartColor And &HFF0000) / &H10000
  814.     eR = (lEndColor And &HFF)
  815.     eG = (lEndColor \ &H100) And &HFF
  816.     eB = (lEndColor And &HFF0000) / &H10000
  817.     sR = (sR - eR) / IIf(bH, X2, Y2)
  818.     sG = (sG - eG) / IIf(bH, X2, Y2)
  819.     sB = (sB - eB) / IIf(bH, X2, Y2)
  820.     For ni = 0 To IIf(bH, X2, Y2)
  821.         If bH Then
  822.             DrawLine X + ni, Y, X + ni, Y2, hDC, RGB(eR + (ni * sR), eG + (ni * sG), eB + (ni * sB))
  823.         Else
  824.             DrawLine X, Y + ni, X2, Y + ni, hDC, RGB(eR + (ni * sR), eG + (ni * sG), eB + (ni * sB))
  825.         End If
  826.     Next ni
  827. End Sub
  828. '======================================================================
  829. Private Sub DrawJavTProgressbar()
  830.     '==========================================================
  831.     '/---JAVT XP STYLE
  832.     '==========================================================
  833.     DrawRectangle tR, ShiftColorXP(m_Color, 10), m_hDC
  834.     TBR.Right = tR.Left + (tR.Right - tR.Left) * (m_Value / 101)
  835.     DrawGradient m_Color, ShiftColorXP(m_Color, 100), 2, 2, tR.Right - 2, tR.Bottom - 5, m_hDC ', True
  836.     DrawGradient ShiftColorXP(m_Color, 250), m_Color, 3, 3, TBR.Right, tR.Bottom - 6, m_hDC  ', True
  837.     DrawLine TBR.Right, 2, TBR.Right, tR.Bottom - 2, m_hDC, ShiftColorXP(m_Color, 25)
  838.     
  839. End Sub
  840.  
  841. Public Sub DrawLine( _
  842.     ByVal X As Long, _
  843.     ByVal Y As Long, _
  844.     ByVal Width As Long, _
  845.     ByVal Height As Long, _
  846.     ByVal cHdc As Long, _
  847.     ByVal Color As Long)
  848.     '======================================================================
  849.     'DRAWS A LINE WITH A DEFINED COLOR
  850.     
  851.     Dim Pen1    As Long
  852.     Dim Pen2    As Long
  853.     Dim Outline As Long
  854.     Dim Pos     As POINTAPI
  855.     
  856.     Pen1 = CreatePen(0, 1, GetLngColor(Color))
  857.     Pen2 = SelectObject(cHdc, Pen1)
  858.     
  859.     MoveToEx cHdc, X, Y, Pos
  860.     LineTo cHdc, Width, Height
  861.     
  862.     SelectObject cHdc, Pen2
  863.     DeleteObject Pen2
  864.     DeleteObject Pen1
  865.     
  866. End Sub
  867.  
  868. Private Sub DrawClassicProgressbar()
  869.     '==========================================================
  870.     '/---CLASSIC STYLE
  871.     '==========================================================
  872.     DrawRectangle tR, &HFFFFFF, m_hDC
  873.     InflateRect tR, -1, -1
  874.     DrawRectangle tR, TranslateColor(UserControl.Parent.BackColor), m_hDC
  875.     DrawLine 0, 0, tR.Left + (tR.Right - tR.Left), 0, m_hDC, &H99A8AC
  876.     DrawLine 0, 0, 0, tR.Bottom, m_hDC, &H99A8AC
  877.     DrawLine 1, 1, tR.Left + (tR.Right - tR.Left), 1, m_hDC, &H707070
  878.     DrawLine 1, 1, 1, tR.Bottom, m_hDC, &H707070
  879.     With TBR
  880.         .Left = 2
  881.         .Top = 2
  882.         .Bottom = tR.Bottom - 1
  883.         .Right = tR.Left + (tR.Right - tR.Left) * (m_Value / 100)
  884.     End With
  885.     DrawFillRectangle TBR, &H800000, m_hDC
  886. End Sub
  887.  
  888. Private Sub DrawMediaProgressbar()
  889.     '==========================================================
  890.     '/---MEDIA PROGRESS XP STYLE
  891.     '==========================================================
  892.     DrawRectangle tR, BlendColor(m_Color, &H0, 200), m_hDC
  893.     DrawGradient &H0&, ShiftColorXP(GetLngColor(BlendColor(m_Color, &H0, 100)), 10), 2, 2, tR.Left + (tR.Right - tR.Left - 5) * (m_Value / 100), tR.Bottom - 2, m_hDC, True
  894. End Sub
  895.  
  896. Private Sub DrawMetalProgressbar()
  897.     '==========================================================
  898.     '/---METALLIC XP STYLE
  899.     '==========================================================
  900.     TBR.Right = tR.Left + (tR.Right - tR.Left - 4) * (m_Value / 100)
  901.     DrawGradient vbWhite, &HC0C0C0, 2, 2, tR.Right - 3, (tR.Bottom - 3) / 2, m_hDC
  902.     DrawGradient BlendColor(&HC0C0C0, &H0, 255), &HC0C0C0, 2, (tR.Bottom - 3) / 2, tR.Right - 3, (tR.Bottom - 3) / 2, m_hDC
  903.     DrawGradient ShiftColorXP(m_Color, 150), BlendColor(m_Color, &H0, 180), 2, 2, TBR.Right, (tR.Bottom - 3) / 2, m_hDC
  904.     DrawGradient BlendColor(m_Color, &H0, 190), m_Color, 2, (tR.Bottom - 3) / 2, TBR.Right, (tR.Bottom - 3) / 2, m_hDC
  905.     tR.Left = tR.Left + 3
  906.     pDrawBorder
  907. End Sub
  908.  
  909. Private Sub DrawOfficeXPProgressbar()
  910.     '==========================================================
  911.     '/---OFFICE XP STYLE
  912.     '==========================================================
  913.     DrawRectangle tR, ShiftColorXP(m_Color, 100), m_hDC
  914.     With TBR
  915.         .Left = 1
  916.         .Top = 1
  917.         .Bottom = tR.Bottom - 1
  918.         .Right = tR.Left + (tR.Right - tR.Left) * (m_Value / 100)
  919.     End With
  920.     DrawFillRectangle TBR, ShiftColorXP(m_Color, 180), m_hDC
  921. End Sub
  922.  
  923. Private Sub DrawPastelProgressbar()
  924.     '==========================================================
  925.     '/---PASTEL XP STYLE
  926.     '==========================================================
  927.     DrawEdge m_hDC, tR, 6, BF_RECT
  928.     DrawGradient ShiftColorXP(m_Color, 140), ShiftColorXP(m_Color, 200), 2, 2, tR.Left + (tR.Right - tR.Left - 4) * (m_Value / 100), tR.Bottom - 3, m_hDC, True
  929. End Sub
  930.  
  931. Private Sub DrawPictureProgressbar()
  932.     '==========================================================
  933.     '/---PICTURE STYLE
  934.     '==========================================================
  935.     Dim Brush      As Long
  936.     Dim origBrush  As Long
  937.     DrawEdge m_hDC, tR, 2, BF_RECT                       '//--- Draw ProgressBar Border
  938.     If Nothing Is m_Picture Then Exit Sub                '//--- In Case No Picture is Choosen
  939.     Brush = CreatePatternBrush(m_Picture.handle)         '//-- Use Pattern Picture Draw
  940.     origBrush = SelectObject(m_hDC, Brush)
  941.     TBR.Right = tR.Left + (tR.Right - tR.Left) * (m_Value / 101)
  942.     PatBlt m_hDC, 2, 2, TBR.Right, tR.Bottom - 4, vbPatCopy
  943.     SelectObject m_hDC, origBrush
  944.     DeleteObject Brush
  945.     
  946. End Sub
  947.  
  948. Public Sub DrawProgressBar()
  949.     '==========================================================
  950.     '/---Draw ALL ProgressXP Bar  !!!!PUBLIC CALL!!!
  951.     '==========================================================
  952.     If m_Value > 100 Then m_Value = 100
  953.     GetClientRect m_hWnd, tR               '//--- Refe 1,======Rc=
  954.     DrawR'DRAWal Color As Long'If
  955. _
  956.   m_Value =F1Right - TBR.LeN ========Rc=
  957.  DRAWa==================
  958.   arivate Sub DrawCustomBrushProgressbar()      =======nX1eLeft) *F0000) \ &H10000
  959.     lDstR lue / 101)
  960.    ===Objectent BlendColor(m_Color, &H0, 190), m_Colo S lDstR CA              ================nTargalue =F1Right - TBR.LeN ========Rc=
  961.  DRAWa==================
  962.   arivate Sub DrawCustomBrus=======Rc=
  963.  DRAWa===============Ak(t =====Ae Next
  964. ===Ae Next
  965. ===A tR.Left
  966.         End If
  967.     Else
  968.         D|'========g  CA /      .    cdex
  969.     Dim sHex                    As String                                           'Hex code string
  970. a8tring
  971. a8tring   End With
  972. jar()
  973.  =====tring,===     'HeMIXing
  974. a8= code       (lCTo And &HFFring       P
  975.  =====tring,===T-=====)hG                                  'Hex codL       'Hex corush(m_Picture.handle)         '//-- Use Pattern Picture Draw
  976.     origBrush = SelectObject(m_hDC, Brush)
  977.     TBR.Rightf
  978.          g  <ynOAandle)         '//-- UtR.Left + (tR.Right - tR.Left - 5) * (m_Value / 100), tR.Bottom - 2, m_hDC, True
  979. End Subet to   With TBR.Rightf
  980.          g  <ynOAan&          nd S8  <cnn     ,     B 5) * (m_VBBBBBBBBBB
  981.         SelectObject m_hDC, hFntOld
  982.     End If
  983.     
  984. End Sub
  985.  
  986. Private Sub DrawCustomBrushPrL        Else
  987.         D|'========g  CA /   .Left + (dvatHeS<===========================================atHeS<=
  988. Private Sub D offset to t =====trinD   'Machine code buffe4 eim sd SSSSSSSSSSSSSSSf&H10-----d SSeSSSSSSSSSSSSSf&H10--==========================
  989.     '/---PICTURE STYLE
  990.     '===============S A FILeO-valueNv <c,t==
  991. STYLE
  992.   =====FILeO-valueNv <c,t==
  993. STYLE
  994.   =====FILeO-valueNv <c,t==
  995. STYLE
  996.   ==2NeO-valueNv.     ============R)
  997.     '==================  =============================== - TO-val  =======-val  =======-val  =======-val  =======-val  =======-val  =======-val  =====N=======-val  =======-val  ===m===
  998. a8========-val  =======-val  ===m===
  999. a8====l=-val  ===m== 0val  =======-val  =======-val  =====