home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / iQ_WordPad20918411252007.psc / candybutton.ctl < prev   
Text File  |  2007-06-23  |  82KB  |  1,712 lines

  1. VERSION 5.00
  2. Begin VB.UserControl CandyButton 
  3.    Appearance      =   0  'Flat
  4.    AutoRedraw      =   -1  'True
  5.    BackColor       =   &H00FFFFFF&
  6.    ClientHeight    =   1335
  7.    ClientLeft      =   0
  8.    ClientTop       =   0
  9.    ClientWidth     =   1830
  10.    ClipBehavior    =   0  'None
  11.    BeginProperty Font 
  12.       Name            =   "Tahoma"
  13.       Size            =   9
  14.       Charset         =   0
  15.       Weight          =   400
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    ScaleHeight     =   89
  21.    ScaleMode       =   3  'Pixel
  22.    ScaleWidth      =   122
  23. End
  24. Attribute VB_Name = "CandyButton"
  25. Attribute VB_GlobalNameSpace = False
  26. Attribute VB_Creatable = True
  27. Attribute VB_PredeclaredId = False
  28. Attribute VB_Exposed = False
  29. Option Explicit
  30.  
  31. '-Selfsub declarations----------------------------------------------------------------------------
  32. Private Enum eMsgWhen                                                       'When to callback
  33.   MSG_BEFORE = 1                                                            'Callback before the original WndProc
  34.   MSG_AFTER = 2                                                             'Callback after the original WndProc
  35.   MSG_BEFORE_AFTER = MSG_BEFORE Or MSG_AFTER                                'Callback before and after the original WndProc
  36. End Enum
  37.  
  38. Private Const ALL_MESSAGES  As Long = -1                                    'All messages callback
  39. Private Const MSG_ENTRIES   As Long = 32                                    'Number of msg table entries
  40. Private Const WNDPROC_OFF   As Long = &H38                                  'Thunk offset to the WndProc execution address
  41. Private Const GWL_WNDPROC   As Long = -4                                    'SetWindowsLong WndProc index
  42. Private Const IDX_SHUTDOWN  As Long = 1                                     'Thunk data index of the shutdown flag
  43. Private Const IDX_HWND      As Long = 2                                     'Thunk data index of the subclassed hWnd
  44. Private Const IDX_WNDPROC   As Long = 9                                     'Thunk data index of the original WndProc
  45. Private Const IDX_BTABLE    As Long = 11                                    'Thunk data index of the Before table
  46. Private Const IDX_ATABLE    As Long = 12                                    'Thunk data index of the After table
  47. Private Const IDX_PARM_USER As Long = 13                                    'Thunk data index of the User-defined callback parameter data index
  48.  
  49. Private z_ScMem             As Long                                         'Thunk base address
  50. Private z_Sc(64)            As Long                                         'Thunk machine-code initialised here
  51. Private z_Funk              As Collection                                   'hWnd/thunk-address collection
  52.  
  53. Private Declare Function CallWindowProcA Lib "USER32" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  54. Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
  55. Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long
  56. Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
  57. Private Declare Function GetWindowThreadProcessId Lib "USER32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
  58. Private Declare Function IsBadCodePtr Lib "kernel32" (ByVal lpfn As Long) As Long
  59. Private Declare Function IsWindow Lib "USER32" (ByVal hWnd As Long) As Long
  60. Private Declare Function SetWindowLongA Lib "USER32" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  61. Private Declare Function VirtualAlloc Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
  62. Private Declare Function VirtualFree Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
  63. Private Declare Sub RtlMoveMemory Lib "kernel32" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)
  64. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  65.  
  66. Public Event Status(ByVal sStatus As String)
  67.  
  68. Private Const WM_MOUSEMOVE    As Long = &H200
  69. Private Const WM_MOUSELEAVE   As Long = &H2A3
  70. Private Const WM_MOVING       As Long = &H216
  71. Private Const WM_SIZING       As Long = &H214
  72. Private Const WM_EXITSIZEMOVE As Long = &H232
  73. Private Const WM_PAINT = &HF
  74.  
  75. Private Enum TRACKMOUSEEVENT_FLAGS
  76.   TME_HOVER = &H1&
  77.   TME_LEAVE = &H2&
  78.   TME_QUERY = &H40000000
  79.   TME_CANCEL = &H80000000
  80. End Enum
  81.  
  82. Private Type TRACKMOUSEEVENT_STRUCT
  83.   cbSize                      As Long
  84.   dwFlags                     As TRACKMOUSEEVENT_FLAGS
  85.   hwndTrack                   As Long
  86.   dwHoverTime                 As Long
  87. End Type
  88.  
  89. Private bTrack                As Boolean
  90. Private bTrackUser32          As Boolean
  91. Private IsHover               As Boolean
  92. Private bMoving               As Boolean
  93.  
  94. Public Event Click()
  95. Attribute Click.VB_MemberFlags = "200"
  96. Public Event DblClick()
  97. Public Event MouseEnter()
  98. Public Event MouseLeave()
  99. Public Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  100. Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  101. Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  102.  
  103. Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
  104. Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As String) As Long
  105. Private Declare Function TrackMouseEvent Lib "USER32" (lpEventTrack As TRACKMOUSEEVENT_STRUCT) As Long
  106. Private Declare Function TrackMouseEventComCtl Lib "Comctl32" Alias "_TrackMouseEvent" (lpEventTrack As TRACKMOUSEEVENT_STRUCT) As Long
  107.  
  108. '-Candy Button declarations----------------------------------------------------------------------------
  109. Public Enum eAlignment
  110.     PIC_TOP
  111.     PIC_BOTTOM
  112.     PIC_LEFT
  113.     PIC_RIGHT
  114. End Enum
  115.  
  116. Public Enum eStyle
  117.     XP_Button
  118.     XP_ToolBarButton
  119.     Crystal
  120.     Mac
  121.     Mac_Variation
  122.     WMP
  123.     Plastic
  124.     Iceblock
  125. End Enum
  126.  
  127. Public Enum eColorScheme
  128.     Custom
  129.     Aqua
  130.     WMP10
  131.     DeepBlue
  132.     DeepRed
  133.     DeepGreen
  134.     DeepYellow
  135. End Enum
  136.  
  137. Public Enum eState
  138.     eNormal
  139.     ePressed
  140.     eFocus
  141.     eHover
  142.     eChecked
  143. End Enum
  144.  
  145. Private Type tCrystalParam
  146.     Ref_MixColorFrom As Long
  147.     Ref_Intensity As Long
  148.     Ref_Left As Long
  149.     Ref_Top As Long
  150.     Ref_Radius As Long
  151.     Ref_Height As Long
  152.     Ref_Width As Long
  153.     RadialGXPercent As Long
  154.     RadialGYPercent As Long
  155.     RadialGOffsetX As Long
  156.     RadialGOffsetY As Long
  157.     RadialGIntensity As Long
  158. End Type
  159.  
  160. Private Type BITMAPINFOHEADER    '40 bytes
  161.    biSize As Long
  162.    biWidth As Long
  163.    biHeight As Long
  164.    biPlanes As Integer
  165.    biBitCount As Integer
  166.    biCompression As Long
  167.    biSizeImage As Long
  168.    biXPelsPerMeter As Long
  169.    biYPelsPerMeter As Long
  170.    biClrUsed As Long
  171.    biClrImportant As Long
  172. End Type
  173.  
  174. Private Type RGBQUAD
  175.    rgbBlue As Byte
  176.    rgbGreen As Byte
  177.    rgbRed As Byte
  178.    rgbReserved As Byte
  179. End Type
  180.  
  181. Private Type BITMAP    '24 bytes
  182.   bmType As Long
  183.   bmWidth As Long
  184.   bmHeight As Long
  185.   bmWidthBytes As Long
  186.   bmPlanes As Integer
  187.   bmBitsPixel As Integer
  188.   bmBits As Long
  189. End Type
  190.  
  191. Private Type BITMAPINFO
  192.   bmiHeader As BITMAPINFOHEADER
  193.   bmiColors As RGBQUAD
  194. End Type
  195.  
  196. Private Const BI_RGB = 0&
  197. Private Const DIB_RGB_COLORS = 0&
  198.  
  199. Private m_PictureAlignment                      As eAlignment
  200. Private m_Style                                 As eStyle
  201. Private m_Checked                               As Boolean
  202. Private m_hasFocus                              As Boolean
  203. Private m_Caption                               As String
  204. Private m_StdPicture                            As StdPicture
  205. Private m_Font                                  As StdFont
  206. Private m_ColorButtonHover                      As OLE_COLOR
  207. Private m_ColorButtonUp                         As OLE_COLOR
  208. Private m_ColorButtonDown                       As OLE_COLOR
  209. Private m_ColorBright                           As OLE_COLOR
  210. Private m_ForeColor                             As OLE_COLOR
  211. Private m_DisplayHand                           As Boolean
  212. Private CornerRadius                            As Long
  213. Private m_BorderBrightness                      As Long
  214. Private m_ColorScheme                           As eColorScheme
  215. Private m_bHighLited                            As Boolean
  216. Private m_bIconHighLite                         As Boolean
  217. Private m_lIconHighLiteColor                    As OLE_COLOR
  218. Private m_bCaptionHighLite                      As Boolean
  219. Private m_lCaptionHighLiteColor                 As OLE_COLOR
  220. Private m_bEnabled                              As Boolean
  221. Private m_InitCompleted                         As Boolean
  222. Private hButtonRegion                              As Long
  223.  
  224. Private Const m_def_ForeColor                   As Long = vbBlack
  225. Private Const m_def_PictureAlignment            As Byte = 0
  226. Private Const DST_TEXT                          As Long = &H1
  227. Private Const DST_PREFIXTEXT                    As Long = &H2
  228. Private Const DST_COMPLEX                       As Long = &H0
  229. Private Const DST_ICON                          As Long = &H3
  230. Private Const DST_BITMAP                        As Long = &H4
  231. Private Const DSS_NORMAL                        As Long = &H0
  232. Private Const DSS_UNION                         As Long = &H10
  233. Private Const DSS_DISABLED                      As Long = &H20
  234. Private Const DSS_MONO                          As Long = &H80
  235. Private Const DSS_RIGHT                         As Long = &H8000
  236. Private Const RGN_XOR = 3
  237. Private Const MK_LBUTTON = &H1
  238.  
  239. Private Type POINTAPI
  240.     X As Long
  241.     Y As Long
  242. End Type
  243.  
  244. Private Type Rect
  245.         Left As Long
  246.         Top As Long
  247.         Right As Long
  248.         Bottom As Long
  249. End Type
  250.  
  251. Private Declare Function SetWindowRgn Lib "USER32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
  252. Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
  253. Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  254. 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
  255. Private Declare Function DrawState Lib "USER32" Alias "DrawStateA" (ByVal hdc As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As Long, ByVal wParam As Long, ByVal X As Long, ByVal Y As Long, ByVal cX As Long, ByVal cY As Long, ByVal fuFlags As Long) As Long
  256. Private Declare Function DrawStateText Lib "USER32" Alias "DrawStateA" (ByVal hdc As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As String, ByVal wParam As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal un As Long) As Long
  257. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
  258. Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
  259. Private Declare Function TranslateColor Lib "olepro32.dll" Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, ByVal palet As Long, Col As Long) As Long
  260. Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal X As Long, ByVal Y As Long) As Long
  261. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  262. Private Declare Function InflateRect Lib "USER32" (lpRect As Rect, ByVal X As Long, ByVal Y As Long) As Long
  263. Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  264. 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
  265. Private Declare Function IsRectEmpty Lib "USER32" (lpRect As Rect) As Long
  266. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  267. Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
  268. Private Declare Function FillRect Lib "USER32" (ByVal hdc As Long, lpRect As Rect, ByVal hBrush As Long) As Long
  269.  
  270.  
  271. Public Property Let DisplayHand(newValue As Boolean)
  272.     m_DisplayHand = newValue
  273. End Property
  274.  
  275. Public Property Get DisplayHand() As Boolean
  276.     DisplayHand = m_DisplayHand
  277. End Property
  278.  
  279. 'Description: Enable or disable the control
  280. Public Property Let Enabled(bEnabled As Boolean)
  281. On Error GoTo Handler
  282.     m_bEnabled = bEnabled
  283.     PropertyChanged "Enabled"
  284.     '/*** added
  285.     DrawButton (eNormal)
  286. Handler:
  287. End Property
  288.  
  289. Public Property Get Enabled() As Boolean
  290. On Error GoTo Handler
  291.     Enabled = m_bEnabled
  292.     Refresh
  293.     Exit Property
  294. Handler:
  295. End Property
  296.  
  297. Public Property Let ColorScheme(newValue As eColorScheme)
  298.     Select Case newValue
  299.         Case Aqua
  300.             ColorButtonUp = &HD06720
  301.             ColorButtonHover = &HE99950
  302.             ColorButtonDown = &HA06710
  303.             ColorBright = &HFFEDB0
  304.         Case WMP10
  305.             ColorButtonUp = &HD09060
  306.             ColorButtonHover = &HE06000
  307.             ColorButtonDown = &HA98050
  308.             ColorBright = &HFFFAFA
  309.         Case DeepBlue
  310.             ColorButtonUp = &H800000
  311.             ColorButtonHover = &HA00000
  312.             ColorButtonDown = &HF00000
  313.             ColorBright = &HFF0000
  314.         Case DeepRed
  315.             ColorButtonUp = &H80&
  316.             ColorButtonHover = &HA0&
  317.             ColorButtonDown = &HF0&
  318.             ColorBright = &HFF&
  319.         Case DeepGreen
  320.             ColorButtonUp = &H8000&
  321.             ColorButtonHover = &HA000&
  322.             ColorButtonDown = &HC000&
  323.             ColorBright = &HFF00&
  324.         Case DeepYellow
  325.             ColorButtonUp = &H8080&
  326.             ColorButtonHover = &HA0A0&
  327.             ColorButtonDown = &HC0C0&
  328.             ColorBright = &HFFFF&
  329.     End Select
  330.     m_ColorScheme = newValue
  331.     PropertyChanged "m_ColorScheme"
  332.     DrawButton (eNormal)
  333. End Property
  334.  
  335. Public Property Get ColorScheme() As eColorScheme
  336.     ColorScheme = m_ColorScheme
  337. End Property
  338.  
  339. Public Property Let BorderBrightness(newValue As Long)
  340.     m_BorderBrightness = SetBound(newValue, -100, 100)
  341.     PropertyChanged "m_BorderBrightness"
  342.     DrawButton (eNormal)
  343. End Property
  344.  
  345. Public Property Get BorderBrightness() As Long
  346.     BorderBrightness = m_BorderBrightness
  347. End Property
  348.  
  349. '/*** enable icon mouse over highliting
  350. Public Property Get IconHighLite() As Boolean
  351.     IconHighLite = m_bIconHighLite
  352. End Property
  353.  
  354. Public Property Let IconHighLite(PropVal As Boolean)
  355.     m_bIconHighLite = PropVal
  356.     PropertyChanged "IconHighLite"
  357. End Property
  358.  
  359. '/*** enable icon mouse over highliting
  360. Public Property Get IconHighLiteColor() As OLE_COLOR
  361.     IconHighLiteColor = m_lIconHighLiteColor
  362. End Property
  363.  
  364. Public Property Let IconHighLiteColor(PropVal As OLE_COLOR)
  365.     m_lIconHighLiteColor = PropVal
  366.     PropertyChanged "IconHighLiteColor"
  367. End Property
  368.  
  369. '/*** enable caption mouse over highliting
  370. Public Property Get CaptionHighLite() As Boolean
  371.     CaptionHighLite = m_bCaptionHighLite
  372. End Property
  373.  
  374. Public Property Let CaptionHighLite(PropVal As Boolean)
  375.     m_bCaptionHighLite = PropVal
  376.     PropertyChanged "CaptionHighLite"
  377. End Property
  378.  
  379. Public Property Get CaptionHighLiteColor() As OLE_COLOR
  380.     CaptionHighLiteColor = m_lCaptionHighLiteColor
  381. End Property
  382.  
  383. Public Property Let CaptionHighLiteColor(PropVal As OLE_COLOR)
  384.     m_lCaptionHighLiteColor = PropVal
  385.     PropertyChanged "CaptionHighLiteColor"
  386. End Property
  387.  
  388. Public Property Let ColorBright(newValue As OLE_COLOR)
  389.     m_ColorBright = newValue
  390.     If m_ColorScheme <> Custom Then m_ColorScheme = Custom:  PropertyChanged "m_ColorScheme"
  391.     PropertyChanged "m_ColorBright"
  392.     DrawButton (eNormal)
  393. End Property
  394.  
  395. Public Property Get ColorBright() As OLE_COLOR
  396.     ColorBright = m_ColorBright
  397. End Property
  398.  
  399. Public Property Let ColorButtonDown(newValue As OLE_COLOR)
  400.     m_ColorButtonDown = newValue
  401.     If m_ColorScheme <> Custom Then m_ColorScheme = Custom:  PropertyChanged "m_ColorScheme"
  402.     PropertyChanged "m_ColorButtonDown"
  403.     DrawButton (eNormal)
  404. End Property
  405.  
  406. Public Property Get ColorButtonDown() As OLE_COLOR
  407.     ColorButtonDown = m_ColorButtonDown
  408. End Property
  409.  
  410. Public Property Let ColorButtonUp(newValue As OLE_COLOR)
  411.     m_ColorButtonUp = newValue
  412.     If m_ColorScheme <> Custom Then m_ColorScheme = Custom:  PropertyChanged "m_ColorScheme"
  413.     PropertyChanged "m_ColorButtonUp"
  414.     DrawButton (eNormal)
  415. End Property
  416.  
  417. Public Property Get ColorButtonUp() As OLE_COLOR
  418.     ColorButtonUp = m_ColorButtonUp
  419. End Property
  420.  
  421. Public Property Let ColorButtonHover(newValue As OLE_COLOR)
  422.     m_ColorButtonHover = newValue
  423.     If m_ColorScheme <> Custom Then m_ColorScheme = Custom:  PropertyChanged "m_ColorScheme"
  424.     PropertyChanged "m_ColorButtonHover"
  425.     DrawButton (eNormal)
  426. End Property
  427.  
  428. Public Property Get ColorButtonHover() As OLE_COLOR
  429.     ColorButtonHover = m_ColorButtonHover
  430. End Property
  431.  
  432. Public Property Let ForeColor(ByVal NewForeColor As OLE_COLOR)
  433.      m_ForeColor = NewForeColor
  434.      UserControl.ForeColor = m_ForeColor
  435.      PropertyChanged "ForeColor"
  436.      DrawButton (eNormal)
  437. End Property
  438.  
  439. Public Property Get ForeColor() As OLE_COLOR
  440.      ForeColor = m_ForeColor
  441. End Property
  442.  
  443. Public Property Set Picture(Value As StdPicture)
  444.     Set m_StdPicture = Value
  445.     PropertyChanged "Picture"
  446.     DrawButton (eNormal)
  447. End Property
  448.  
  449. Public Property Get Picture() As StdPicture
  450.     Set Picture = m_StdPicture
  451. End Property
  452.  
  453. Public Property Let Checked(Value As Boolean)
  454.     m_Checked = Value
  455.     If Value Then
  456.         DrawButton (eChecked)
  457.     Else
  458.         If IsHover Then
  459.             DrawButton (eHover)
  460.         Else
  461.             DrawButton (eNormal)
  462.         End If
  463.     End If
  464.     PropertyChanged "Checked"
  465. End Property
  466.  
  467. Public Property Get Checked() As Boolean
  468.     Checked = m_Checked
  469. End Property
  470.  
  471. Public Property Let Style(eVal As eStyle)
  472.     If eVal <> m_Style Then
  473.         m_Style = eVal
  474.         PropertyChanged "Style"
  475.         Init_Style
  476.         DrawButton (eNormal)
  477.     End If
  478. End Property
  479.  
  480. Public Property Get Style() As eStyle
  481.     Style = m_Style
  482. End Property
  483.  
  484. Public Property Let PictureAlignment(eVal As eAlignment)
  485.     If eVal <> m_PictureAlignment Then
  486.         m_PictureAlignment = eVal
  487.         PropertyChanged "PictureAlignment"
  488.         DrawButton (eNormal)
  489.     End If
  490. End Property
  491.  
  492. Public Property Get PictureAlignment() As eAlignment
  493.     PictureAlignment = m_PictureAlignment
  494. End Property
  495.  
  496. Public Property Let Caption(ByVal New_Caption As String)
  497.     m_Caption = New_Caption
  498.     PropertyChanged "Caption"
  499.     DrawButton (eNormal)
  500. End Property
  501.  
  502. Public Property Get Caption() As String
  503.     Caption = m_Caption
  504. End Property
  505.  
  506. Public Property Set Font(ByVal NewFont As StdFont)
  507.      Set UserControl.Font = NewFont
  508.      PropertyChanged "Font"
  509.      DrawButton (eNormal)
  510. End Property
  511.  
  512. Public Property Get Font() As StdFont
  513.      Set Font = UserControl.Font
  514. End Property
  515.  
  516. Private Sub UserControl_Initialize()
  517.     m_Style = Style
  518. End Sub
  519.  
  520. Private Sub UserControl_InitProperties()
  521.     If Not Ambient.UserMode Then
  522.         m_bEnabled = True
  523.         m_ColorButtonHover = &HFFC090
  524.         m_ColorButtonUp = &HE99950
  525.         m_ColorBright = &HFFEDB0
  526.         m_ColorButtonDown = &HE99950
  527.         m_Caption = UserControl.Name
  528.         UserControl.Picture = LoadPicture("")
  529.     End If
  530.     m_Caption = Extender.Name
  531.     m_InitCompleted = True
  532. End Sub
  533.  
  534. Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
  535.     If Not m_bEnabled Then Exit Sub
  536.     If KeyCode = vbKeyReturn Then UserControl_MouseDown 1, 0, 0, 0
  537. End Sub
  538.  
  539. Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
  540.     If Not m_bEnabled Then Exit Sub
  541.     If KeyCode = vbKeyReturn Then
  542.         UserControl_MouseUp 1, 0, 0, 0
  543.         RaiseEvent Click
  544.     End If
  545. End Sub
  546.  
  547. Private Sub UserControl_Click()
  548.     If Not m_bEnabled Then Exit Sub
  549.     RaiseEvent Click
  550. End Sub
  551.  
  552. Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  553.     If Not m_bEnabled Then Exit Sub
  554.     m_hasFocus = True
  555.     DrawButton (ePressed)
  556.     RaiseEvent MouseDown(Button, Shift, X, Y)
  557. End Sub
  558.  
  559. Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  560.     If Not m_bEnabled Then Exit Sub
  561.     RaiseEvent MouseMove(Button, Shift, X, Y)
  562.     If Button = 1 And (X < 0 Or X > ScaleWidth Or _
  563.         Y < 0 Or Y > ScaleHeight) Then
  564.         IsHover = False
  565.         DrawButton (eNormal)
  566.     End If
  567. End Sub
  568.  
  569. Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  570.     If Not m_bEnabled Then Exit Sub
  571.     If Not m_Checked Then
  572.         If IsHover Then
  573.             DrawButton (eHover)
  574.         Else
  575.             If m_hasFocus Then DrawButton (eFocus)
  576.         End If
  577.     End If
  578.     RaiseEvent MouseUp(Button, Shift, X, Y)
  579. End Sub
  580.  
  581. Private Sub UserControl_DblClick()
  582.     If Not m_bEnabled Then Exit Sub
  583.     DrawButton (ePressed)
  584.     RaiseEvent DblClick
  585. End Sub
  586.  
  587. Private Sub UserControl_EnterFocus()
  588.     m_hasFocus = True
  589.     If Not m_bEnabled Then Exit Sub
  590.     If Not m_Checked And Not IsHover Then DrawButton (eFocus)
  591. End Sub
  592.  
  593. Private Sub UserControl_ExitFocus()
  594.     m_hasFocus = False
  595.     If Not m_bEnabled Then Exit Sub
  596.     If Not m_Checked Then DrawButton (eNormal)
  597. End Sub
  598.  
  599. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  600.     With PropBag
  601.         .WriteProperty "Enabled", m_bEnabled, True
  602.         .WriteProperty "Font", UserControl.Font, Ambient.Font
  603.         .WriteProperty "Caption", m_Caption, UserControl.Name
  604.         .WriteProperty "IconHighLite", m_bIconHighLite, False
  605.         .WriteProperty "IconHighLiteColor", m_lIconHighLiteColor, &HFF00&
  606.         .WriteProperty "CaptionHighLite", m_bCaptionHighLite, False
  607.         .WriteProperty "CaptionHighLiteColor", m_lCaptionHighLiteColor, &HFF00&
  608.         .WriteProperty "ForeColor", m_ForeColor, m_def_ForeColor
  609.         .WriteProperty "Picture", m_StdPicture, Nothing
  610.         .WriteProperty "PictureAlignment", m_PictureAlignment, m_def_PictureAlignment
  611.         .WriteProperty "Style", m_Style, 0
  612.         .WriteProperty "Checked", m_Checked
  613.         .WriteProperty "ColorButtonHover", m_ColorButtonHover
  614.         .WriteProperty "ColorButtonUp", m_ColorButtonUp
  615.         .WriteProperty "ColorButtonDown", m_ColorButtonDown
  616.         .WriteProperty "BorderBrightness", m_BorderBrightness
  617.         .WriteProperty "ColorBright", m_ColorBright
  618.         .WriteProperty "DisplayHand", m_DisplayHand
  619.         .WriteProperty "ColorScheme", m_ColorScheme
  620.     End With
  621. End Sub
  622.  
  623. Private Sub UserControl_Resize()
  624.     Init_Style
  625.     DrawButton (eNormal)
  626. End Sub
  627.  
  628. Private Sub UserControl_Show()
  629.     Init_Style
  630.     DrawButton (eNormal)
  631. End Sub
  632.  
  633. Private Sub DrawButton(vState As eState)
  634.     If m_Checked Then vState = eChecked
  635.     If m_InitCompleted Then
  636.         UserControl.Picture = LoadPicture("")
  637.         Select Case m_Style
  638.             Case XP_Button
  639.                 DrawXPButton vState
  640.             Case Crystal, Mac, WMP, Mac_Variation, Iceblock
  641.                 DrawCrystalButton vState
  642.             Case Plastic
  643.                 DrawPlasticButton vState
  644.             Case XP_ToolBarButton
  645.                 DrawXPToolbarButton vState
  646.         End Select
  647.         DrawIconWCaption vState
  648.     End If
  649. End Sub
  650.  
  651. Public Sub DrawIconWCaption(vState As eState)
  652.     Dim pW As Long, pH As Long, lW As Long, lH As Long
  653.     Dim StartX As Long, StartY As Long, lBrush As Long, lFlags As Long
  654.     Dim lTemp As Long, XCoord As Long, YCoord As Long
  655.     
  656.     If Not m_StdPicture Is Nothing Then
  657.         pW = ScaleX(m_StdPicture.Width, vbHimetric, vbPixels)
  658.         pH = ScaleY(m_StdPicture.Height, vbHimetric, vbPixels)
  659.     End If
  660.     
  661.     If LenB(m_Caption) Then
  662.         lW = TextWidth(m_Caption)
  663.         lH = TextHeight(m_Caption)
  664.     End If
  665.     
  666.     Select Case m_PictureAlignment
  667.         Case Is = PIC_TOP
  668.             StartX = ((ScaleWidth - pW) \ 2) + 1
  669.             StartY = (ScaleHeight - (pH + lH)) \ 2 + 1
  670.             XCoord = Abs(ScaleWidth \ 2 - lW \ 2)
  671.             YCoord = Abs(ScaleHeight \ 2 + pH \ 2 - lH \ 2)
  672.         Case Is = PIC_BOTTOM
  673.             StartX = (ScaleWidth - pW) \ 2
  674.             StartY = (ScaleHeight - (pH - lH)) \ 2 + 1
  675.             XCoord = Abs(ScaleWidth \ 2 - lW \ 2)
  676.             YCoord = Abs(ScaleHeight \ 2 - (pH + lH) \ 2)
  677.         Case Is = PIC_LEFT
  678.             If CornerRadius Then StartX = CornerRadius Else StartX = 8
  679.             StartY = (ScaleHeight - pH) \ 2 + 1
  680.             XCoord = Abs(ScaleWidth \ 2 - lW \ 2)
  681.             YCoord = Abs(ScaleHeight \ 2 - lH \ 2)
  682.         Case Is = PIC_RIGHT
  683.             If CornerRadius Then StartX = ScaleWidth - CornerRadius - pW Else StartX = ScaleWidth - 8 - pW
  684.             StartY = (ScaleHeight - pH) \ 2 + 1
  685.             XCoord = Abs(ScaleWidth \ 2 - lW \ 2)
  686.             YCoord = Abs(ScaleHeight \ 2 - lH \ 2)
  687.     End Select
  688.     If vState = ePressed Then
  689.         StartX = StartX + 1: XCoord = XCoord + 1
  690.         StartY = StartY + 1: YCoord = YCoord + 1
  691.     End If
  692.     If m_bEnabled Then lFlags = DST_PREFIXTEXT Or DSS_NORMAL Else lFlags = DST_PREFIXTEXT Or DSS_DISABLED
  693.     
  694.     If vState = eHover And m_bCaptionHighLite Then
  695.         lTemp = UserControl.ForeColor
  696.         UserControl.ForeColor = m_lCaptionHighLiteColor
  697.     End If
  698.     If LenB(m_Caption) Then Call DrawStateText(hdc, 0&, 0&, m_Caption, Len(m_Caption), _
  699.                XCoord, YCoord, 0&, 0&, lFlags)
  700.     'Return the old forecolor state
  701.     If vState = eHover And m_bCaptionHighLite Then UserControl.ForeColor = lTemp
  702.     
  703.     If Not m_StdPicture Is Nothing Then
  704.         If m_StdPicture.Type = vbPicTypeBitmap Then
  705.             lFlags = DST_BITMAP
  706.         ElseIf m_StdPicture.Type = vbPicTypeIcon Then
  707.             lFlags = DST_ICON
  708.         End If
  709.         If Not m_bEnabled Then
  710.             lFlags = lFlags Or DSS_DISABLED 'Draw disabled
  711.         ElseIf vState = eHover And m_bIconHighLite Then
  712.             lBrush = CreateSolidBrush(m_lIconHighLiteColor)
  713.             lFlags = lFlags Or DSS_MONO 'Draw highlighted
  714.         End If
  715.         With m_StdPicture
  716.             DrawState hdc, lBrush, 0, .Handle, 0, CLng(StartX), _
  717.                     CLng(StartY), .Width, .Height, lFlags
  718.         End With
  719.         'm_StdPicture.Render Usercontrol.hDC, CLng(StartX), CLng(StartY), CLng(pW), CLng(pH), _
  720.                     0, m_StdPicture.Height, m_StdPicture.Width, -m_StdPicture.Height, ByVal 0&
  721.         If vState = eHover And m_bIconHighLite Then DeleteObject lBrush
  722.     End If
  723.     
  724.     UserControl.Refresh
  725. End Sub
  726.  
  727. Private Function DrawXPToolbarButton(vState As eState)
  728. Dim i As Long
  729. Dim r1 As Long, g1 As Long, b1 As Long
  730. Dim r2 As Long, g2 As Long, b2 As Long
  731. Dim uH As Long, uW As Long
  732.     uH = ScaleHeight - 1
  733.     uW = ScaleWidth - 1
  734.     On Error Resume Next
  735.         Line (0, 0)-(uW, uH), Parent.BackColor, BF
  736.     On Error GoTo 0
  737.     If vState = ePressed Then
  738.         r1 = 220: g1 = 218: b1 = 209
  739.         r2 = 231: g2 = 230: b2 = 224
  740.         For i = 0 To 3
  741.             Line (0, 1 + i)-(uW, 1 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
  742.         Next
  743.         r1 = 231: g1 = 230: b1 = 224
  744.         r2 = 225: g2 = 224: b2 = 216
  745.         For i = 4 To uH - 4
  746.             Line (0, i)-(uW, i), RGB(r2 * (i / (uH - 6)) + r1 - (r1 * (i / (uH - 6))), g2 * (i / (uH - 6)) + g1 - (g1 * (i / (uH - 6))), b2 * (i / (uH - 6)) + b1 - (b1 * (i / (uH - 6))))
  747.         Next
  748.         r1 = 225: g1 = 224: b1 = 216
  749.         r2 = 235: g2 = 234: b2 = 229
  750.         For i = 0 To 3
  751.             Line (0, uH - 4 + i)-(uW, uH - 4 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
  752.         Next
  753.         PSet (1, 0), RGB(215, 215, 204): PSet (0, 1), RGB(215, 215, 204)
  754.         Line (0, 2)-(2, 0), RGB(179, 179, 168) '7617536
  755.         Line (2, 0)-(uW - 2, 0), RGB(157, 157, 146)
  756.         PSet (uW - 1, 0), RGB(215, 215, 204): PSet (uW, 1), RGB(215, 215, 204)
  757.         Line (uW - 2, 0)-(uW, 2), RGB(179, 179, 168) '7617536
  758.         Line (uW, 2)-(uW, uH - 2), RGB(157, 157, 146)
  759.         PSet (uW, uH - 1), RGB(215, 215, 204): PSet (uW - 1, uH), RGB(215, 215, 204)
  760.         Line (uW, uH - 2)-(uW - 2, uH), RGB(179, 179, 168) ' 7617536
  761.         Line (uW - 2, uH)-(2, uH), RGB(157, 157, 146)
  762.         PSet (1, uH), RGB(215, 215, 204): PSet (0, uH - 1), RGB(215, 215, 204)
  763.         Line (2, uH)-(0, uH - 2), RGB(179, 179, 168) '7617536
  764.         Line (0, uH - 2)-(0, 2), RGB(157, 157, 146)
  765.     ElseIf vState = eHover Then
  766.         r1 = 254: g1 = 254: b1 = 253
  767.         r2 = 252: g2 = 252: b2 = 249
  768.         For i = 0 To 3
  769.             Line (0, 1 + i)-(uW, 1 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
  770.         Next
  771.         r1 = 252: g1 = 252: b1 = 249
  772.         r2 = 238: g2 = 237: b2 = 229
  773.         For i = 4 To uH - 4
  774.             Line (0, i)-(uW, i), RGB(r2 * (i / (uH - 6)) + r1 - (r1 * (i / (uH - 6))), g2 * (i / (uH - 6)) + g1 - (g1 * (i / (uH - 6))), b2 * (i / (uH - 6)) + b1 - (b1 * (i / (uH - 6))))
  775.         Next
  776.         r1 = 238: g1 = 237: b1 = 229
  777.         r2 = 215: g2 = 210: b2 = 198
  778.         For i = 0 To 3
  779.             Line (0, uH - 4 + i)-(uW, uH - 4 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
  780.         Next
  781.         
  782.         PSet (1, 0), RGB(232, 232, 221): PSet (0, 1), RGB(232, 232, 221)
  783.         Line (0, 2)-(2, 0), RGB(216, 216, 205) '7617536
  784.         Line (2, 0)-(uW - 2, 0), RGB(206, 206, 195)
  785.         PSet (uW - 1, 0), RGB(232, 232, 221): PSet (uW, 1), RGB(232, 232, 221)
  786.         Line (uW - 2, 0)-(uW, 2), RGB(216, 216, 205) '7617536
  787.         Line (uW, 2)-(uW, uH - 2), RGB(206, 206, 195)
  788.         PSet (uW, uH - 1), RGB(232, 232, 221): PSet (uW - 1, uH), RGB(232, 232, 221)
  789.         Line (uW, uH - 2)-(uW - 2, uH), RGB(216, 216, 205) ' 7617536
  790.         Line (uW - 2, uH)-(2, uH), RGB(206, 206, 195)
  791.         PSet (1, uH), RGB(232, 232, 221): PSet (0, uH - 1), RGB(232, 232, 221)
  792.         Line (2, uH)-(0, uH - 2), RGB(216, 216, 205) '7617536
  793.         Line (0, uH - 2)-(0, 2), RGB(206, 206, 195)
  794.     ElseIf vState = eChecked Then
  795.         Line (1, 1)-(uW - 1, uH - 1), vbWhite, BF
  796.         PSet (1, 0), RGB(203, 213, 214): PSet (0, 1), RGB(203, 213, 214)
  797.         Line (0, 2)-(2, 0), RGB(152, 175, 190) '7617536
  798.         Line (2, 0)-(uW - 2, 0), RGB(122, 152, 175)
  799.         PSet (uW - 1, 0), RGB(203, 213, 214): PSet (uW, 1), RGB(203, 213, 214)
  800.         Line (uW - 2, 0)-(uW, 2), RGB(152, 175, 190) '7617536
  801.         Line (uW, 2)-(uW, uH - 2), RGB(122, 152, 175)
  802.         PSet (uW, uH - 1), RGB(203, 213, 214): PSet (uW - 1, uH), RGB(203, 213, 214)
  803.         Line (uW, uH - 2)-(uW - 2, uH), RGB(152, 175, 190) ' 7617536
  804.         Line (uW - 2, uH)-(2, uH), RGB(122, 152, 175)
  805.         PSet (1, uH), RGB(203, 213, 214): PSet (0, uH - 1), RGB(203, 213, 214)
  806.         Line (2, uH)-(0, uH - 2), RGB(152, 175, 190) '7617536
  807.         Line (0, uH - 2)-(0, 2), RGB(122, 152, 175)
  808.     End If
  809. End Function
  810.  
  811. Private Function DrawXPButton(vState As eState)
  812. Dim i As Long
  813. Dim r1 As Long, g1 As Long, b1 As Long
  814. Dim r2 As Long, g2 As Long, b2 As Long
  815. Dim uH As Long, uW As Long
  816.     uH = ScaleHeight - 1
  817.     uW = ScaleWidth - 1
  818.     On Error Resume Next
  819.         Line (0, 0)-(uW, uH), Parent.BackColor, BF
  820.     On Error GoTo 0
  821.     If vState = ePressed Then
  822.         r1 = 209: g1 = 204: b1 = 193
  823.         r2 = 229: g2 = 228: b2 = 221
  824.         For i = 0 To 3
  825.             Line (0, 1 + i)-(uW, 1 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
  826.         Next
  827.         r1 = 229: g1 = 228: b1 = 221
  828.         r2 = 226: g2 = 226: b2 = 218
  829.         For i = 4 To uH - 4
  830.             Line (0, i)-(uW, i), RGB(r2 * (i / (uH - 6)) + r1 - (r1 * (i / (uH - 6))), g2 * (i / (uH - 6)) + g1 - (g1 * (i / (uH - 6))), b2 * (i / (uH - 6)) + b1 - (b1 * (i / (uH - 6))))
  831.         Next
  832.         r1 = 226: g1 = 226: b1 = 218
  833.         r2 = 242: g2 = 241: b2 = 238
  834.         For i = 0 To 4
  835.             Line (0, uH - 4 + i)-(uW, uH - 4 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
  836.         Next
  837.     Else
  838.         r1 = 236: g1 = 235: b1 = 230
  839.         r2 = 214: g2 = 208: b2 = 197
  840.         For i = 0 To uH - 3
  841.             Line (1, i)-(uW, i), RGB(r1 * (i / (uH - 3)) + 255 - (255 * (i / (uH - 3))), g1 * (i / (uH - 3)) + 255 - (255 * (i / (uH - 3))), b1 * (i / (uH - 3)) + 255 - (255 * (i / (uH - 3))))
  842.         Next
  843.     
  844.         For i = 0 To 3
  845.             Line (0, uH - 4 + i)-(uW, uH - 4 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
  846.         Next
  847.     End If
  848.     
  849.     Select Case vState
  850.         Case Is = eFocus
  851.             Line (0, 1)-(uW, 1), RGB(206, 231, 255)
  852.             Line (0, 2)-(uW, 2), RGB(188, 212, 246)
  853.             r1 = 188: g1 = 212: b1 = 246
  854.             r2 = 137: g2 = 173: b2 = 228
  855.             For i = 3 To uH - 3
  856.                 Line (0, i)-(3, i), RGB(r2 * (i / uH) + r1 - (r1 * (i / uH)), g2 * (i / uH) + g1 - (g1 * (i / uH)), b2 * (i / uH) + b1 - (b1 * (i / uH)))
  857.                 Line (uW - 2, i)-(uW, i), RGB(r2 * (i / uH) + r1 - (r1 * (i / uH)), g2 * (i / uH) + g1 - (g1 * (i / uH)), b2 * (i / uH) + b1 - (b1 * (i / uH)))
  858.             Next
  859.             Line (0, uH - 2)-(uW, uH - 2), RGB(137, 173, 228)
  860.             Line (0, uH - 1)-(uW, uH - 1), RGB(105, 130, 238)
  861.         Case Is = eHover
  862.             Line (0, 1)-(uW, 1), RGB(255, 240, 202)
  863.             Line (0, 2)-(uW, 2), RGB(253, 216, 137)
  864.             r1 = 253: g1 = 216: b1 = 137
  865.             r2 = 248: g2 = 178: b2 = 48
  866.             For i = 3 To uH - 3
  867.                 Line (0, i)-(3, i), RGB(r2 * (i / uH) + r1 - (r1 * (i / uH)), g2 * (i / uH) + g1 - (g1 * (i / uH)), b2 * (i / uH) + b1 - (b1 * (i / uH)))
  868.                 Line (uW - 2, i)-(uW, i), RGB(r2 * (i / uH) + r1 - (r1 * (i / uH)), g2 * (i / uH) + g1 - (g1 * (i / uH)), b2 * (i / uH) + b1 - (b1 * (i / uH)))
  869.             Next
  870.             Line (0, uH - 2)-(uW, uH - 2), RGB(248, 178, 48)
  871.             Line (0, uH - 1)-(uW, uH - 1), RGB(229, 151, 0)
  872.     End Select
  873.     
  874.     PSet (0, 1), RGB(122, 149, 168): PSet (1, 0), RGB(122, 149, 168)
  875.     Line (0, 2)-(2, 0), RGB(37, 87, 131) '7617536
  876.     Line (2, 0)-(uW - 2, 0), 7617536
  877.     PSet (uW - 1, 0), RGB(122, 149, 168): PSet (uW, 1), RGB(122, 149, 168)
  878.     Line (uW - 2, 0)-(uW, 2), RGB(37, 87, 131)  '7617536
  879.     Line (uW, 2)-(uW, uH - 2), 7617536
  880.     PSet (uW, uH - 1), RGB(122, 149, 168): PSet (uW - 1, uH), RGB(122, 149, 168)
  881.     Line (uW, uH - 2)-(uW - 2, uH), RGB(37, 87, 131) ' 7617536
  882.     Line (uW - 2, uH)-(2, uH), 7617536
  883.     PSet (1, uH), RGB(122, 149, 168): PSet (0, uH - 1), RGB(122, 149, 168)
  884.     Line (2, uH)-(0, uH - 2), RGB(37, 87, 131)  '7617536
  885.     Line (0, uH - 2)-(0, 2), 7617536
  886. End Function
  887.  
  888. Private Function DrawCrystalButton(vState As eState)
  889.     Dim CrystalParam As tCrystalParam
  890.     If m_Style = Mac Then 'Mac
  891.         'CrystalParam.Ref_MixColorFrom = 0 '20
  892.         CrystalParam.Ref_Intensity = 70 '50
  893.         CrystalParam.Ref_Left = (CornerRadius \ 3)
  894.         'CrystalParam.Ref_Top = 0
  895.         CrystalParam.Ref_Height = 12 'CornerRadius - 2
  896.         CrystalParam.Ref_Width = ScaleWidth + 2 * CornerRadius
  897.         CrystalParam.Ref_Radius = 10 'CornerRadius \ 2
  898.         CrystalParam.RadialGXPercent = 200
  899.         CrystalParam.RadialGYPercent = 100 - (7 * 100 \ ScaleHeight)
  900.         If CrystalParam.RadialGYPercent > 80 Then CrystalParam.RadialGYPercent = 80
  901.         CrystalParam.RadialGOffsetX = ScaleWidth / 2
  902.         CrystalParam.RadialGOffsetY = ScaleHeight
  903.         CrystalParam.RadialGIntensity = 130
  904.     ElseIf m_Style = WMP Then 'WMP
  905.         CrystalParam.Ref_Intensity = 40
  906.         CrystalParam.Ref_Left = -CornerRadius \ 2 - 1
  907.         CrystalParam.Ref_Top = -CornerRadius
  908.         CrystalParam.Ref_Height = (CornerRadius) + 1
  909.         CrystalParam.Ref_Width = ScaleWidth + 2 * CornerRadius
  910.         CrystalParam.Ref_Radius = CornerRadius
  911.         CrystalParam.RadialGXPercent = 60
  912.         CrystalParam.RadialGYPercent = 60
  913.         CrystalParam.RadialGOffsetX = ScaleWidth / 2
  914.         CrystalParam.RadialGOffsetY = ScaleHeight
  915.         CrystalParam.RadialGIntensity = 130
  916.     ElseIf m_Style = Mac_Variation Then
  917.         CrystalParam.Ref_Intensity = 70
  918.         CrystalParam.Ref_Left = (CornerRadius \ 3) - 1
  919.         CrystalParam.Ref_Height = CornerRadius
  920.         CrystalParam.Ref_Width = ScaleWidth + 2 * CornerRadius
  921.         'CrystalParam.Ref_Top = 0
  922.         CrystalParam.Ref_Radius = (CornerRadius \ 2)
  923.         CrystalParam.RadialGXPercent = 200
  924.         CrystalParam.RadialGYPercent = 70
  925.         CrystalParam.RadialGOffsetX = ScaleWidth / 2
  926.         CrystalParam.RadialGOffsetY = ScaleHeight
  927.         CrystalParam.RadialGIntensity = 130
  928.     ElseIf m_Style = Crystal Then
  929.         CrystalParam.Ref_Intensity = 50
  930.         CrystalParam.Ref_Left = CornerRadius \ 2
  931.         CrystalParam.Ref_Height = CornerRadius * 1.1
  932.         CrystalParam.Ref_Width = ScaleWidth + 2 * CornerRadius
  933.         CrystalParam.Ref_Top = 1
  934.         CrystalParam.Ref_Radius = CornerRadius \ 2
  935.         CrystalParam.RadialGXPercent = 300
  936.         CrystalParam.RadialGYPercent = 60
  937.         CrystalParam.RadialGOffsetX = ScaleWidth / 2
  938.         CrystalParam.RadialGOffsetY = ScaleHeight
  939.         CrystalParam.RadialGIntensity = 120
  940.     ElseIf m_Style = Iceblock Then
  941.         CrystalParam.Ref_Intensity = 50
  942.         CrystalParam.Ref_Left = CornerRadius / 2
  943.         CrystalParam.Ref_Top = 2
  944.         CrystalParam.Ref_Height = CornerRadius + 1
  945.         CrystalParam.Ref_Width = ScaleWidth - CornerRadius
  946.         CrystalParam.Ref_Radius = CornerRadius / 2
  947.         CrystalParam.RadialGXPercent = 60
  948.         CrystalParam.RadialGYPercent = 60
  949.         CrystalParam.RadialGOffsetX = ScaleWidth / 2
  950.         CrystalParam.RadialGOffsetY = ScaleHeight / 2
  951.         CrystalParam.RadialGIntensity = 100
  952.     End If
  953.     Select Case vState
  954.         Case eHover
  955.             DrawCrystal ScaleWidth, ScaleHeight, m_ColorButtonHover, CrystalParam
  956.         Case ePressed, eChecked
  957.             DrawCrystal ScaleWidth, ScaleHeight, ColorButtonDown, CrystalParam
  958.         Case eNormal, eFocus
  959.             DrawCrystal ScaleWidth, ScaleHeight, m_ColorButtonUp, CrystalParam
  960.     End Select
  961. End Function
  962.  
  963. Private Sub DrawCrystal(lWidth As Long, lHeight As Long, ByVal Color As Long, CrystalParam As tCrystalParam)
  964. Dim i As Long, j As Long, ptColor As Long, ColorBright As Long
  965. Dim RGXPercent As Single, RGYPercent As Single, RadialGradient As Long
  966. Dim hHlRgn As Long, Bordercolor As Long, nBrush As Long, ClientRct As Rect
  967.     
  968.     If CornerRadius < 1 Then CornerRadius = 1
  969.     ColorBright = m_ColorBright
  970.     'In Disabled state Color = 11583680 (light gray)
  971.     'and ColorBright = vbWhite
  972.     If Not m_bEnabled Then Color = 11583680: ColorBright = vbWhite
  973.     
  974.     RGYPercent = (100 - CrystalParam.RadialGYPercent) / (lHeight * 2)
  975.     RGXPercent = (100 - CrystalParam.RadialGXPercent) / lWidth
  976.     
  977.     If m_BorderBrightness >= 0 Then
  978.         Bordercolor = BlendColors(Color, vbWhite, m_BorderBrightness)
  979.     Else
  980.         Bordercolor = BlendColors(Color, vbBlack, -m_BorderBrightness)
  981.     End If
  982.     'Create Highlite region (hHlRgn), we will use PtInRegion to
  983.     'check if we are inside the highlite Rounded rectangle
  984.     'you could simply use IsInRoundRect(i ,j ,CrystalParam.Ref_Left, CrystalParam.Ref_Top, CrystalParam.Ref_Width, CrystalParam.Ref_Height, CrystalParam.Ref_Radius * 2, CrystalParam.Ref_Radius * 2)
  985.     'instead of PtInRegion and remove these lines, but will be slower.
  986.     hHlRgn = CreateRoundRectRgn(CrystalParam.Ref_Left, CrystalParam.Ref_Top, CrystalParam.Ref_Width, CrystalParam.Ref_Height, CrystalParam.Ref_Radius * 2, CrystalParam.Ref_Radius * 2)
  987.     'Paint the Background Color
  988.     SetRect ClientRct, 0, 0, lWidth, lHeight
  989.     nBrush = CreateSolidBrush(Color)
  990.     FillRect hdc, ClientRct, nBrush
  991.     DeleteObject nBrush
  992.     'Draw a radial Gradient
  993.     DrawElipse hdc, CrystalParam, lWidth, lHeight, Color, ColorBright
  994.     For j = 0 To lHeight
  995.         For i = 0 To lWidth \ 2
  996.             If PtInRegion(hButtonRegion, i, j) Then
  997.                 'We are inside the button
  998.                 If PtInRegion(hHlRgn, i, j) Then
  999.                     ptColor = BlendColors(vbWhite, Color, CrystalParam.Ref_MixColorFrom + j * CrystalParam.Ref_Intensity \ CornerRadius)
  1000.                     Line (i, j)-(lWidth - i + 1, j), ptColor
  1001.                     i = 0: j = j + 1
  1002.                 End If
  1003.             Else
  1004.                 'this draw a thin border
  1005.                 SetPixelV hdc, i, j, Bordercolor
  1006.                 SetPixelV hdc, lWidth - i, j, Bordercolor
  1007.             End If
  1008.         Next i
  1009.     Next j
  1010.     DeleteObject hHlRgn
  1011. End Sub
  1012.  
  1013. Private Sub DrawElipse(lhDC As Long, CrystalParam As tCrystalParam, lWidth, lHeight, FromColor As Long, ToColor As Long)
  1014. Dim oldBrush As Long, newBrush As Long, newPen As Long, oldPen As Long
  1015. Dim incX As Single, incY As Single, RadX As Long, RadY As Long
  1016. Dim klr As Long, rc As Rect
  1017.     klr = 1
  1018.     RadX = CrystalParam.RadialGXPercent * lWidth / 100
  1019.     RadY = CrystalParam.RadialGYPercent * lHeight / 100
  1020.     SetRect rc, CrystalParam.RadialGOffsetX - RadX, CrystalParam.RadialGOffsetY - RadY, _
  1021.                 CrystalParam.RadialGOffsetX + RadX, CrystalParam.RadialGOffsetY + RadY
  1022.     incX = 1: incY = 1
  1023.     If RadX > RadY Then
  1024.         incX = (RadX / RadY)
  1025.     Else
  1026.         incY = (RadY / RadX)
  1027.     End If
  1028.     newBrush = CreateSolidBrush(FromColor)
  1029.     oldBrush = SelectObject(lhDC, newBrush)
  1030.     newPen = CreatePen(5, 0, FromColor)
  1031.     oldPen = SelectObject(lhDC, newPen)
  1032.     Do Until Not IsRectEmpty(rc) = 0
  1033.         Ellipse lhDC, rc.Left, rc.Top, rc.Right, rc.Bottom
  1034.         InflateRect rc, -incX, -incY
  1035.         klr = klr + 1
  1036.         newBrush = CreateSolidBrush(BlendColors(FromColor, ToColor, klr * CrystalParam.RadialGIntensity / RadY))
  1037.         DeleteObject SelectObject(lhDC, newBrush)
  1038.     Loop
  1039.     DeleteObject SelectObject(lhDC, oldBrush)
  1040.     DeleteObject SelectObject(lhDC, oldPen)
  1041. End Sub
  1042.  
  1043. Private Function DrawPlasticButton(vState As eState)
  1044.     Select Case vState
  1045.         Case eHover
  1046.             DrawPlastic 0, 0, ScaleWidth - 1, ScaleHeight - 1, m_ColorButtonHover
  1047.         Case ePressed, eChecked
  1048.             DrawPlastic 0, 0, ScaleWidth - 1, ScaleHeight - 1, ColorButtonDown
  1049.         Case eNormal, eFocus
  1050.             DrawPlastic 0, 0, ScaleWidth - 1, ScaleHeight - 1, m_ColorButtonUp
  1051.     End Select
  1052. End Function
  1053.  
  1054. Private Sub DrawPlastic(X As Long, Y As Long, lWidth As Long, lHeight As Long, Color As Long)
  1055. Dim i As Long, j As Long, HighlightColor As Long, ShadowColor As Long
  1056. Dim ptColor As Long, LinearGPercent As Long
  1057.     ShadowColor = BlendColors(vbBlack, Color, 50)
  1058.     
  1059.     For j = 0 To lHeight
  1060.         If j < CornerRadius Then
  1061.             HighlightColor = BlendColors(vbWhite, Color, j * 30 \ CornerRadius)
  1062.         End If
  1063.         LinearGPercent = Abs((2 * j - lHeight) * 100 \ lHeight)
  1064.         For i = 0 To lWidth \ 2
  1065.             If IsInRoundRect(i, j, 1, 1, lWidth - 2, lHeight - 2, CornerRadius) Then
  1066.                 'Drawing the button properly
  1067.                 If IsInRoundRect(i, j, 4, 2, lWidth - CornerRadius, 2 * CornerRadius - 1, 2 * CornerRadius \ 3) _
  1068.                 And Not IsInRoundRect(i, j, 4, CornerRadius \ 2, lWidth - CornerRadius, 2 * CornerRadius - 1, 2 * CornerRadius \ 3) Then
  1069.                     ptColor = HighlightColor 'draw reflected highlight
  1070.                 Else
  1071.                     ptColor = BlendColors(Color, m_ColorBright, LinearGPercent)
  1072.                 End If
  1073.                 SetPixelV hdc, i, j, ptColor
  1074.                 SetPixelV hdc, lWidth - i, j, ptColor
  1075.             ElseIf IsInRoundRect(i, j, 0, 0, lWidth, lHeight, CornerRadius) Then
  1076.                 'this draw a thin border
  1077.                 SetPixelV hdc, i, j, ShadowColor
  1078.                 SetPixelV hdc, lWidth - i, j, ShadowColor
  1079.             End If
  1080.         Next i
  1081.     Next j
  1082. End Sub
  1083.  
  1084. '/----------------------------------------------------------------------------------/
  1085. '/                                                                                  /
  1086. '/ Init_Style                                                                       /
  1087. '/ -------------------                                                              /
  1088. '/ Description:                                                                     /
  1089. '/                                                                                  /
  1090. '/ Init_Style will create the window region according to the button style           /
  1091. '/ and will be responsible of storing the same region (but without the border)      /
  1092. '/ in hButtonRegion. This will be used later to determine if a point                /
  1093. '/ is inside the button region.                                                     /
  1094. '/----------------------------------------------------------------------------------/
  1095. Private Sub Init_Style()
  1096. Dim lCornerRad As Long
  1097.     'Remove the older Region
  1098.     If hButtonRegion Then DeleteObject hButtonRegion
  1099.     Select Case m_Style
  1100.         Case Crystal, WMP, Mac_Variation
  1101.             lCornerRad = SetBound(ScaleHeight \ 2 + 1, 1, ScaleWidth \ 2)
  1102.         Case Mac
  1103.             lCornerRad = 12
  1104.         Case Iceblock
  1105.             lCornerRad = SetBound(ScaleHeight \ 4 + 1, 1, ScaleWidth \ 4)
  1106.         Case Plastic
  1107.             lCornerRad = SetBound(ScaleHeight \ 3, 1, ScaleWidth \ 3)
  1108.     End Select
  1109.  
  1110.     If m_Style = Crystal Or m_Style = WMP Or m_Style = Mac Or _
  1111.         m_Style = Mac_Variation Or m_Style = Plastic Or m_Style = Iceblock Then
  1112.         hButtonRegion = CreateRoundedRegion(0, 0, ScaleWidth, ScaleHeight, lCornerRad)
  1113.         
  1114.         'Set the Button Region
  1115.         Call SetWindowRgn(hWnd, hButtonRegion, True)
  1116.         DeleteObject hButtonRegion
  1117.         'Store the region but exclude the border
  1118.         hButtonRegion = CreateRoundedRegion(1, 1, ScaleWidth - 2, ScaleHeight - 2, lCornerRad)
  1119.     Else
  1120.         Call SetWindowRgn(hWnd, 0, True)
  1121.     End If
  1122. End Sub
  1123.  
  1124. '/----------------------------------------------------------------------------------/
  1125. '/                                                                                  /
  1126. '/ CreateRoundedRegion                                                              /
  1127. '/ -------------------                                                              /
  1128. '/ Description:                                                                     /
  1129. '/                                                                                  /
  1130. '/ CreateRoundedRegion returns a rounded region based on a given Width, Height      /
  1131. '/ and a CornerRadius. We will use this function instead of normal CreateRoundRect  /
  1132. '/ because this will give us a better rounded rectangle for our purposes.           /
  1133. '/----------------------------------------------------------------------------------/
  1134. Private Function CreateRoundedRegion(X As Long, Y As Long, lWidth As Long, lHeight As Long, Radius As Long) As Long
  1135. Dim i As Long, j As Long, i2 As Long, j2 As Long, i3 As Long, j3 As Long
  1136. Dim hRgn As Long
  1137.     CornerRadius = Radius
  1138.     If CornerRadius < 1 Then CornerRadius = 1
  1139.     '/* Create initial region
  1140.     hRgn = CreateRectRgn(0, 0, X + lWidth, Y + lHeight)
  1141.     For j = 0 To Y + lHeight
  1142.         For i = 0 To (X + lWidth) \ 2
  1143.             If Not IsInRoundRect(i, j, X, Y, lWidth, lHeight, CornerRadius) Then
  1144.                 '/* substract the pixels outside of the rounded rectangle
  1145.                 '/* (it doesn't exclude the border)
  1146.                 If Not j = j2 Then
  1147.                     '*** If 2 * i2 <> Width Then i2 = i2 + 1
  1148.                     ExcludePixelsFromRegion hRgn, X + lWidth - i2, j2, lWidth - i, j
  1149.                     If Not 2 * i2 = X + lWidth Then
  1150.                         i2 = i2 + 1
  1151.                     End If
  1152.                     ExcludePixelsFromRegion hRgn, i, j, i2, j2
  1153.                 End If
  1154.                 i2 = i
  1155.                 j2 = j
  1156.             End If
  1157.         Next i
  1158.     Next j
  1159.     CreateRoundedRegion = hRgn
  1160. End Function
  1161.  
  1162. Private Sub ExcludePixelsFromRegion(hRgn As Long, X1 As Long, Y1 As Long, X2 As Long, Y2 As Long)
  1163.     Dim hRgnTemp As Long
  1164.     hRgnTemp = CreateRectRgn(X1, Y1, X2, Y2)
  1165.     CombineRgn hRgn, hRgn, hRgnTemp, RGN_XOR
  1166.     DeleteObject hRgnTemp
  1167. End Sub
  1168.  
  1169. Private Function IsInRoundRect(i As Long, j As Long, X As Long, Y As Long, lWidth As Long, lHeight As Long, Radius As Long) As Boolean
  1170. Dim offX As Long, offY As Long
  1171.     offX = i - X
  1172.     offY = j - Y
  1173.     If offY > Radius And offY + Radius < lHeight And offX > Radius And offX + Radius < lWidth Then
  1174.         '/* This is to catch early most cases
  1175.         IsInRoundRect = True
  1176.     ElseIf offX < Radius And offY <= Radius Then
  1177.         If IsInCircle(offX - Radius, offY, Radius) Then IsInRoundRect = True
  1178.     ElseIf offX + Radius > lWidth And offY <= Radius Then
  1179.         If IsInCircle(offX - lWidth + Radius, offY, Radius) Then IsInRoundRect = True
  1180.     ElseIf offX < Radius And offY + Radius >= lHeight Then
  1181.         If IsInCircle(offX - Radius, offY - lHeight + Radius * 2, Radius) Then IsInRoundRect = True
  1182.     ElseIf offX + Radius > lWidth And offY + Radius >= lHeight Then
  1183.         If IsInCircle(offX - lWidth + Radius, offY - lHeight + Radius * 2, Radius) Then IsInRoundRect = True
  1184.     Else
  1185.         If offX > 0 And offX < lWidth And offY > 0 And offY < lHeight Then IsInRoundRect = True
  1186.     End If
  1187. End Function
  1188.  
  1189. Private Function IsInCircle(ByRef X As Long, ByRef Y As Long, ByRef r As Long) As Boolean
  1190. Dim lResult As Long
  1191.     '/* this detect a circunference centered on y=-r and x=0
  1192.     lResult = (r * r) - (X * X)
  1193.     If lResult >= 0 Then
  1194.         lResult = Sqr(lResult)
  1195.         If Abs(Y - r) < lResult Then IsInCircle = True
  1196.     End If
  1197. End Function
  1198.  
  1199. Public Function BlendColors(ByRef Color1 As Long, ByRef Color2 As Long, ByRef Percentage As Long) As Long
  1200. Dim r(2) As Long, g(2) As Long, b(2) As Long
  1201.     
  1202.     Percentage = SetBound(Percentage, 0, 100)
  1203.     
  1204.     GetRGB r(0), g(0), b(0), Color1
  1205.     GetRGB r(1), g(1), b(1), Color2
  1206.     
  1207.     r(2) = r(0) + (r(1) - r(0)) * Percentage \ 100
  1208.     g(2) = g(0) + (g(1) - g(0)) * Percentage \ 100
  1209.     b(2) = b(0) + (b(1) - b(0)) * Percentage \ 100
  1210.     
  1211.     BlendColors = RGB(r(2), g(2), b(2))
  1212. End Function
  1213.  
  1214. Private Function SetBound(ByRef Num As Long, ByRef MinNum As Long, ByRef MaxNum As Long) As Long
  1215.     If Num < MinNum Then
  1216.         SetBound = MinNum
  1217.     ElseIf Num > MaxNum Then
  1218.         SetBound = MaxNum
  1219.     Else
  1220.         SetBound = Num
  1221.     End If
  1222. End Function
  1223.  
  1224. Public Sub GetRGB(r As Long, g As Long, b As Long, Color As Long)
  1225. Dim TempValue As Long
  1226.     TranslateColor Color, 0, TempValue
  1227.     r = TempValue And &HFF&
  1228.     g = (TempValue And &HFF00&) \ &H100&
  1229.     b = (TempValue And &HFF0000) \ &H10000
  1230. End Sub
  1231.  
  1232. Private Function HiWord(lDWord As Long) As Integer
  1233.   HiWord = (lDWord And &HFFFF0000) \ &H10000
  1234. End Function
  1235.  
  1236. Private Function LoWord(lDWord As Long) As Integer
  1237.   If lDWord And &H8000& Then
  1238.     LoWord = lDWord Or &HFFFF0000
  1239.   Else
  1240.     LoWord = lDWord And &HFFFF&
  1241.   End If
  1242. End Function
  1243. 'Read the properties from the property bag - also, a good place to start the subclassing (if we're running)
  1244. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  1245.   Dim w As Long
  1246.   Dim h As Long
  1247.   Dim s As String
  1248.   
  1249.     With PropBag
  1250.         m_bEnabled = .ReadProperty("Enabled", True)
  1251.         Set UserControl.Font = .ReadProperty("Font", Ambient.Font)
  1252.         m_Caption = .ReadProperty("Caption", UserControl.Name)
  1253.         m_bCaptionHighLite = .ReadProperty("CaptionHighLite", False)
  1254.         m_lCaptionHighLiteColor = .ReadProperty("CaptionHighLiteColor", &HFF00&)
  1255.         m_bIconHighLite = .ReadProperty("IconHighLite", False)
  1256.         m_lIconHighLiteColor = .ReadProperty("IconHighLiteColor", &HFF00&)
  1257.         m_ForeColor = .ReadProperty("ForeColor", m_def_ForeColor)
  1258.         Set m_StdPicture = .ReadProperty("Picture", Nothing)
  1259.         m_PictureAlignment = .ReadProperty("PictureAlignment", m_def_PictureAlignment)
  1260.         m_Style = .ReadProperty("Style", 0)
  1261.         m_Checked = .ReadProperty("Checked", m_Checked)
  1262.         m_ColorButtonHover = .ReadProperty("ColorButtonHover", &HFFC090)
  1263.         m_ColorButtonUp = .ReadProperty("ColorButtonUp", &HE99950)
  1264.         m_ColorButtonDown = .ReadProperty("ColorButtonDown", &HE99950)
  1265.         m_ColorBright = .ReadProperty("ColorBright", &HFFEDB0)
  1266.         m_BorderBrightness = .ReadProperty("BorderBrightness", 0)
  1267.         m_DisplayHand = .ReadProperty("DisplayHand", False)
  1268.         m_ColorScheme = .ReadProperty("ColorScheme", 0)
  1269.     End With
  1270.     If m_DisplayHand Then UserControl.MousePointer = vbCustom Else UserControl.MousePointer = vbArrow
  1271.     UserControl.ForeColor = m_ForeColor
  1272.     
  1273.   If Ambient.UserMode Then                                                              'If we're not in design mode
  1274.     bTrack = True
  1275.     bTrackUser32 = IsFunctionExported("TrackMouseEvent", "User32")
  1276.   
  1277.     If Not bTrackUser32 Then
  1278.       If Not IsFunctionExported("_TrackMouseEvent", "Comctl32") Then
  1279.         bTrack = False
  1280.       End If
  1281.     End If
  1282.   
  1283.     If bTrack Then
  1284.       'OS supports mouse leave, so let's subclass for it
  1285.       With UserControl
  1286.         'Subclass the UserControl
  1287.         sc_Subclass .hWnd
  1288.         sc_AddMsg .hWnd, WM_PAINT, MSG_BEFORE
  1289.         sc_AddMsg .hWnd, WM_MOUSEMOVE
  1290.         sc_AddMsg .hWnd, WM_MOUSELEAVE
  1291.       End With
  1292.     End If
  1293.   End If
  1294.   m_InitCompleted = True
  1295. End Sub
  1296.  
  1297. 'The control is terminating - a good place to stop the subclasser
  1298. Private Sub UserControl_Terminate()
  1299.   sc_Terminate                                                              'Terminate all subclassing
  1300.   If hButtonRegion Then DeleteObject hButtonRegion
  1301. End Sub
  1302.  
  1303. 'Determine if the passed function is supported
  1304. Private Function IsFunctionExported(ByVal sFunction As String, ByVal sModule As String) As Boolean
  1305.   Dim hMod        As Long
  1306.   Dim bLibLoaded  As Boolean
  1307.  
  1308.   hMod = GetModuleHandleA(sModule)
  1309.  
  1310.   If hMod = 0 Then
  1311.     hMod = LoadLibraryA(sModule)
  1312.     If hMod Then
  1313.       bLibLoaded = True
  1314.     End If
  1315.   End If
  1316.  
  1317.   If hMod Then
  1318.     If GetProcAddress(hMod, sFunction) Then
  1319.       IsFunctionExported = True
  1320.     End If
  1321.   End If
  1322.  
  1323.   If bLibLoaded Then
  1324.     FreeLibrary hMod
  1325.   End If
  1326. End Function
  1327.  
  1328. 'Track the mouse leaving the indicated window
  1329. Private Sub TrackMouseLeave(ByVal lng_hWnd As Long)
  1330.   Dim tme As TRACKMOUSEEVENT_STRUCT
  1331.   
  1332.   If bTrack Then
  1333.     With tme
  1334.       .cbSize = Len(tme)
  1335.       .dwFlags = TME_LEAVE
  1336.       .hwndTrack = lng_hWnd
  1337.     End With
  1338.  
  1339.     If bTrackUser32 Then
  1340.       TrackMouseEvent tme
  1341.     Else
  1342.       TrackMouseEventComCtl tme
  1343.     End If
  1344.   End If
  1345. End Sub
  1346.  
  1347. '-SelfSub code------------------------------------------------------------------------------------
  1348. Private Function sc_Subclass(ByVal lng_hWnd As Long, _
  1349.                     Optional ByVal lParamUser As Long = 0, _
  1350.                     Optional ByVal nOrdinal As Long = 1, _
  1351.                     Optional ByVal oCallback As Object = Nothing, _
  1352.                     Optional ByVal bIdeSafety As Boolean = True) As Boolean 'Subclass the specified window handle
  1353. '*************************************************************************************************
  1354. '* lng_hWnd   - Handle of the window to subclass
  1355. '* lParamUser - Optional, user-defined callback parameter
  1356. '* nOrdinal   - Optional, ordinal index of the callback procedure. 1 = last private method, 2 = second last private method, etc.
  1357. '* oCallback  - Optional, the object that will receive the callback. If undefined, callbacks are sent to this object's instance
  1358. '* bIdeSafety - Optional, enable/disable IDE safety measures. NB: you should really only disable IDE safety in a UserControl for design-time subclassing
  1359. '*************************************************************************************************
  1360. Const CODE_LEN      As Long = 260                                           'Thunk length in bytes
  1361. Const MEM_LEN       As Long = CODE_LEN + (8 * (MSG_ENTRIES + 1))            'Bytes to allocate per thunk, data + code + msg tables
  1362. Const PAGE_RWX      As Long = &H40&                                         'Allocate executable memory
  1363. Const MEM_COMMIT    As Long = &H1000&                                       'Commit allocated memory
  1364. Const MEM_RELEASE   As Long = &H8000&                                       'Release allocated memory flag
  1365. Const IDX_EBMODE    As Long = 3                                             'Thunk data index of the EbMode function address
  1366. Const IDX_CWP       As Long = 4                                             'Thunk data index of the CallWindowProc function address
  1367. Const IDX_SWL       As Long = 5                                             'Thunk data index of the SetWindowsLong function address
  1368. Const IDX_FREE      As Long = 6                                             'Thunk data index of the VirtualFree function address
  1369. Const IDX_BADPTR    As Long = 7                                             'Thunk data index of the IsBadCodePtr function address
  1370. Const IDX_OWNER     As Long = 8                                             'Thunk data index of the Owner object's vTable address
  1371. Const IDX_CALLBACK  As Long = 10                                            'Thunk data index of the callback method address
  1372. Const IDX_EBX       As Long = 16                                            'Thunk code patch index of the thunk data
  1373. Const SUB_NAME      As String = "sc_Subclass"                               'This routine's name
  1374.   Dim nAddr         As Long
  1375.   Dim nID           As Long
  1376.   Dim nMyID         As Long
  1377.   
  1378.   If IsWindow(lng_hWnd) = 0 Then                                            'Ensure the window handle is valid
  1379.     zError SUB_NAME, "Invalid window handle"
  1380.     Ex 'T0'Thipx 'T0'Thvalid wind2E safe,o0'T-u,a4 e44444444 safe---------------
  1381.     $pIColor =UB_hen
  1382.         hButtonReW03, 213, 214)
  1383.         Line (uW - .mpWhe bf the Calcontrol is terminat uH :is terminat uH :is terminat uH :isg+1ine (u c .mp (u c .ion Then DeleteObject hBuW, 2), RGB(253, 216, 137)
  1384.   gggggcallbtlDWorusXall uW = Scaject_LEAVE
  1385.       .hwndTrack = lng_hWnd
  1386.     End With
  1387.  
  1388.     IslalFree funtonHover", &HFFC090)
  1389.         P uW = A090)90)
  1390. 'aO 40
  1391.         Crys0TR u4nunhwnH - 4 unk, data + cng_hWmCtl tmeCdow t)253, 216, 137)
  1392.   ggerminat uH o) .ion Then Delet6, 137)
  1393.   ggerminat uH o) .ion Theng, CrystalParam As tCrystalParam, lWidth, lHeigWIdpg) As BoWMf IsWindow(lng_hAs Long = 10                                            'Thunk data index of  vbWhite
  1394. ndex of  lse
  1395.  ina    Cre lHeigWI5  As ---nse
  1396.     LoWord = lDWord And &HFFFF&
  1397. 1ubclass
  1398.  ECam, lWidth,,,,,,,,,,,Thunk datat lHeigWIde window hHWnd
  1399.     End          4)) .ion Idpg) As BoWMf IsWindow(lng_hAs Long = FicDow(lng_hAs Long = FicDow(lng_hAs Long = FicDow(lng_hAs Long = FicDow(lng_hAs Long = FicDow(lng_hAs 47
  1400.   ggerm)'Ensure thr  'In Disabled state Color =0)
  1401. 'aO 40
  1402.         Co               s Long = FO         s   O   94_r As Long)
  1403. Dim oldBrush As Long, newBrush As Long, newPen As Long, oldPen As LonOed  As Boolean
  1404.  
  1405.   hMod = GetModuC  O   94_r As Long'Thunk data index of the CallWindowProc function address
  1406. ConwProc function afunction addresabled stx of tan(uW -ctiongng  uH)method, etc.IePaRGB                              Theng, CryDePaRGB     zError SUB_NAME, 77LonOed  As Boolean
  1407.  
  1408.   hMod = GetModuC4   Theng, CryDePaRGBect hn Disabled state Color =0)
  1409. 'aO 40
  1410.      ----------i Get,lingng nb= 2End I-------ist IDX_FREE      Af the SetWindowsLob= 2oaded  ALd I---eng-----------roc function adiLoneb2s we're rusdBrush AsC22222222AALd s Belr-----g     As Long = &H40&                         t uH :isg+1-roc function adistalParam As tCrystalPi0ram As tHeigW-roc m AA----E    As Long = 3                              Lon-roc functed memory flag
  1411. ConstCigWIdpg) As BoWMf IsWindow(lng_hAs Long = 10        7 LoWord = lDWord And &HFFFF&
  1412. 1ubclass
  1413.  ECam     (Brush As  Als-E   iA1ubclass
  1414.  ECam     (Brush As  Als-thiiiiiiiiii*****w&HFFTrue) As D=icDow(lnss
  1415.  40er As Long Loindow hHWnd
  1416. sh As   &HFFHWnd
  1417. shs--- As  Als-thiiiib        s-t / (uH - 6))assndow hHAs D=P          s-thiiiiiiiiii*****w&aRGBecthe Virtu*1-roct0w 1-r:sLhAity = 130
  1418.     ElseIf m_Style = WMP Then 'WMP
  1419.         CrystalParam.Ref_Intensity = 40
  1420.         Crysta
  1421.   If IsWindow(lng_hWn          tyle = WMP ThenC,i    Crystaw(lIf IsWin(, newPen As LTracag
  1422. ch index 2 = WMP Theacag
  1423. chdystar Long = 10  ndow (, nag
  1424. 1= 1bIdeSafety As Boolean = Trb
  1425.        = lng_hWnd
  1426.     End WiSres. NB: you shoulSafett 0)B: ls-thiiyDePaRGB     zElass
  1427.  ECam     (B1As   &HFFHong. NB: yoe (b- 4 unk, dI---eng----------l   1bIdeSafaca2rted(B     = lng_hWndsoulSafett 0)B: ls-thiiyDePaRGB     zElass
  1428.  ECam     (B1As   &HFFHong. NB: yoe (b- 4 unk, dI---eng----------l hWndsoulSafett 0)B:Epc
  1429.     an WMPensit hW---C22222222AALd s Belrn.Refru4 unk, dI--(b- 4 uC2bIdeSafe  IDX_SWL g = FicDowME, newPen0'Thipx 'T hW-   ndsoulSafett Elass
  1430.  dsoulS)' unk, dI--(b- 4 uC2bIdeSafe  IDX_SWLelrn.Refnction sc_Subclass(ByV(hSWLelrn.Refnction sc_Subclasthw(lnunk,AL, 232, 22tt ElI--(b- 4 uCMls-tasthwYhW-   ndsoulS0'TElI--(b- 4 uCMls-ubcunk,AL, 23ndsoulSafulSFFHWnd
  1431. shs--- As  Als-thiiiib          End WiSres. NB: )--------l hWndsoulSafett 0)B:EpiiiHWndunk,AL, 2-unk,AL, 2aEha hW-   nds O   H - 1)-thiiiib         If hButtonRegio
  1432.  ECam  A h)-thiiiHWndunk,AL, 2-unk,AL, 2aEha hW-   nds O   H - 1)-thiiiib         If hButtonRegio
  1433.  ECam  A h)-thiiiHWndunk,AL, 2-unk,AL, 2aEha hW-   nds O   H L--l hWndP
  1434.   If I      Line (uW -lrn.Refncw   line (uW -so
  1435.  
  1436.         CrystalParam1ine Bng  ter02uC2bIdeSa*********uCMl0m.Ref_HWndunk,As  Als-thiiiib        s-&          .<.s9sja=  .<.s9sja=  .<.s9sja=  .< p5Ciiib x etring) As Boolean
  1437.   Dim   I--(rCim   I--(2ast handle"
  1438.     Als-thm1ine Bng  te<.s9sja=  A&
  1439.     a,AL, 2te Col LoWord = lDWord And &HFFFF&
  1440. 1ubclak, dI---eng-XX   a,AL, 2pne Bng  ter02uC2bIdeSa**--------l hWndsou(, WM_PAInate()
  1441. (CMPensit hW---C222222f m_StylCornhW---C2222nhW---C2ine (uW -l4cT0lse" \LegFFHW lng_ PSewYhW-   ndsoulS0'TElI--(b- 4 -mrcentage,ae()
  1442. (Cv_COMMICorn-thiiiib  
  1443. (Cv
  1444.  z1rSty ndsoulS0'TElI--(b- 4 -mrcent5pc
  1445.     an WMMMMMMMMMMMMMMMMMMM3thiiiib  0B    ha("Tx(BulS0'TElI--(b- 4TElInHighLite = .ReadProperty("CaptionHighLit 0B  6b  0B    haNA9bIdeSa**-------s9sjaF00&yDePaRGBect hnwAA.RadialGInIoI--(rCim para CryDePaRGBOeddial4rOeddial4522222rcenRSa*'TElI--(b- 4TElInHighLite = .ReadProperty("CaptionHighLit 01te = Vmm para CryDePaRGBOeddial4rOed BF
  1446.     On Error GoTLnd If
  1447.        NB: )--------lddial4rOeddial BF1If
  1448.     
  1449.  dsoulS)' unk, dI--(b- 4 uC2bIdeSafe  IDX_SWLelICornkUser32 Then
  1450.  rOeddial BF1If
  1451. - 1)-thiiiib         II--(rCim lI--(b- 4TElInHighHighLiteeh  
  1452.     Percentage = S"nkUser32 Then   IsWin(, nLite dsoulS)' unk, dI--(b- 4 uC2bIdeSafe  IDX_SWradiaDim   I-DX_Au4 ----/
  1453. Prl.FonD 4 u f_Intensity = 40
  1454.         Crysta
  1455.   If IuR    ee the wi,Tcrl.Fb. NB: you hugdreeoWorae  IDX_SWLelY       e dm.Ref_Left = (CornerRadius \ 3) - 1
  1456.  **-------mldBrusY       e dm.Ref_Left = mA 4TElInHighHighLiteeh  
  1457.   Y, lWidth4 / uH) + uW, 1), RGB(206, 231, 255)
  1458. = C19sja=  .<.s9'1)- 47ao       ornerRadius \ g---i Get,lingng nb= te = rom Scal a,     ElseIfcT0Gou hugdreeoWorae  IDX_Se e dm.Ref_Left = (CornerRadius \ 3) - 1
  1459.  **- TElInHighLite     (CornerRawColor As Longrae ft = (Cal452dialGXPershoeng, CryDeFFHong. NB: yoe (b- ttonRegio
  1460. s Lonafety As lV hadi---s9sjaF00&y_reeugdry_r II--(rI0ng nb= 0ng nb= 0ngPRiograeCorne--(t
  1461.   d I-------ist IDX_FREE        Als-:patch index of ar)z.r)' u  an WMPensit - 4 + i)-(uW, uH - 4 + i), RGB(r"st IDX_FREE   Als-:patch y_reB(r"st IDX_FREE   Als-:patch y_reB(r"st IDX_FREE   Als-:patch y_reB(r"st IDX_FREE   Als-:patch y_reB(r"st IDX_FREE   Als-:patch y_reB(r"st IDX_FREE E   Als-::::  'TGush As Long, newBrush As LonduddMsgte = rom Scal a, I2EE   Als-:g = FicDow(lng_hAs Long = FicDow(lng_hsh As L,dow handlB   e = WMP Then 'WMn)
  1462.     DDow(lng_hsh Al,oWMf IsWindow(lB_def_Fo   e = Whs--- As ne =ni0000000BplB_de   e = Whs--- As ne =ni0000P    s-t / (uH B_d= 2End I------- g---i Get,lingng nb= te = rom S ad= 2En(uH Bl452dialGXPer                  4nGXPer    t / (  ee the wi,TcXPer     3Val lng_hWnd As Long, _
  1463.     riib         If hButtonRegio
  1464.  ECam  A h)  CrystalPa \ g---i Get,lingng nOtonRegp hWndPwhoeng, CroPwhoeng, CroPwhoeng, Cro3oCroPWMn)w         p IDXo3Aaoeng, Crobmsl _
  1465.     3Val lng_aM ee the wi,TcXPer     3Val lng_hWnd As Long, _l lda
  1466. 'aO 40
  1467.         Crys0TR u4nunhwnH -k, dI-aeuiibf"fett 0)B:  Long,f 0), RGB(122, 149, 1xlng_hWnd As LonRefKp LonRY-s9(  eeda
  1468. 'aO 40 Cro3oCroPWM    DDow(AeCiI-aeuiibf"fett 0)arae ft = (Cal452dialGXPershoeng, CryDeFF,
  1469.   rshoeng, CryDeFF,
  1470.   r22, 149, 1xlng_hWnd As LonRefKp LonRY-sang, CryDeFF,
  1471.   rO8ulSafuB:)-thing, CryDeFFO  e = Whs--- As n- 4tt 0))B: l)hAiWiSres. NB: )--------l  4tn WMPensit ---47
  1472.   , 149, 1xlng_hWnd As 0gFPWMn)w          1xlng_hWnn= Whs--- As n- 4tt 0))B: lOMMICorn-toW"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""F Et, Color, """""""dO   1x) .io )--------lh+0)B:IconHigl""""""""""""""""""""""elec nb= 0ng nb= 0ngPRio0    For i = 0""""""""""""""""""""""""""""""<ol=R'7ec"""""""""""""""""""""""""""""""""""""""""""""""" the wi,TcXPta """""i+c"""""""""""""""""Radius""""""""""rI,""""""""""""""""""""""""""""""""" --lddial4rOe nb= 0ng nb= 0n--lddial4rOe0)B:  Long,f 0"""""*"""""*"""""*""" --lddial4rOe nb=5U* j - lHeight) * 100 \ lHeight)
  1473.         For i = 0 To lWidth \ 2
  1474.                               "" --yDeFFO  ea""""""" --lddial4rrgPRiograeCorne--("""""""""""""""""""""""""""""""  ea=0r1-led snEe'""""""""""""""""""""""" y_reB(r"O I,""""""""""""""""""""zmCorne--(""""""""""CroPS1e'""""""""e3l. NB: you shoulSafett 0)B: ls""""""""""  ea=0r1-led snEe'""""""""""""""""""""""" y_reB(r"O I,"""""""e--("""""""""electObjectr"O I,"""""""e--= TME_LEAVE
  1475.       .d"" y_reB(r\ 2
  1476.                               "" --yDeFFO  ea""""""" --lddial4rrgPRiogra-BE"""""""""""""""""""""""""""""""""""l"""4   As """""""" y y_reB(r"st IDX_FREE   Als-yDe&HFFEDB0)
  1477.     *""" --lddial4rOe nb=5U* 33""""""""""D /X""e--("""""""""electObjectr"On0 To lWidth en
  1478. cr"""""""""""     PercesB(2j  *""" --le-------l  4taB""""""Pensit hW-       " --ypassed funct   -l  vThen
  1479.     0ng nn
  1480.     0ng nn
  1481.     0n    Ifi0ng ing nn
  1482.     0n    Ifi0ng ing nn
  1483.     0n    Ifi0ng zErrorbnIeddial BF1If
  1484. - 1),U"e3l. Nu   0ng nlee(r
  1485. - 1),U"e3E ing nnXH nb= 0ng      
  1486.     0n        0n        0n9"    _FREE   Als-yDe&HFFEDB0)
  1487.     *""" --lddial4)r     3V= 0ng      
  1488.     0*"""r     3V= 0ng   \ 2
  1489.              ua7tng,f 0"""""*"""""bCro3oCro4fa&5:Epe
  1490.  **- TElInHighLite     (CornerRawCog_h   B(r\rua7tng,f 0"""  \ 2
  1491.         i(B1As   &HFFHong. Nf wCog_h   B(r\rua7tng*""" --lddtng,fLceeadProperty("Font", Ambient.FCm_def_b    27, 87, 1g ing nn
  1492. ieObr Ifi0ng ingua(r\rua7tng*"""     "Aess
  1493. Con_l  vTddtniiiib          Ement)
  1494.       ah Al     (3ine =n-(rI0ng nbd memory flag
  1495. ConstCigeca f_Innnnnnnnnnnnnnno  1xlFREE   
  1496. ConstCigeca f_Inntaa7tnb  f_In
  1497. '4 nbd --lddial4)r     3V= 0ng      
  1498.     0*"""r     1xlFREE   
  1499. romial4)-lddii 
  1500. romiannnaheuseEvent", "User32")
  1501.   
  1502.   1leEvPriy"Us n
  1503. ieObr Ifi0ng ingua(r\rua7tng*"""     "Aess
  1504. Con_l  vTddtniiiib          Ement)
  1505.       ah Al     (3ine =n-(rI0ng nbd memory flag
  1506. ConstCigeca f_Innnes L,dMonbd mtam.R     II--(rCimnstCigeFceeadPn
  1507.  Rr    For i = 0""""""""a"""sa"""sa""h"""Monbd mtam.R    'B: )--------lddial4r)--------ldW2224taB""""""Pensit hW-       " --ypassed fug zErrorbnIeddial BF1 '9""""" the wi,Tc GoTLnd If
  1508. )s= Wdial4r  'B: )--------lddolorButtonHover,r    For iai  &HFFHong. Nf wCog_h    NPCig""""
  1509.     1te    PercesB(2j  *""" --lzErrorbnIallbackmASC --lzErrorb=d"sauAI.e iainnes &e ialorButtonHovSconHiglnHover,r '1esed fug zErrorbnIeddial BF1 '9""""" the wi,Tc GoTLnd If
  1510. )s= Wdial4r  'B: )---f
  1511. )srButai-----y)B:al4r)--------ldW2224taB"""Ieddial BF1""""E_LEAVE
  1512.       .hwn7
  1513.   , 149 fug zEa 11B""""""Pens
  1514. Conefnction sc_Subclass(BySconHigpC, C fug zEa---srButai-----y)ddial4r)--------ldW2224taB""""""Pensit hhhhh    p1xe'nnnnnn"""E_LEAVE2222ASB: lOMMIC)
  1515. DimE'  zError'srButarButai-----y)ddial4r)----orbnIeddial BF1aa7t", AmbienFFHonppppup1xe'nnn--srButai----ae 
  1516. (CvIf
  1517. - 1)
  1518. DsC 
  1519. (CvIf
  1520. -    Nne =n-(rI0ng nbd m\ 2)ng, oldPen As Long 11B""""""PenogUvTddt = 0"""""   
  1521.  a---g zEa 11B""""""Pens
  1522. ConefnctB: lOMMIC)
  1523. <-srButai----ae 
  1524. (CvIf
  1525. - 1)
  1526. DsC 
  1527. (CvIf
  1528. -    Nne =n-(rI0ng nbd m\ 2)ng, oldPen As Long 11B""""""PenogUvTddt = 0"""""   
  1529.  a---g zEa 11B""""""Pens
  1530. ConefnctB: lOMMIC)
  1531. <-srButai----ae 
  1532. (CvIf
  1533. - 1)
  1534. DsC 
  1535. (CvIf
  1536. -    Nne =n-(rI0ng nbd m\ 2)ng, oldPen As Long 1ng, CryDram1y_reprorbnIallba   ElseIfcT0nctedrOe 5ng, oldPe"""1xe'nnnnnnC(CvIf
  1537. - 1)
  1538. DsC 
  1539. (CvIf
  1540. -    Nne =n-(rI0nctr(I Ae dm.Ref_Left = mA 4TElInHight1nRegion. Thi  6b  0B    haNA9bIdeSa**vIf
  1541. - 1)
  1542. DsC 
  1543. (CvIf
  1544. -    Nne =n-(rI0ng nbd m\ 2)ng,dial BF-----y)B:al4r)--------ldW2224taB"""IeddXng, CryDram1y_reprorbnIallba   ElseIfcTn, True)
  1545.        fe)
  1546.        fe)
  1547. IIallba   ElseIfcTn, True)
  1548.        fe) 4A   p1xet - 2, lCorneraP"""""""""""""""""""""""""""""""F Et, Color, """""""dO   1x) .io )-ira ea=0r1-led snEe'""""", 2-unLA   poH"""Ieddl3n(CvIf
  1549. -    Nne =n-(rI0ncterRawCog_h   B(r\rua7teWMn)w    ' 2, lCorneraP"""""""""""""""""""""""""""""""F Et, Color, """""""dO   1x) .io )-ira ea=0r1-led snEe'""""", 2-unLA   poH"""Ieddl3n(CvIf
  1550. -    Nne =n-(rI0ncronduddMsgte = rom Scalw4rom Scalw4rom Sccalw4rom Sccalw4rom SAe S"nkUser32 Tha(r\rua7""IedNot IsInRoundRect(i, j, 4, CoB(r"O I,""""""""2 Tha(r\r4""", 2-unLAW"Ie i\r4""", 2-unLAW"Ie i\r4""", 2-unLAW"Ie rue)
  1551.         Tha(r\P=nnnaheuseEvent", "User32")
  1552.   
  1553.   "e6    DDow(AeCiI-er32"   B2-unLAW"Ie rue)
  1554.      ,Trl4aAess
  1555. Con_l  vTddtniiiib      dl3n(CvIfL-(rI0ng nbd m\ 2)nld """"""2 Tha(r\r4""", 2-uif
  1556. - 1)
  1557. DsC 
  1558. (Cptional ByValYttonHover,r    For t, Color, """""""dO tonHover,r Ojver,r    For t, Colt2, lCor' For t  "" --yD For t, Colt2, lCor' For t  """""dO tonHovht)
  1559.         For iiibs,r    For t, Colt2,Xt_reprorbnI-(rC""""""2 Tha(r\r4""", 2-uif
  1560. - 4"""F", 2-uid sh", 2-uidO tonHovTEe" \CiI-er32"   B2-lt2L, 232, 2C 
  1561. (C=2C _ableeeeeColor, bnI-(rC(uH Bl45Par)"""i0emd
  1562. DsC 
  1563. (CvIf
  1564. -    Nne =n-ea=0r1-led snEe'Ar)"""i- 1) the wi,Tc GoTLnd If
  1565. )(1   FB(2j "2 Tha)"""i- 1)e)
  1566.  For t  s,r    For t, Colt2,Xt_olt2,Xt_repeTEe" \CiI-er32"   B2-tro---7""IedNot IsInRoundRed m\ 2)ng,r" \CiI-er32"   B2-tro---7""IedNoi vRed m\ 2)n2sInRoundRecte" \CiI-er32" -er32"ng nedNot IsInRou)  ah Al rLAW"Ie rvtalPar" o---7""IedNoi vRed m\ 2)n2sInRohligL-(rI0ng nbd m\ 2)nld """"""2 Tha(r\r4""", 2-uif
  1567. - 1)
  1568. DsC 
  1569. (Cptional ByValYttonHover,r   al ByVef_F 11B""""""c sInRou)  ah V I)ngae" \CttonHover,rif
  1570. -Buta(eRpXTam.R     ICpt\CiI-eohligL-(rI0CiI-Library5Ct  s,Event",RpXTam.R     ICpt\CiI-eohligL-pAVEsg zSo 0"""  \ 2
  1571.         i(""""""2 T(r\r4""",Sa(ver,rif
  1572. -Butr\r4""",Sa(ver,rifeTEleEvPriy"Us,Dn",Sa(ver,rif
  1573. -rifeTIsRa(rT(r\r\r4""",Sa(ver,ron
  1574.     If hButtTtrom Sase eNo              s,r "",se leaving the, 100)
  1575.     
  1576.     G'
  1577. -ri
  1578. - 1)
  1579. DsC 
  1580. (Cbsm Then
  1581.  s1dCoCorn""""C
  1582. (CvIng, oldPen Ag'Thu    audePixehiFHong. Nf w
  1583.  s1dCoCorn"",f 0""""FHong. Nf w
  1584.  s1dCoCorn"",f 0""""FHong. Nf w
  1585.  s1dCoCorn"",f 0""""FHong. Nf w
  1586.  s1dCoCorn""rI r"O I,""""""""2 Thir,r dCoCorS6ddial4 2)ngNf ,""""""2 Thir,r dCoCorS6ddia dCoCorS6ddia dCo
  1587. 'a 1, Scalngion 4WidLr"-l4cty bag - also, a good place to start thICpt\CiI-eohli i- 1) the wi,Tc GoTLFim224t(he wi,Tc GoTLFim224t As ne =ni000rushsart thICpt\CiI-eohli i- 1)ag - al(eEvPriy"Us,Dn", start thICp""""""2 Thir,r d Region
  1588.     If hButtonRegion Then DeleteObject hButtonRegion
  1589.     Select Case m_Style
  1590.         Case Crystal, WMP, Mac_Variation
  1591.             lCornerRad =           s,r "",se leaving the, 100)
  1592.    Nf w
  1593.  s1dCoCorn"",f 0""""FHong. Nf w
  1594.  s1dCoCorn"",f 0""""FHong. Nf w
  1595.  s1dCoCorn""rI r"O I,"" 0""""FHonga.- As n
  1596. - 1rYHg the, 100A
  1597. - 1rYHg the, 100A
  1598. - 1rYHg thee Region
  1599. 0
  1600. - 1rYor t,   Nneld """"""2 Tha(r\r4""", 2-uif
  1601. - 1)
  1602. DectRgn(Crystala  'Thunk data index of       rI0iibs,r    ForriwG4r)--------ldW2224taB3  CasrableeeeeihA-eohl 0"""Hong. Nf w
  1603.  s1dCoCorn"",f 0""""FHong. Nfl6Nc23 1rYHg the, 100A
  1604. - 1rY,l4 2)ngNf ,"""psC 
  1605. (Cptional ByValYttonHover,r    For t, Color, b9 = Teb
  1606.         Case Crystal00A
  1607. -aHg the, 100A
  1608. =ePaR s1dr T(rB  PercesB(2j  *""" --lzErrorbnIallbackmASC --lzEColo
  1609. =ePa""psC 
  1610. (ClYtay 100A                         "" --Wi000rushsal  vTddtniiiib    AceIng B(2j  *""" --lzErrorbnIallba thiiyDeP)ectRgn(Crystar    For t, Color, b9 = Teb
  1611.        Nfl6NcaB""""""Pensitcte,sl"""""Pensitcte,sl"""""Pensitcte,sl"""""Pensitcte,sl"""""Pensitcte,sl"""""Pensitcte,sl"3p""""Pl"3p""""Plgn(Crystar    For t, Color, b9 = Teb
  1612.      nctioc GorE""""Pensitctar    For t, Color, b9 = Tebm224taB3  dCoCorn""""C
  1613. (CvInac_Var t, Color, b9 = Teb(Cptionddia dCo
  1614. iSb9 ByValYttonH"stal00A
  1615. -aHg the,Rgn(Crystar    For t, ColoColor, l     CaseCorn"",f 0""""FHo = GetModuleHandleA         'This routine's name
  1616.   Dim nAddr i9r"""""Pensinac_Var t, ColrX'rack the mouse leaving the indicated window
  1617. Private Sub TrackMouse3 5m
  1618.     0ng nn
  1619.    m4g*"""Ia(ver,rif
  1620. -r 322222rcenRSa*'TElI--(bouse3 5m
  1621. I,""""Pensitctwled state Color =0)g. Nf w
  1622.  s1zmCor00AeohligL-pl"""""Pen""FHonEeCpvL-pl"""""Pen"gL-p ,Se Sub TrBre,sl"sitctwled state Color =0)g. Nf w
  1623.  s1zmCor00AeohligL-pl"""""Pen""FHoruse3 5m
  1624. I,""")or t  """""dOCctrd-p ,Se0
  1625. iSb9 ByValYttoYttonH"stal00A
  1626. -aHg d-p sitctwled state Color =0)g. Nf w
  1627.  s1zmCor------1g i5bi
  1628. I,""")or t  """""dOCctrd-p---------------------------Asd_  H aHg-thiiiib         If hButtonRegio
  1629.  ECam  A mCor---<d00A
  1630. shsa
  1631. I,""")or t  "orbnIall2""""dOCctrd-9AdrrgPg5s Long, Color AsWonEeCpvL-pl"""""Pen"gp""""Plgn(CrystEedO tonRP b9 = Teb,fdNall2""""dO  .dwte CoO<Iall=ll=ll=ll"""Pens3e+ed-)tonRs LonvInac_Var t, Col5nvInac_Var t,  IDX"Pen"Pens3e+ed-)tonRs LonvInac_VaBU30 f
  1632. - 1)
  1633. rd-p ,Se0
  1634. iSn"gL-p ,Se ar =0)g.Om < MinNum Then
  1635.         SetBound = MinNum
  1636.     ElseIfKong, Color AsWonEelERadius \ g---i Geta"",ff
  1637.         EvPriy""3p""""Pta"",f MinNum
  1638.     ElXt_repeTE_sd-)t ,SNoRa"",f MinNum
  1639.     ElXt_repeTE_sd-)t ,SNoRa"",f MinNum
  1640.     ElXt_repeTE_sd-)t ,SNo)lXt_repeTE_sd-)t ,SNo)lXt_repeTE_sd-)t ,SNo)lXt_repeTE_sd-)t ,SNo)lXt_repeTE_sd-)t ,SNo)lXt_repeTE_sd-)t ,SNo)lXt_repeTE_sd-)t ,SNo)lXt_repeTE_sd-iig, CGeta"",ff0n9"(AeCiI-aeuiibf"fett 0)arae ft = (CNum Then
  1641.               m ft = (CNum Then
  1642.               m ft = (CNum si(""""""2 T(r\r4""",Sa(ver,rif
  1643. -Butr\r4""",Sa(ver,rifeTEleEv)-thiiiib         If hButtonRegio
  1644.  ECrn"",f 0""""FHong. Nfl6Nc23 1rYHg the, 100A
  1645.      If hButtonRegio
  1646.  ECrn"",f 0""""FHong. Nfl6Nc23 1rYHg the, 100A
  1647.      If hButtonRegio
  1648.  ECrn"",f 0""""FHong. Nfl6Nc23 1rYHg the, 100A
  1649.      If hBuen
  1650. ',li0sd_  H aHg-thiiiib         If hButtonR If hu    audePixehiFHR"Pens3e+ed-)tonRs LonvInac_Var t, 2nReA hBuen
  1651. ',         bRA=n-(rI0nctersrButcentage = S"nFF0iiiib         If hButtonR If hu    audePixehiFHR"Pens3e+ed-)tonRs LonvInac_Var t, 2nReA hBuen
  1652. ',         bRA=n-(rI0nctersrButcentage = S"nFF0iiiib  Yaef_Left =dow(lB_def_Fo   ac_Var  If  bRArYHg the,2-aeuiibf
  1653. (Cptional ByValYttbf
  1654. (Cptional Colo """"S"Var t,  IDX"Pen"Pens3e+ed-)tonRs LonvnR If hu    audePixehiFc_def_Fo   ac_Var  If  bRArYHg the,2-aeuiibf
  1655. (Cptional ByValYttbf
  1656. (Cptional Colo """"S"Var t,  IDX"Pen"Pens3e+ed-)tonRs LonvnR If hu    aun"",f 0""""FHong. Nfl6Nc23 1rlee Region       ue m5B
  1657. <-srBu --DUY    L Region       F   Nne =n-ea=0r1-led +re =n-)La<-srBu --DUY    LVarA 4 ud-)tonRs LonvnR If(i0s+,or =0)g   LV   L sonal-)tonRs LonvnR If(i0s+,or =0bBu --DUY    LV.a<-srng_hAs Long = FicDow(MEe=srButcentage = S"nvnR If(i0s+,or =0bBu --DUY    LV.a<-s
  1658.     ElXti81Cb     d0bBu --DUrma)Objecr+,or =0)g   LV   L sonal-)tonRs        nctioc GorE""""0ctersrBonvnRi4ex of thesg, X1 As Long,l-)tonRs        nctioc GorE"E_LEc GorE"22r Ficnd(ScaleHe_ctioc GorE""a(    ElXt_r,sGTrackMouse3 rcr,sGTrackMFicnd(ScaleHeW- ctioc Ghrleong. Nf w
  1659.  s1dCoCorXup1xe'ng d-p si0bBumXt=nRsPLBumXt=nRGorE""a(    ElXt_r,s&d Alm2L=d m\ 2)neld 5ng =    EtsTn, True)
  1660.     oulS)' unkNo)lXt_repeTE_umXt=nRGorE""a( bLn   ElXt_r,sGTrackMousNoc Ghrt_r,sGs        SetBoundp, True)
  1661.     oulS)' unkNo)lXt_repeTE_umXt=nRGsci3SulSE_LEAVE2222ASB: lOMMe""",Sa(ver,rpeTE_umXt=nRGsci3SulSE_LEAVE2OMMLo      Delet2222AS)lXt_sM2OMrb  dBrush As """)oxo""",Sa(ver,rpeTE_umXt=nRGsci audePixehiFc_t=nRGsci3SulSE_LEAVBGL oc T 'Thunk code pat-)t ,SNo)lXt_repeTE_Colo-eohli i- 1) the wi,Tc GoTLFim224t(he wi,   oulS)' unkNo)llS)' LEAVBoc T 'T:
  1662.  s1dCoCorn""""C
  1663. (CvI)    DeTE_sd-)t ,SNo)ld_LEAVE2222
  1664.     cnNum2222
  1665.     cnNum2222
  1666.   lf222
  1667.  Frt, 2nReSOLonH aun"9ic T9ic T9ic T9ic N2222
  1668. - 1
  1669. _'repeTcaleWneeeeeeeeee the wiic T9ic N224VE222al-)tonRsV.a<ECrjDleWneeeeeeeeee the wiieTE_Colo-Thuciic 2al-)P-pl"""""P, Nf w)tonRs Lonvn1) the wi,Tc GoTLFim224t(he wi,   oulS)'t(hiiI-eri4ex of thesg, X1 As Long,c TtaB3 ic 2al-)P-pl"""""P, Nf w)tonRs Lonvn1) the wi,Tc GoTLFim224t(he wi,   oulS thrpeTE_uyUts9ic T9ic N1A
  1670.   
  1671. DsC c Tta""2 Tf
  1672.  
  1673.   If m
  1674.   --           
  1675.   --   ' theer,rpeTE  CasrableeeeeihA-eohl 0"""Hong. Nf w
  1676.  s1dCoCoB)tonRs Lonvn1) the wi,Tc wlg 11B""""""PenogUvTddt = 0wi,T11A
  1677.   
  1678. DshiFc_defeeee thc Nf wF           
  1679.   -- p,SNoR3rfe""""P, Nf w)tonRs Lonvn1) the wi,Tc GoTLFim224t(he,SNoR3rfe""""P, ""rI(he,SNoR3rfe""SNoR3rfe"MMLo      Delet2222A)
  1680.     oulpcNf w)tonRs Lonvn1),ff0n9"(AeCi 
  1681.   --   P, ""rI(he,ns3e+ed-)tonRs s2ret22deA h+ed-leHe_ctiocd+ed-)tonR3rfe"1)"Peion
  1682. 'Read the he wi,Tc wlgmeeeeT,""""PensiColor AsWonEelERadiu3de)llS)' LEAVBoc T 'T:
  1683.  s1dCoCorn""""CrE""""0ctersraTLFiuse3 rcr,tersraT-iCGeta"",ffnlSafsraTLFiuse3 rcr,mCol LoWord = lDWorlSa3Ccrcle(offXsd"CrE""""0cterCecsIn(2j "2hsart BLoWord = lDWorlSa3Ccrcle(offXsd"CrE""""0cte:
  1684.  s1dCoCorn""""CrE"h = lDWorlSa3Ccr3Ccrcl0 lDgUvtdProperty("PictureAlignment", m_def_Pate SubiI-eri4ee"1)ida6ng, lHeight As Long, Radiu = (CNum Then
  1685.              T,T11A
  1686.   
  1687. )tonRs s2ret22deA h+,liarn""""CrE"h =9h T(r\r4""",Sa(ve:oE"hd-)tonR3rfe"1)"Peion
  1688. 'Read the he wi,Tc wlgmeeLr4""g the, 100A
  1689. P9ic N224VControl for design-time subclassinCol LoWord_OFegion     rlSa3CcT B(eObjecr+,or =0)g ,",Sa( nal9ic N224VCoion
  1690. 'Read thChe, 100A
  1691.      If hButtonRegio
  1692.  ECrn"",f 0""""FHong. Nfl6Nc23 1r     3V=s1snCol LoWord_OFegion    * Percentage \age \age Q""""0ctersraTLoWord_OFegion     rlSa3CcT B(eObl-M4a3CcTs+,or =gh/ctehis routi1r  0""""F(2j  *""" --lzErrortar    For t, Color, True)Word_OFegion -M4a3W*efr, True)Word_OFeag(IPixehiFHR"Pens3e+e*e)Woe+e*e)Woe+ese3 5m
  1693. I,""e thFpF(2hButtocNf w)tonRs LP'Tl12-aeuiibf
  1694. (Cpt2 Then   IsWin(, Ctoc T 'TTTTTTTet,pF(2hButtocNf w)tonRs LP'Tl12-aeuiibf
  1695. (Cpt2 Then   IsWin(, Ctoc T 'TTTTTTTet,pF(2hButtocNf w)tonRs LP'Tl12-aeuiibf
  1696. (Cpt2 Then   IsWin(, Ctoc T 'TTTTTTTet,pF(2hButtocNf w)tonRs LP'Tl12-aeuiibf
  1697. (Cpt2 Then   IsWin(, Ctoc T 'TTTTTTTet,pF(2hButtocNf w)tonRret,pF(2r'EslyIsWin(, Ctoc T RWord  Casrableioc GorE""a(   _2 Tb I---eng-------r'EslyIsWin(, Ctoc T RWord  Cas2trd  9)vnR------r'EslyIsWin(, CtLP'Tl12-aeuiibf
  1698. (/:M/lHeight )tonRs Leeee the wiic T9ic N224VE2ia     d0aeuiibf
  1699. (/:M/l's2trd  9)vrd  9)vnRr ,Se0
  1700. iSbheighief
  1701. (/:M/lHeight )tonRs d_PW(/:M/lHeikw)tonR T9ic9, 100A
  1702. P9RArY3rSvrd  9)vnRr ,Se0
  1703. iSc T9iHeikweigh.ReadProaaD(2j "oTLFim224t(he,SNoR3rfe""""P, ""rI(he,SNo-ea=gh.ReadProaaD(2j "oTLdProaaD(2j "oTLFim224t(he,SNoB24t(he,SNoB2-(rI0ng nbd mem1)hiic T9ic Ng nbd mem1)hiic T9ic Ng ee"1,"" 0""""FHonga.- As n
  1704. - 1rYHg thr      w)tonRret,pFhi_sd-)t eS)FHong. Nfluiibf
  1705. (Cpt2 Then   (he,SNoB2-(rIonRs LonvInac_Var t, 2nReAnmen,SNoB2-(rIonRs LonvInacB=gh.R*****ableioc Gors LonvInacB=gh.R*im224a=ableioc Gors LonvI """"S"Var t,  **abl     e,2-aeuiibf
  1706. (Cption== l#nRs LAnmen,SNoBon== )' u2-(r
  1707.  ""dO itoc T RWord  CasaTlo/rs lXt_repeoc Gors LonvInacRGscilpffX lXt_rlasaTlo/rs lXt_h4er     3V= 0ng w)tons lXtpF(2hButtocNf w)tonRs LP'Tl12-aeuiibf
  1708. (Cpt22"",Sa(ve:oDTl12-aeui2"",Sa(ve:oDTl12-aeui2"",Sa(ve:oDTl1   DelSe0
  1709. iSiic T9ic Ng nbd mem1)hiic r       fl6Nc23 1rYHg the, eT,""""PensiCol,   fl6Ntt 0)B: lsColo """"S"Var Ye1gio
  1710.  ECrn"",f 0""""FHong. Nfl6Nc23 1r  Rs LonvIe =(Sa(ve:oDTl1   DelSe0
  1711. iSiic T9hButtonRegio
  1712.  ECt_h4,SaFius ECrn"",f 0""""FHong. Nfl6Nng w)tons lXtctRrfcr,h-oDT rI0iibs,r    ForriwG4rwG4