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_Notepad20867710112007.psc / CandyButton.ctl < prev   
Text File  |  2007-10-09  |  82KB  |  1,996 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.     Exit Function
  1381.   End If
  1382.  
  1383.   nMyID = GetCurrentProcessId                                               'Get this process's ID
  1384.   GetWindowThreadProcessId lng_hWnd, nID                                    'Get the process ID associated with the window handle
  1385.   If nID <> nMyID Then                                                      'Ensure that_NAME      As String =E'irfI
  1386.     StrinuncreSaf of the windo                \M                   address
  1387. Const IDX_S,1 Then
  1388.               l     rFom cess IDure that_NAME      As StriIlass0                    associated p0dle
  1389.   If nID <>() As        rivate Function Draw        te metnaIwindo                \M                   address
  1390. Con/ight = vbWss
  1391. Con/ieger
  1392. - Ot =9  te metnaIwindo     ) + g1 - (gsrmine i'Bc"Teger
  1393. - Ot =9  te mW
  1394.   If nID <>() As        rivate (((((((((((Con/ight =t     rivaThen      G             onst IDX_B0       9 data
  1395. Const SUB_NAME      As Stringe Via i'Bc"Teger
  1396. - Ot =9  te mW
  1397.   If nID <>() As   SEl8UrivaThen 0
  1398.         PSet (1, 0)Ory hMYhen 0
  1399.        a i'Bc"
  1400. Con/ieNER  8xecutable memory
  1401. Const MEM_COMMIT ) As   SEl8UrivaThen 0
  1402.         PSetessId lng_hWnd, nID   wonaW=4g1 - (gsrmine i'srmine i'srmine i'srmbclass .h        \M                   address
  1403. meO    ddress
  1404. mlWb)***********************
  1405. '*tThen  B_angle Pa228aded  As Boolean
  1406.  
  1407.   hMod = GetModuleHanddddddddddd 2 * CornIf
  1408.   End If
  1409.   m_Init (i )*******5)
  1410.     b)****************unction
  1411.  
  1412. ine i'srmine i'srmine i'srmbclass .h        \M                   addressi=9  dddddddd 2 * CornIf
  1413.   End       M               U  \M                   adivaThcrinuonst SUB_NAhButt  OptionalnIf
  1414.   E                 C   e is validi        NAhButtudutt t Funcine i'srmine i'srmbclass M    )            y    \M                   addressi=9  ddddddddresse C   e ie
  1415. Const Pesse  ID Then    class .h        \M                 s
  1416. Const IDX_S,1 Then
  1417.           le Pa228adeprocess's ID
  1418.   Ge   eaI4,d with the window handle) CornIhim nAddr         As Long
  1419. Function
  1420. 5)
  1421.         Pl z1e  i'srmine i'srmine iht =-lst SUB_NAME      Long
  1422.   l  As Long
  1423. Functio1j'srmine  l  Dessi=9 ng ndex     s
  1424. Coe SUBuuicata te mW
  1425.   If nine i'srmAs Lo)ddddd=-lstfined, callbacks are sent to this object's in Pl z\M    X0lng_hWnd, nID     As Long
  1426. Functnd, nID     A data
  1427. Const SUm',n 'Subclass the specramramramramra(     ) + g1 - (g ndex  yt  OptionalnIf
  1428.   E  S*st Pesse t       Long
  1429.   l        a i'amramramramra( I1i   ) + g1 esss   SEl8U      Pl i
  1430.         m_Bad) + g1 esss   SElIXThunkl8U                 3hunkl8U 'nctioow aDim i As L.          3 ID   .onRegion = Creag'dlPa  3 Ii       )tTtAs Long = 5    u8U 'ncti  u8 l  DThunk da. If undefinedDim i As Lfunction 
  1431. C) daadeder, BF
  1432.     On Error GoTo 0
  1433.     If vState = eP = IsFuncti                 'Get this pr      3hunkl8U 'nctCpnctCpnctCpncs IDure t eP = IsFuncti        As    3hunkl8U 'nctCpnctC                   'Ge     ) As      undefinedDim i As   As    3hunkl8U SUB_NAhButt unkl8U '    4MRi   ) +           m i  + aA, nID 4MRi   ) +          =9  ddddddddresse C   e iutt unkl8U '    4inedDim seEventComCtl tme
  1434.    ,m6Bc"Teger
  1435. - Ot =9  te mW
  1436.   I
  1437.      m_Baf ,m6Bc"Teger
  1438. - O(=9  dddddddd= IsFunc tate = eP i9  te mW
  1439.  mlc.hwndTrack   m_u'Mtl tme
  1440.     X2, Y2)
  1441. Th)Baf(hWnd, nID   wonaonaonc tate = eP i9  te mW
  1442.  mlc.hwndTrack   m_u'Mtl tme
  1443.     X2, Y2)
  1444. Th)Baf(hWnd, nID   wonaonaonc tate = eP i9  te mW
  1445.  mlc.hwndTrack   m_u'Mtl e mW
  1446.  mlc-e mW
  1447.  mlcaRmanedDim seEv
  1448. meO , uH)-
  1449. Th)Baf(hWnd, n                l8U 'nctC mm seEalFree function address
  1450. Const IDX_BADPTR    As Long = 7                              lh)Baf(hWnd'ic As BooleanuH - 6))))ong tme
  1451. liree funct     hwndTrack   m_u'Mtl e R   As'ic As Boolelh)NO , uH)-
  1452. Th)Baf(hWnd, n                l8lcti  u8 l bRGN_Xl45= &H8000&         rNanuH - 6))))ong tmeXnction Dra.:. Long
  1453. Function
  1454. 5 Dra.:. Long
  1455. Function
  1456. 5 Dra.:. Long
  1457. Function
  1458. 5 Dra.:. Long
  1459. Function
  1460. 5 Dra.:Rn
  1461. 5 Dra.:Rn
  1462. 5 Dra.:Rn
  1463. 5 D s5I_NAME fction Dro5 Dra.:. Long
  1464. Function
  1465. 5 Dra.:Rn
  1466. 5 Dra   hwndddddresse C   e iutt unkl8U '    4inedDim seEventComCtl tme
  1467.    WDra.:Rn
  1468. 5 Dr/ iutIpX_S,1 Thelstfined, c ex of the thunk data
  1469. Const SUB_NAME      As Str As Lfuncto      nd a CornerRadiuDr/ iutIpX_S,1 Thelstfined, c ex C,Aunction address
  1470. Const IDX_CWP       As Long =Rn
  1471. o                        
  1472. 5 D s5I_NAME :r.hwndTray
  1473. ConsIDined, i8n  u8 l bRGN_Xlta
  1474. Con), RGB(137, 17   As Str As Lfuncto             m_u'Mtl e R   AHme9    5 Dra.:Rn
  1475. rt=O_Rn
  1476. 5 Dra   hwndddddresse C   'srmine i'xp                sde
  1477.   Dim nAddr      ThelstfiRn
  1478. 5 Dra   hwndddddresse  LongUR'xp   m:(ByRef Num As Long, ByRef MinNum AanedDim seEv
  1479. meO , uH)-nm nAdTrack   m_udddresse C   'srmine i'xp     As S Rn
  1480. 5 Dra   hwndddddresse C   'sT.X_S,1 Thelstfined, i seEveni'xp     As StrMes M    )            y    \M     rt=ceive tElbacks are se      +-C CrystalPaSpX_CWP    sefta   hwnddddEs \  e se      +rtInctio m:(T  rz   Es \ Vn2lck   m_udddresse C   'srmiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiir (CornerRadack   m_u'Mtl e R   As'   ada  As Long =Rdddresse C   'srmiiiii        sdestIpX_SUrnerRadackn
  1481. 5 Dra.:. Long
  1482. FuncrMes M   To 0
  1483.     If vState = eP =     As Long =Rdd.hwndddddre        sdest
  1484.  his pr   =  e            'Commit allocated memory
  1485. Const MrornerRadack   m)b2 * c  Es \ Vn2lck   m_udddressec         p8emorDimte mW1t z1e  i'srmine i'srmine iht =nstof 6))))ong a   hwnddW\M             19 mW1BX     
  1486.  
  1487. erRadackn
  1488. 5Y
  1489. Conste3s5m_udddressene iht =nstn***unc1BX     
  1490.  
  1491. erRadackn
  1492. 5Y
  1493. Cn/   As Long =Rdl = j2 ThenB          i - X
  1494.     offY = j - Y
  1495.     If offY > adi4k data
  1496. Cons,BX   Es \ Vn2ThenB     p         'Commit al4bTUME :r.hwnd46dtsG**uaddr * 11w  hwnddW\M             19 me
  1497. erRadackn
  1498. 5Y
  1499. Conste3s5m_udddressene iht =n tio m:(T  rz G**uadine i'xp   piBl4bTUV h  FreeLibrary hMod
  1500.  y hM  +-C           9  ddddddddresse C  Boolean
  1501.  
  1502.   h(utt  i8n     
  1503.  
  1504.   ncre
  1505. Coe SU Y
  1506.     If offY > aME :r.hw_S,1 Then
  1507.          WTrayPa228adep(F-----hM  + 
  1508.  
  1509.   , b(1l e R   As'ic As B9       WTrayPa228adep(FR*U Y
  1510.     If of    ptCU Y
  1511.     If of    ptCU Y
  1512.     If of    ptCU Y
  1513.     If of    ptCU Y
  1514.     If of   r If of    ptCU Y
  1515.  tr As3tate = eP =     As Lj"If of    pt
  1516.     If of    p WTr        'This routine's name
  1517.   Dim nAddr         As Long
  1518.   Dim nID           As Long
  1519.   DimnedDim seE    <Addr         As Long
  1520.   Dim nID                    m i  + aA, nID 4MRi tyh  FreeLibrarytyh  Fng
  1521.  If of    ptCU Y
  1522.     If of    ptCU Y     riiiiiiiii'nctieof the callback metho5GS Y        As D       T th" apiiiiii'nt, m_Colbub UserControl_ReadProperties(PropBag As PropertyBag)
  1523.   Dim w As Long
  1524.   Dim h As Lon
  1525.   Dim nAddr   ag)
  1526. Const IDX_EBMuH)-
  1527. ThXeH)-
  1528. ThXeH)-
  1529. TLong
  1530.   DimI    wonaonaonc urControlg
  1531.   Dim h As LoS,1 Then
  1532.          WTrayPa228adep(F-----hM  m_Colbub 'This 'nctine's naTray
  1533. ConsIDined, i8n  u8 l  w As Long
  1534.   Dim h As te mW
  1535.   I
  1536.      m_Baf    As D       T th" apiiiii82UV h  FreeLibrary hMod
  1537.  y hM  +-C     OntComCs- (255 s Lorpl#Aps- (Readwnk data ishMod 7617536
  1538.     Line (uW - 2, uanddddddddddd 2 * CornIf
  1539.   End If
  1540.   m_Init (i )*******5)
  1541.   adProperties(PropBag As daonc urControlg
  1542.   Dh1 Thelstfined, c ex C,Aunction address
  1543. Const IDX_CWP       As Long =Rn
  1544. o          PhM  + 
  1545.  
  1546.  i              bj:************unc5 Dra.:ApeeLibrae
  1547.     X2, Y,6t IDX_CWP       htKs    hYtatii'nt'5 1tnaonc taeIi(Readwnk data ishMod 76175stfined, c ex C,Aunction address
  1548. Const IDX_CWP       As Longong =R adPropmtfined, c ex C,) wonaonaonc urControlg
  1549.   Dim h As LoS,1 Then
  1550.          WTrayPa228adep(F-----hM  m_Colbub 'Thaa C,AunTrayPa228adep(F-LDtxp     As S Rn5)
  1551.   adProp
  1552.          WTrLddddddd 2 * CoradProp
  1553.    ----------- As S Rn5)
  1554.   adProp
  1555.          WTrLddddddd 2 * CoradProp
  1556.    ----------- As S Riii n           0n_it (i )**zf Abs(Y - r) < lRessss0c5 Dra.:. Long
  1557. Function
  1558. 5 D0tdBrush(Fr(Fr(Fr(Fr(Fr(FrF9ndRect = True
  1559.     End Ifct = True
  1560.  u
  1561. CWWWWWLop
  1562.    ---------) As    ---- As S RiiE. Long
  1563. Function
  1564. 5 Dra.:. Long
  1565. Fu228adep(F-LDtxp     e   +-If undefined1**zf Abs(Y - r) R3hRgn
  1566. End Funr(Fr(Fr(FrF9ndRect = True
  1567.    2 * =g)
  1568.   Dim w As Long
  1569.   Dim h As Lon,n2lck   mg
  1570. Fu2, 17   As _
  1571.   Dm w Ab 'T _
  1572. nl,unk code parG 2 * CornIfdata
  1573. Cons,BX   Es \ Vn2ThenB     p         'Commit al3u4t al3u4t a
  1574.     X2, Y,6t IDX_CWP      -----
  1575.     -----
  1576.     -----
  1577.     -----
  1578.     -----
  1579.   4t aaS IDX_CWP       As Long =Rn
  1580. o          PhMK. 
  1581.    ,s(PropBag As daonc ur Y,6t IDX_C---- As S Rn5)
  1582.   adPns,BX&,unk codTrayPaSunctip    WT)5)
  1583.   adPns,BX&,unki )*MRi tyh  FO data ishMod 7617536
  1584.  jPns,BX&,unk codTrayPaSunc As LA     WTra  4i    WT)5) data ishMPns,BX&,unk cc SEl8codTWEtlCon
  1585. 5 Dra.:. Long
  1586. FunctionUrnerRadackn
  1587. 5 Dra.:. Long
  1588. FuncrMeseR
  1589. Funct IDX_FREE    ,.:. Long
  1590. Functi Long
  1591. Funitl tme
  1592.    ,m6Bc"TehenB     p      E  ng
  1593. Fi8 urControlg
  1594.   Dh1 Thelstfined, c exuncti2&trolge    Wng
  1595. Flse 6mH c exuncti2&trolge    WnPte m5Drse   -----EtlCo    Wng
  1596. Flse hMPn0lge    Wng
  1597. Flexunceed, c ex C,)aE w Ab 0 Wng
  1598. FleH<ncti C,)aE w Ab 0 Wne hMPn0lge    Wng
  1599. Flexunceed, c ex,)aE w Ab 0 Wne hMPn0lge    Wng
  1600. Flexunceed, c ex,)aE w Ab 0 Wne hMPn0lgvrI Y2)
  1601. Th)IExutIpX_irI YiI Y2)
  1602. Th)IExutIpX_irI YiI Y2)
  1603. Th)IExutIpX_irI rinuncrcoS mW1t z1e  i'srmine1Hlh)Baf(hWnd YiI Y2)wlgvrI Y2n
  1604. o3h  Y2)
  1605. TXGLong
  1606. Fungion h)IExutIpX_iIExutIpX_iIExutI9"pX_ige    WnPte m5Drse   -----EtlCo    Wng
  1607. FlsPi2&trolge    WnPte
  1608. Fun2&trolgng
  1609.   Dim h = True
  1610.    5,g
  1611.   WP      -----
  1612.     -----
  1613.     -----
  1614.     -----
  1615.     -----
  1616.   4t aaS IDX_Cm,unki )*MRinID                    m i  + aA, nID 4MRi tyh  FreeLibrarytyh  Fng
  1617.  If of    ptCU Y
  1618.     If of    ptCU Y    tEmp  If of ong
  1619. Fungion     c rderBrigA, nID 4MRi tyhin address
  1620. Const IDf ong
  1621. Fungion     c r-
  1622.   4t aaSbraryLde2&trolge    WnPte m5Drse   -----EtlCo  r-
  1623.   4t aaSbraryLde2&tR     \M ckn
  1624. 5Y
  1625. Conste3s5m_udddressene iht =nstn***unc1BX     
  1626.  
  1627. erRadackn
  1628. 5Y
  1629. Cn/   As Long =Rdl = j2 T61e h)IExutIpX_iIExutI IsInRoundRect =ri0vWnd'ic AYg
  1630. Fungion h)IExR
  1631. FunFlsPi  
  1632. g
  1633. Function
  1634. 5 DerControl.ForaeeLim5DrseAi s Loyh  Fng
  1635.  GoTo 0
  1636.     If vState = eP rack   m_udddresseytyh  Fnpote3s5m_udddressene ih           If of    ptCDim nAddrmc npoterneC eP r  c rderBrigA, nID 4MRi tyhin address
  1637. Conste ih           i8derBr c rdi    i8dek  amenc1BX     
  1638.  
  1639. erRadackn
  1640. 5Y
  1641. Cn/   As Lo =nsssTrBrigAe ih TrBrigAeOw Ab Cn/l.Fo                       X8 Cn/n   X8 CnW
  1642.   I
  1643.      m_---------(trWWWWWLop
  1644.    ---------aa
  1645. nNum AanedDim seE CnW
  1646.  h 'Commit al3uUns,BX
  1647.      m_- r-
  1648.   4t aaSb"erRapeE CnW
  1649.  h 'Comm
  1650.  
  1651. erRen2ThenB          3hunkV0it al3uUns,BX
  1652.    M CnW
  1653.  ----
  1654.     -----
  1655.     -----
  1656.  YbTUV h  FreeLibrary hMneeLibE5:Wl6--
  1657.     -----
  1658.  Yb--Etl3uUns,BX
  1659.    M CtR     rbrB hMneeLibE5:Wlv---
  1660.  YbTUV h  FreevWl6--
  1661.     -----
  1662.  Yb--s 'nctine's naTr1)z = IsFuncti        al3uUns,BX
  1663.    M  FreevWl6--
  1664.     -----
  1665.  Yb--s 'nctine's naTr1)z = IsFuncti        al3uUns,BX
  1666.    M  FreevWl6--
  1667.     -----
  1668.  Yb- 7613uUnsej      al3uUnbG 2 * C      al3)3e     rbrB hMneeLibE5:Wlv---
  1669.  YbTUV h  FreevWl6--
  1670.     -----
  1671.  Yb--s 'nctine's naT---
  1672.      ri-ibE5yons7y hMneeLibE5:Wl6--
  1673.     -----
  1674.  :Wlv---
  1675.  YbT As , user-defined call---) As  v---
  1676.  Yabe   FreevWl6------------------------Boolean
  1677.  
  1678.   hlean
  1679.  
  1680.   hlean
  1681.  
  1682. --------------------------s-Boolean
  1683.  
  1684.   hleserbT As , user-d(--------------  WTs3xe) rderB-) As  v--- e sI9zf Abs(Y 
  1685.     ER)  hMod
  1686. ibE5:und C ERArdIDreevWl6---rControlge       rolge    Wng
  1687. Flse 6 Wnntro  If n2As _
  1688.   D'1BX     
  1689.  
  1690. erRadr  c rderBrigA, nID--
  1691.    SeeLibrary , uac e sI9zf Abs(Y 
  1692.     ER)  hMod
  1693. ibE5:und C ERArdIDreeveh)IExutIpX_iIExugA, nID--
  1694.    SeeLibrary , uac e sI9zf Abs(Y 
  1695.     ER)  hMod
  1696. ibE5:und C ERArd,C9 w Ab 'T o  ----- C ERArs(Y 
  1697.     ER)=woK
  1698. Fu2, 17   Ai    ER)=woK
  1699. Fury , uac e sI9zf Abs(Y 
  1700.     ER)  h---
  1701.     -----
  1702.  ID--
  1703.    SeeLibrary , uac e HER)  h---
  1704.     -----
  1705. bER)  h    -----
  1706. -YCn/ 4    ax2O
  1707.    ---------hMod
  1708. ibEG, 17  pppppppppppppppppppppppppppppppppppppm:  As Lon(  m_bCapti'''''''''')Eppppf''''')Eppppf''''S'0hng
  1709. Flexunceed, c ex C,)aE w Ab 0aary , uaca******T63crac SEl8codTWEtlCon
  1710. 5 D:. LonL'''''fy-
  1711. bER) lAo  ER)  hMod
  1712. ibE5:und C ERArd, m i  + aA, nID 4MRi te adProper)D 4MRi te adProper)D 4MRi te adProper)D 4MRi te adProper)D 4MRi te adProper)D 4MRi te adPwIc)Eppppf'''"Eppppf'''"Eppppff'''"Eppppff'''"EppppCehwnddW\M      c)D 4MRi te adProper)D 4MRii)                                             hng*X_S,1     c)D 4M   unctio   SeeLibrary4MRii) P==Rdl = j2 T61e h)IExutIpX_iIExutI "e6bj:************utIpXLibE4M   unctio   SeeLibra1UrlBah        \M                   address    L ri-ibE5yons7y hMnelh-----EtlCo  r-
  1713.   4t aaSbraryY 
  1714.     ER)  hMod
  1715. i:ast private mY CnW
  1716.   I
  1717.      m_--pppppm:  As Lon(  m_CnW
  1718.   I
  1719.   Oj I
  1720.      m_--pppppmt:. LonL) m_--p--
  1721.     --S,1     c)D 4M   unctio   SeeLibrary4MRi
  1722.   p--
  1723.  
  1724.         y   m_--pppp   If v-
  1725.    SeeL           1M_COMMIT    As Longd, c eY,6   SeeL      1
  1726.   Oj1 Dim s************utI--p  m_u'Mtl 
  1727.    =l 
  1728. _
  1729. Funnnnn I
  1730.    -
  1731.    Se        
  1732.  0adPi3lCr
  1733.   hlean
  1734.  
  1735.   hlean
  1736.  
  1737. ------ti'''''''''')EppCPi3lCr1e   m_udddrUd Function
  1738.  
  1739. Private Sub ExcludePixe1hCommis Long
  1740.      m_-1R-p--
  1741.    pp   If v-
  1742.    SeeL                   1enaonc tate = eeeeeeeeeeeeee9(                1enaonc tate =i4u    m i  + aA, nI Dim s**fAFleH<ncti C,)aERX3rbE5W    As Longd, c eY,6   S  miwPsIxlWidth \ 2
  1743.             If PtInRegion(hButtonaA,leH<ncti C,)aERX3rbE5W    As Lon    zn border
  1744.   Long
  1745. Fum,s Longd, c eY , uac e sI9zf Abs(Y 
  1746.     ER)  hModncti C,)aERX3rbE5W    As Longd, c eY,6   S  miwPsIxlWidth \ 2
  1747.             If PtInRegion(hButtonaA,leH<ncti C,)aERX3rbE5W    As Lon    zn border
  1748.   Long
  1749. Fum,,,,,,,,,, C ERArdIDreevWl6---rControlge       rr
  1750.   Long
  1751. Fum,,,,,,,,,,As LoE5:u,eTsY,,,,As LoE5:u,eL, C ERArdIDreevWloERArdIDda2reevion sc_,leH<ncti C,21t priva, C ERArdIDreevWloERArdIDda2rees   -eevWloERArdIDda2rNbpi tyhin address
  1752. Const zn borde
  1753.   Long
  1754. bevWloERArdIDda2ree----ti''''6ta2rNbpi tyhin address
  1755. Const zn borde
  1756.   'l  unctio   SeeLibrary4MRi
  1757.   c eY , uac e sI9zf A 2
  1758.             borxRi
  1759.   1)o   SeeLibr vabT Ay4MRi
  1760.   c eY ,>c    -----
  1761.  YbC  H<ncti   As Lon    zn border
  1762.   Lon**uaddr * 4 A 2
  1763.         lRIxlWids Lo i8ng
  1764. Fu nID-    ER)=woK
  1765. dddddRef_Height, CrystadK
  1766. dddddRef_Height,eeeeeeeeAs Lone,,AA+ddRerS Bah        \M      ievWl
  1767. ddddbp+ddR'xRi
  1768.   eeeAs LoR)  hModnA,leH<ncti C,)aEbng
  1769. Fu nID-    ER)=wo  c e---
  1770.     -----
  1771.     --6--
  1772.     -----
  1773. ef (it ti C'M 4 A 2
  1774. fdIDreevWloERArdIDda2reevion s *fAFleH<ncti C,)aERX3Fin---
  1775.  YbT
  1776. ddddbp+ddR'xRi
  1777.   eeeAs LoR)  4nU      P  ---e-------------Boolean,''''''')Eppppf'er    oleaCon/ieNbti+
  1778.  YbT
  1779. ddddbp+ddR'xRi------------a.yBag)eevehrYGxRi
  1780.   eeeAg =Rdd.hwndddddre        se eeeAs Lo2ddre       ER
  1781.  
  1782. e)GxRi
  1783.   eeeAg =Rdd.hwndddddre p18S  'Thunk data index of the       ibE
  1784.   Oj I
  1785.     aiw<ec  ---------hMod
  1786. ibEG, 17  pppppppE5:u,eTsY,nU      P  ---rG 2e       ER
  1787.  
  1788. e)GxRi
  1789.   eee
  1790.  
  1791. e       a -----
  1792. ef (it    aiw<ec  ---------hMod
  1793. ibEGum,,,,,,c  ---------ndex of the(hWnf (it ti C'M        (hWnf (it ti C'M      H<nuwnddddait    aiw<ec  = '   se i'sr H<nuwnddddait    aiw<nf (it ti C the(ti) 5W    As LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooluoaoWDra.oooooooooooo_OWNER     As Long = 8   3hunkFlexundress
  1794. lc.hwndTrack   m_0index of the '---Function
  1795. 5 Dra.:. Long
  1796. Fu228adep(F-LDtxp     e   +-If undefvWl6--
  1797.  M  + 
  1798.  
  1799.  i              bj:****F-----P     ---P     -(m ,>c    -----
  1800.  vWl6--
  1801.  M  utIpX_iIExutI ndoooooootnindex of rdIDreevWloERArdIDdER)=wX_iIExutI ndoooooootbj:****T61e h)IEx  FooooooooCPi3lCr1e   m_udddrUd  ,>c    -----
  1802.  vWoc.hwndTrack  GoTo \  e se   
  1803.  
  1804. 'Determine if 1Ara(   s 'ncti2\  e se   er
  1805.   Lon*Ax C,)aE wh FooooooooCPi3lCR5nction Dro5 Dra.:. Long
  1806. F- (gsva.:.(s Longd, c eY A'xp     As StrMes M   on Dro5 DreevoooooluoaoWw      addressi=9  )GxRi
  1807.   eeeA,BX   eerbE5W    Aess
  1808. lc.hA,leH<Recsv  Aess
  1809. lc.hA    A 1bCPi3lCR5ErOWNERuoaoWw      addressi=9  )GxRi
  1810.   eeeA,BX   eerbE5W    Aess
  1811. lc.hA,leron Dro5 Dreevo0UrlBah       I-) AN'_AB*fAFl--
  1812.  Dra.:Rn
  1813. 5 D s
  1814. Const rfAFl--
  1815.  Dra.:Rn
  1816. 5 D ssI9zf Abs(Y 
  1817.     ER)  T eerbE5WYa2reevion sc_    ER)  T eerbE5WYa2reevio lW
  1818. 5(MRi
  1819.   p--
  1820.  
  1821.         y   m_--pppp   If v-
  1822.    SeeL           1M_COMMIT    As LOMMIT    As LOMM Dim h As Lonaiw<5WYa2reevio lW,c  ----4
  1823. 5(MRi
  1824.   p--
  1825. 9Chw Asg5ShadowColor = BlWc.hA    A 1bCPi3lCR5Erion
  1826. 5 Dra.:. LRe      TP****F----1fhN---4
  1827. 5(MRiouseE)  T O:i C =C =C =C oooooolDra.:Rn
  1828. 5 D ssI9zf Abs(Y 
  1829.     ER)  T eerbE5WYa2reb5Er0C =C   
  1830.                          he window handle) Coo4p=C  WolDra.:Rnpp,    
  1831.  0adPtho5GS  If lap45GS  If lub GetRGB(r As Long, g As Long, b As Long, Color As LoKC,)aERX3Fin---
  1832.  YbT
  1833. dddd3)a2reb5Er0C =C   
  1834.                          he window handle) Coo4p=C  WolDradcsSSSd a Cornei ER)  T exr0C =C   
  1835.     tion
  1836.  
  1837. P_ lW,c  ----4
  1838. 5(Me As LpTz
  1839.  E hMod
  1840.  y hM  +-C     OntComCs- (255 s Lorpl#Aps- (Readwnk data ishMod 7617536
  1841.     Line 
  1842.  y gion     c rderBrig
  1843. F'      5(s Longd, c eY A'hC
  1844.    =C oo h  FreeLdress------Boolean,''''''')Eppppf'er    oleaCon/ie''"Eppppf'''"Eppppff'''"Eppppff'''"EppppCehwnddW\M      c)D 4MRi te adProper)D 4MRii) ''"E20hng 7617536
  1845.     Line 
  1846.  y 
  1847. 5 Dra.:. LRe      TP****F = True
  1848.     End If
  1849. End Function
  1850.  
  1851. Public Function BlendColors(ByRef Color1 As Long, BAo0U Line 
  1852.  y gLong, BAo00i =TCIpX_iIExugA,pX_ir hMod:M
  1853. 5 ornei ER)Ya(Me As LpTiR(Ief Colan,''As Lonih5s M   on Dronguthe       ivWl6--
  1854.     -----iNmW
  1855. ig
  1856. F'      oooeter
  1857. '* nOrde
  1858.   Long 
  1859.  
  1860. P_=9 p0.hwIE         ERDH     Long 
  1861.  
  1862. P_=9 pFte adProper)D 4MRi t rPrope0LaEppppf'er    oleaCon/ie''A
  1863. hRzeadwnk data ishMod 761754LaEppppf'er x1      bwnk de adPf Color1 As Long,l f nID <>() As        rivate (      5(s Longd, c eY A'hC
  1864.    =C oo h  FreeLdress------Boolean,''''''')Eppppf'er    oleaCon/ie''"Ep9  te metnaIwindo    MRe=3lCr1e   m_udddrUd Funct ole)Szunct ole)Szunct ole)Sz_)Szunct ole)Szunct ole)Sz_)Sbrary4naIwind3Uuac )GxRrWYa2rary , uac e sI9zT
  1865. dddd3)a2reb5Er0C =C   
  1866.                 e)Szunct ole)Szunct ole)Sz_)Szunct ole)Szunct ole)Sz_)y , uac e sI9zT
  1867. dddd3)a2reb5tessId lng_hWnd, n       If of    po ole)Sz_)Szunct ole)Szunct ole)Sz_)yd3)a2reA_)yd3)a,>c )Gxdth \ 2)
  1868. _2reb5tessId a,       If of    po oleuA(MRi
  1869.   e   )r)Gxindo)Eppppf'ereb5tessId a,           e)Sz As Lon(  m_bCG'''')6g h 'Comm
  1870.  
  1871. erRen2ThenB       oluoaoWDra.oooooooooooo_OWNE)Gxdth \ l for de3   SeeLisIdRdn4L=    1M_roperItes
  1872. pppft'perItes
  1873. pppft'perItes
  1874. pppft'pnct ole)Sz_)yd3)aAdU Line 
  1875.  rrrrs
  1876. pppft'pnct ole)Sz_)yd3)aAd13)yd3)afAFl--
  1877.  Dra.: Dra.:Rn.:Rn
  1878. 5 D 'ereb Se      
  1879. pppft'pnct ole)Sz_)yd3)aAd13)yd3) n2ThenBID = GetCurrentPunct o(ehunk data index of the VirtualFree functi5m   = 
  1880. pppft'pte mYc e pppft'ata iex of the VirtualFree funct7777777777777777777777777777777777777   p777 Se a nAdCp080000
  1881. EOm   = 
  1882.      As Long =Rn
  1883. o      ----- 4MRii) ''"E2D 4MY
  1884. Cons )*******5)
  1885.    End FunctiO
  1886. pppft'p  hModr StrixutI ndoooooR   = 
  1887. =5eOndoG As L9i
  1888. o 9i
  1889. o 9i
  1890. o 9i
  1891. oN
  1892. o 9i
  1893. o 9i
  1894. o 9ilCaptionHigU77777777X_iIExutI6 = 
  1895. =5eOndoG AwCr1euyd3) n2TA                1enaonc tatexRrWod vooR  c tatc tatc tatc tatc tAwCr  3h 'Terminasodncti C tatc tatcnk de ad) ''"E2D 4MYi C rrentPunct o(unct tddd3)a777X_cn   Wonc tID-7777777a 4MYi CtPuNR''"E2D 4MYi C rrentPunct o(unct tddd3)a777X_cn mBhunk data index of the 0Axugf 
  1896.   'l  unctio  *Wonc tID-7777777&
  1897. F'      5(s Lo77777777lID                    m i  + aA, nID 4MRi tyh  FreeLibraryty   e)Szunct ole)Szunct
  1898. 5 D:. LonL''l  M CtR     rbrB hMneeLibE5:WlL''l3nctio  *roper)D od vooR dyty  Fr StrixutI ndoooooR   = e
  1899.      As Long =Rn
  1900. o      ----- 4MRii) ' Long =Rn
  1901. o bk data index of the 0Axugf 
  1902.   'l  unctio  *Wonc tID- =Rn
  1903. o bk data f Pthe 0Axugf 
  1904.   'A, nID--
  1905.    SeeLibrary , uac e sI9zf AbCeuyd3) n2TA          (l  'l  unctio  *Wonc aIf Abs(Y - r) <  4MRi tyh  FreeLibra     Long 
  1906.  
  1907. P_=9 pFte adProphRzeadwnk data ishe6f PtheIf  Virr
  1908.   '-
  1909.     4MRi tyh  Fb.c3operties uyliaUoooCPi3lCre      TP****F----1fBhe'le)Szunct ole)Sz_)yd3)a2re(ag =Rs
  1910. Const rfAFl--
  1911.  Dra.:Rn
  1912. 5 D ssI)Sbrary4naIwind3Uu0Mi tyh  FreeLibcc3opeOu0Mi tyh  FreeLibcc3opeOu0Mi tyh  FreeLibcc3opeOE    LtCurrentPunct o(OE    LtCurrentPuncf 
  1913.   'A, nID--
  1914.    SeeLibrary , ua0adPth tat  LtCurrentPuaos Lon(rNbpi E nID--
  1915.    SeeLibrary , ua0adPth tat  LtCurr     Long 
  1916.  
  1917. P_=9 pFFng
  1918.  If of    ptE 4ooo 
  1919.   'A, naos Lon(rNbpi E nID--
  1920.    Seeiht =nstn***unc1BX     
  1921.  
  1922. at  LtCurrentPuaos Lon(rNthhhhhh4ooo O6Long, Radius As Long) As Longlt = (r * r) - (X * X)
  1923.     If lResu)c e sI9zT
  1924.  As Long) a22vh ArNthhhhhh4ooo FC8  he window handle) Coo4p=C  WolDra (X * X)
  1925.     If lResu)c ooo FC8  he window ha As(    c rderBrig
  1926. F ole)Sz_)Sz OntC
  1927. e)GxRi
  1928.   eeeAgle) Coo4p=C  WolDra (X * X)
  1929.     If lResu)window-e mW
  1930.  mlcaRmanedDim seEv
  1931. meO , uH)-
  1932. Tsu)c 9 Comb , uH)-
  1933. T      TP***of the rig
  1934. F ole)Sz_)Sz OntC
  1935. e)GxRi
  1936.   eeeAgle) Coo4p=C  WolDn BAo0U Line 
  1937.  y gLong, BAo00i =TCIpX_iIExugA,pX_ir hMod:M
  1938. 5 orn ex,)aE omm
  1939.  
  1940. erRen2ThenB
  1941.  y gLong, BAo00i =TCIpX_iIExugA,pX_ir hMod:M
  1942. 5I  yt  OptionalnIf
  1943.   E  S*st PeQ_=9 pFFng
  1944.  If )GxRi
  1945.   eeeAgle) Coo4p=C  WolDn lnction Blend(a     'Commit alloc=ring) As Boolean
  1946. u  p777 Se a nAdCp080000
  1947. EOm   = 
  1948.  2vh A2r hMod:M
  1949. 5 ornei ER)Ya(Me As LpTiR(Ief3ng
  1950. FLtnei EhMod:M
  1951. 5 o  c)D 4MRi teC   1K      TP***** e sI9Radackn
  1952. 5Y
  1953. Cer
  1954. ohMoornei 1K    gLongA,pX_ir hMod:nnd(a    W
  1955.  m(ing) As Bonnd(a RAs Bonnd(a RA rig
  1956. F ole)Sz_)Sz Om E  Lonih5s M   on \g=9 pFFng
  1957.  If )GxRi
  1958. =tl t(r * r) - (X * X)(Ief3ng
  1959. F)s
  1960. Con:M
  1961. 5 o  c)D 4MRi dow-e mW
  1962.  mlcaRm._ir   .C9 w A ih           If of    ptCDimM
  1963. 5 o  erbE5WYaOyrle) Coo4p=8n*Ia   g-.caRm._ir   .C9 w A ih           If of    ptCDimM
  1964. 5 o  erb)-gt
  1965. 5 D:. LlnIf
  1966.   E " If of      ptCDimM
  1967. 5 o AL .C9ieaRm._ir   .C9 w A ih       h_PWr   .C9 w>c aIf Ayty  98  he wind Ayty  98 r *9mM
  1968. 5 o AL .C9i98 r *9mM
  1969. 5 o AL y  98 C9 wttonHoveeaDh tat)te m5Drse   -----Eh           I)O 98  he dkB(a RAs Bonnd(a RA rig
  1970. F ole)Sz_rjm   .C9 w A
  1971. F ole)Sz_rjm   .C9 w A
  1972. F ole
  1973.  
  1974. R'xRi
  1975.   eeeAs LoR)  hModnA,leH<ncrz_)Szih5s M   on \g .C Long, Bl(pX_ir hMod:MundiR(Ief3ng
  1976. FLtnei EhhhhhhhhhhhhhhhhhL             u8U '9ndRect = True
  1977.    2 * =g)d, TiR(te m5N   he window handle) Coo4p=C  WolDra (X * X) - r) <  4MRi tyh  FreeLibra     Lon536_rjm=g)d, TiR(te m5N   he winn) <  4MdlwinN   h=g)d, TiR4Mdlwr1eu(te  g As Loite  g    )-
  1978. T      TP***of the rig
  1979. F ole)Sz_)Sz OntC
  1980. e)GxRi
  1981.   eeeAgle) Coo4B    =g)Mft'p'rigodl Coo4pTruetC
  1982. e)GxRi
  1983.   e0ysttio  *roper)D od vo
  1984. e)GxRi
  1985.   eeeAgleOntC
  1986. e)GxRi
  1987.  tnei EhhhhhO7P***t
  1988.       g) Ascti C,)aERX3rbE5W DruetC''
  1989. F ole)Sz_rjm   .C9 w A
  1990. F ole
  1991.  
  1992. R'xRi
  1993.   eeeAs LoR) trolg
  1994.   Dh1 Thelstfined eeeAs LoRT: Dra.:Rn.:Rn
  1995. 5As LoR M   on \er)onc todrseVOmaeIi(Readwn( h=g).l5---eIi(mine )aERPsI***F----1fBhe'le)Szunct ole)Szt  Ltn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn( tn