home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1999 April / CD_Shareware_Magazine_31.iso / Free / Prg / axbutton.exe / Projects / axButton / axButton.ctl < prev    next >
Encoding:
Visual Basic user-defined control file  |  1999-02-08  |  47.8 KB  |  1,226 lines

  1. VERSION 5.00
  2. Begin VB.UserControl axButton 
  3.    AutoRedraw      =   -1  'True
  4.    ClientHeight    =   615
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   2115
  8.    DefaultCancel   =   -1  'True
  9.    ScaleHeight     =   41
  10.    ScaleMode       =   3  'Pixel
  11.    ScaleWidth      =   141
  12.    ToolboxBitmap   =   "axButton.ctx":0000
  13. End
  14. Attribute VB_Name = "axButton"
  15. Attribute VB_GlobalNameSpace = False
  16. Attribute VB_Creatable = True
  17. Attribute VB_PredeclaredId = False
  18. Attribute VB_Exposed = True
  19. Option Explicit
  20. 'Default Property Values:
  21. Const m_def_Style = 0
  22. Const m_def_DropDown = False
  23. Const m_def_MaskColor = vbButtonFace
  24. Const m_def_PictureAlign = 2
  25. Const m_def_Caption = ""
  26. Const m_def_ButtonGroup = ""
  27. Const m_def_ButtonGroupDefault = False
  28. Const m_def_ButtonGroupDefault2 = False
  29.  
  30. 'Enums
  31. Enum envbuPictureAlign
  32.     vbPicLeft = 0
  33.     vbPicRight = 1
  34.     vbPicTop = 2
  35.     vbPicBottom = 3
  36. End Enum
  37.  
  38. 'kdq 10/19/98 added new styles
  39. Enum vbuStyle
  40.     [Cool Button] = 0
  41.     [Toolbar Button] = 1
  42.     [Seperator] = 2
  43.     [SeperatorH] = 3
  44.     [Toolbar Handle] = 4
  45.     [Toolbar HandleH] = 5
  46.     [Standard Button] = 6
  47.     [Up-Down Button] = 7
  48. End Enum
  49.  
  50. 'Property Variables:
  51. Dim HaveCapture As Boolean
  52. Dim PaintedUp As Boolean
  53. Dim m_Style As vbuStyle
  54. Dim m_DropDown As Boolean
  55. Dim m_MaskColor As OLE_COLOR
  56. Dim m_Picture As Picture
  57. Dim m_PictureAlign As envbuPictureAlign
  58. Dim m_Caption As String
  59. Dim m_Value As Boolean
  60. Dim m_ButtonGroupDefault As Boolean
  61. Dim m_ButtonGroupDefault2 As Boolean
  62. Dim m_ButtonGroup As String
  63. Private hUpDownDitherBrush As Long
  64. Private UpDownButtonFace As Long
  65.  
  66. 'Event Declarations:
  67. Event MouseEnter()
  68. Attribute MouseEnter.VB_Description = "Fires when the mouse cursor enters the boundaries of the control."
  69. Event MouseExit()
  70. Attribute MouseExit.VB_Description = "Fires when the mouse leaves the boundaries of the control."
  71. Event DropDownClick()
  72. Attribute DropDownClick.VB_Description = "Fires whenever the Drop Down Button is Clicked."
  73. Event Click() 'MappingInfo=UserControl,UserControl,-1,Click
  74. Attribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."
  75. Event DblClick() 'MappingInfo=UserControl,UserControl,-1,DblClick
  76. Attribute DblClick.VB_Description = "Occurs when the user presses and releases a mouse button and then presses and releases it again over an object."
  77. Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyDown
  78. Attribute KeyDown.VB_Description = "Occurs when the user presses a key while an object has the focus."
  79. Event KeyPress(KeyAscii As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyPress
  80. Attribute KeyPress.VB_Description = "Occurs when the user presses and releases an ANSI key."
  81. Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyUp
  82. Attribute KeyUp.VB_Description = "Occurs when the user releases a key while an object has the focus."
  83. Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseDown
  84. Attribute MouseDown.VB_Description = "Occurs when the user presses the mouse button while an object has the focus."
  85. Event MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseMove
  86. Attribute MouseMove.VB_Description = "Occurs when the user moves the mouse."
  87. Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseUp
  88. Attribute MouseUp.VB_Description = "Occurs when the user releases the mouse button while an object has the focus."
  89.  
  90. Private mbButtonDown As Boolean
  91. Private mbMouseDown As Boolean
  92. Private miXOffset As Integer
  93. Private miYOffset As Integer
  94. Private mbHasFocus As Boolean
  95. Private mbMouseOver As Boolean
  96. Private mbDropDownPressed As Boolean
  97. Private miCurrentButtonPressed As Integer
  98. Private WithEvents ExitTimer As objTimer
  99. Attribute ExitTimer.VB_VarHelpID = -1
  100.  
  101. Private miClientWidth As Integer
  102. Private miClientHeight As Integer
  103. Private miClientTop As Integer
  104. Private miClientLeft As Integer
  105. Private m_ButtonFace As OLE_COLOR, m_ButtonLightShadow As OLE_COLOR
  106. Private m_ButtonDarkShadow As OLE_COLOR, m_ButtonHighlight As OLE_COLOR
  107. Private m_DownPicture As Picture
  108. Private m_FlatPicture As Picture, m_ShowFlatGrey As Boolean
  109.  
  110. Private Sub Leave()
  111.     mbMouseOver = False
  112.     
  113.     Set ExitTimer = Nothing
  114.     DrawButton
  115.     
  116.     RaiseEvent MouseExit
  117. End Sub
  118.  
  119. Private Function UnderMouse() As Boolean
  120.     Dim ptMouse As POINTAPI
  121.  
  122.     GetCursorPos ptMouse
  123.     If WindowFromPoint(ptMouse.x, ptMouse.y) = UserControl.hWnd Then
  124.         UnderMouse = True
  125.     Else
  126.         UnderMouse = False
  127.     End If
  128.  
  129. End Function
  130.  
  131. Private Sub DrawButton()
  132.     Dim iWidth As Integer
  133.     Dim iHeight As Integer
  134.     Dim iTextWidth As Integer, iTextHeight As Integer, iTextTop As Integer, iTextLeft As Integer
  135.     Dim iPicWidth As Integer, iPicHeight As Integer, iPicTop As Integer, iPicLeft As Integer
  136.     Dim iFocusOffset As Integer
  137.     Dim clsPaint As New PaintEffects
  138.     Dim iDownOffset As Integer
  139.     Dim udtRect As RECT
  140.     Dim udtTextRect As RECT
  141.     Dim lReturn As Long
  142.     Dim lArrowTop As Long
  143.     Dim lArrowLeft As Long
  144.     Dim picButton As Picture
  145.     Dim ret As Integer
  146.     Dim xPixels As Long, yPixels As Long
  147.     
  148.     UserControl.Cls
  149.     If m_DropDown Then
  150.         iWidth = UserControl.ScaleWidth - 10
  151.         iHeight = UserControl.ScaleHeight
  152.     Else
  153.         iWidth = UserControl.ScaleWidth
  154.         iHeight = UserControl.ScaleHeight
  155.     End If
  156.     
  157.     'These client variable describe the area
  158.     'inside the button to draw the picture.
  159.     'You can think of these like page margins
  160.     'in a word processor
  161.     miClientWidth = iWidth - 6
  162.     miClientHeight = iHeight - 8
  163.     miClientTop = 3
  164.     miClientLeft = 3
  165.     
  166.     'If (mbHasFocus Or UserControl.Ambient.DisplayAsDefault) And m_Style = [Standard Button] Then
  167.     If mbHasFocus And m_Style = [Standard Button] Then
  168.         iFocusOffset = 1
  169.         UserControl.Line (0, 0)-(UserControl.ScaleWidth - 1, UserControl.ScaleHeight - 1), vb3DDKShadow, B
  170.     Else
  171.         iFocusOffset = 0
  172.     End If
  173.     
  174.     udtRect.Top = iFocusOffset
  175.     udtRect.Left = iFocusOffset
  176.     udtRect.Right = iWidth - iFocusOffset - IIf(iFocusOffset = 1, 1, 0)
  177.     udtRect.Bottom = iHeight - iFocusOffset - IIf(iFocusOffset = 1, 1, 0)
  178.     
  179.     'kdq 10/19/98 added DrawShadowBox for new styles of buttons. Coolbutton should
  180.     'have thinner border than a regular button
  181.     Select Case m_Style
  182.     Case [Cool Button]
  183.         If mbMouseOver Or miCurrentButtonPressed > -1 Then
  184.             If mbButtonDown Then
  185.                 'Draw Button Down State
  186.                 DrawShadowBox udtRect, True, False
  187.                 'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH Or DFCS_PUSHED)
  188.                 iDownOffset = 1
  189.             Else
  190.                 'Draw Button Up State
  191.                 DrawShadowBox udtRect, False, False
  192.                 'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH)
  193.                 iDownOffset = 0
  194.             End If
  195.         End If
  196.  
  197.     Case [Toolbar Button]
  198.         If mbButtonDown Then
  199.             'Draw Button Down State
  200.             DrawShadowBox udtRect, True, False
  201.             'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH Or DFCS_PUSHED)
  202.             iDownOffset = 1
  203.         Else
  204.             'Draw Button Up State
  205.             DrawShadowBox udtRect, False, False
  206.             'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH)
  207.             iDownOffset = 0
  208.         End If
  209.     
  210.     Case [Standard Button]
  211.         If mbButtonDown Then
  212.             'Draw Button Down State
  213.             DrawShadowBox udtRect, True, True
  214.             'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH Or DFCS_PUSHED)
  215.             iDownOffset = 1
  216.         Else
  217.             'Draw Button Up State
  218.             DrawShadowBox udtRect, False, True
  219.             'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH)
  220.             iDownOffset = 0
  221.         End If
  222.     
  223.     Case [Seperator]
  224.         Line (0, 0)-(ScaleWidth, ScaleHeight), BackColor, BF
  225.         DrawVLine ScaleWidth \ 2 - 1, 0, 2, ScaleHeight
  226.     
  227.     Case [SeperatorH]
  228.         Line (0, 0)-(ScaleWidth, ScaleHeight), BackColor, BF
  229.         DrawHLine 0, ScaleHeight \ 2 - 1, ScaleWidth, 2
  230.     
  231.     Case [Toolbar Handle]
  232.         Line (0, 0)-(ScaleWidth, ScaleHeight), BackColor, BF
  233.         DrawRaisedVLine ScaleWidth \ 2 - 4, 0, 3, ScaleHeight
  234.         DrawRaisedVLine ScaleWidth \ 2, 0, 3, ScaleHeight
  235.     
  236.     Case [Toolbar HandleH]
  237.         Line (0, 0)-(ScaleWidth, ScaleHeight), BackColor, BF
  238.         DrawRaisedHLine 0, ScaleHeight \ 2 - 4, ScaleWidth, 3
  239.         DrawRaisedHLine 0, ScaleHeight \ 2, ScaleWidth, 3
  240.     
  241.     Case [Up-Down Button]
  242.         If m_Value Then
  243.           If mbMouseOver Then
  244.             PaintUpDownDither 1, 1, ScaleWidth - 2, ScaleHeight - 2
  245.             DrawShadowBox udtRect, True, False
  246.           Else
  247.             DrawShadowBox udtRect, True, False
  248.           End If
  249.         Else
  250.           If mbMouseOver Or miCurrentButtonPressed > -1 Then
  251.             If mbButtonDown Then
  252.                 'Draw Button Down State
  253.                 DrawShadowBox udtRect, True, False
  254.                 'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH Or DFCS_PUSHED)
  255.                 iDownOffset = 1
  256.             Else
  257.                 'Draw Button Up State
  258.                 DrawShadowBox udtRect, False, False
  259.                 'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH)
  260.                 iDownOffset = 0
  261.             End If
  262.           End If
  263.         End If
  264.     
  265.     End Select
  266.     
  267.     'Draw the DropDown button
  268.     If m_DropDown Then
  269.         udtRect.Top = iFocusOffset
  270.         udtRect.Left = iWidth '- iFocusOffset
  271.         udtRect.Right = 10 - iFocusOffset
  272.         udtRect.Bottom = iHeight - iFocusOffset - IIf(iFocusOffset = 1, 1, 0)
  273.         Select Case m_Style
  274.         Case [Cool Button]   'Soft Button
  275.             If mbMouseOver Or miCurrentButtonPressed > -1 Then
  276.                 If mbDropDownPressed Then
  277.                     'Draw Button Down State
  278.                     DrawShadowBox udtRect, True, False
  279.                     'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH Or DFCS_PUSHED)
  280.                     iDownOffset = 0
  281.                 Else
  282.                     'Draw Button Up State
  283.                     DrawShadowBox udtRect, False, False
  284.                     'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH)
  285.                 End If
  286.             End If
  287.         Case [Toolbar Button], [Standard Button]       'toolbar, standard
  288.             If mbDropDownPressed Then
  289.                 'Draw Button Down State
  290.                 DrawShadowBox udtRect, True, True
  291.                 'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH Or DFCS_PUSHED)
  292.                 iDownOffset = 0
  293.             Else
  294.                 'Draw Button Up State
  295.                 DrawShadowBox udtRect, False, True
  296.                 'lReturn = DrawFrameControl(UserControl.hDC, udtRect, DFC_BUTTON, DFCS_BUTTONPUSH)
  297.             End If
  298.         End Select
  299.     End If
  300.  
  301.     'Draw the Dropdown arrow
  302.     If m_DropDown And (m_Style = [Cool Button] Or m_Style = [Toolbar Button] Or m_Style = [Standard Button]) Then
  303.         lArrowTop = (UserControl.ScaleHeight / 2) '- 2
  304.         lArrowLeft = iWidth + 1 - iFocusOffset
  305.         UserControl.Line ((lArrowLeft) + 1, lArrowTop)-((lArrowLeft) + 6, lArrowTop), vbBlack
  306.         UserControl.Line ((lArrowLeft) + 2, lArrowTop + 1)-((lArrowLeft) + 5, lArrowTop + 1), vbBlack
  307.         UserControl.Line ((lArrowLeft) + 3, lArrowTop + 2)-((lArrowLeft) + 4, lArrowTop + 2), vbBlack
  308.     End If
  309.     'Draw The Button Face
  310.  
  311.     'Get the Caption Width and Height
  312.     iTextWidth = UserControl.TextWidth(m_Caption)
  313.     iTextHeight = UserControl.TextHeight(m_Caption)
  314.  
  315.     'kdq 10/19/98
  316.     'figure out which picture to display
  317.     If mbMouseOver And mbMouseDown And Not m_DownPicture Is Nothing And m_Style = [Cool Button] Then
  318.       Set picButton = m_DownPicture
  319.     ElseIf Not mbMouseOver And Not m_FlatPicture Is Nothing And m_Style = [Cool Button] Then
  320.       Set picButton = m_FlatPicture
  321.     Else
  322.       Set picButton = m_Picture
  323.     End If
  324.     
  325.     If Not picButton Is Nothing And m_Caption > "" Then
  326.         'Get the Pictures Width and Height
  327.         iPicWidth = ScaleX(picButton.Width, vbHimetric, vbPixels)
  328.         iPicHeight = ScaleY(picButton.Height, vbHimetric, vbPixels)
  329.  
  330.         'Set locations for the Picture and the Caption
  331.         Select Case m_PictureAlign
  332.         Case vbPicLeft
  333.             iPicLeft = miClientLeft
  334.             iPicTop = miClientTop + (miClientHeight / 2) - (iPicHeight / 2) + 1
  335.             udtTextRect.Top = miClientTop
  336.             udtTextRect.Bottom = miClientTop + miClientHeight
  337.             udtTextRect.Left = miClientLeft + iPicWidth
  338.             udtTextRect.Right = miClientLeft + miClientWidth
  339.         Case vbPicRight
  340.             iPicLeft = miClientLeft + miClientWidth - iPicWidth
  341.             iPicTop = miClientTop + (miClientHeight / 2) - (iPicHeight / 2) + 1
  342.             udtTextRect.Top = miClientTop
  343.             udtTextRect.Bottom = miClientTop + miClientHeight
  344.             udtTextRect.Left = miClientLeft ' + iPicWidth
  345.             udtTextRect.Right = miClientLeft + miClientWidth - iPicWidth
  346.         Case vbPicTop
  347.             iPicLeft = miClientLeft + (miClientWidth / 2) - (iPicWidth / 2) + 1
  348.             iPicTop = miClientTop
  349.             udtTextRect.Top = miClientTop + iPicHeight + iPicTop
  350.             udtTextRect.Bottom = miClientTop + miClientHeight
  351.             udtTextRect.Left = miClientLeft
  352.             udtTextRect.Right = miClientLeft + miClientWidth
  353.         Case vbPicBottom
  354.             iPicLeft = miClientLeft + (miClientWidth / 2) - (iPicWidth / 2) + 1
  355.             iPicTop = miClientTop + miClientHeight - iPicHeight
  356.             udtTextRect.Top = miClientTop
  357.             udtTextRect.Bottom = miClientTop + miClientHeight - iPicHeight
  358.             udtTextRect.Left = miClientLeft
  359.             udtTextRect.Right = miClientLeft + miClientWidth
  360.         End Select
  361.     'kdq 10/19/98 center picture if no caption
  362.     ElseIf Not picButton Is Nothing And m_Caption = "" Then
  363.             'Get the Pictures Width and Height
  364.             iPicWidth = ScaleX(picButton.Width, vbHimetric, vbPixels)
  365.             iPicHeight = ScaleY(picButton.Height, vbHimetric, vbPixels)
  366.             iPicLeft = miClientLeft + (miClientWidth / 2) - (iPicWidth / 2)
  367.             iPicTop = miClientTop + (miClientHeight / 2) - (iPicHeight / 2) + 1
  368.             udtTextRect.Top = miClientTop
  369.             udtTextRect.Bottom = miClientTop + miClientHeight
  370.             udtTextRect.Left = miClientLeft
  371.             udtTextRect.Right = miClientLeft + miClientWidth
  372.     'kdq 10/19/98 center caption if not picture
  373.     ElseIf picButton Is Nothing And m_Caption > "" Then
  374.             udtTextRect.Top = miClientTop
  375.             udtTextRect.Bottom = miClientTop + miClientHeight
  376.             udtTextRect.Left = miClientLeft
  377.             udtTextRect.Right = miClientLeft + miClientWidth
  378.     End If
  379.  
  380.     '10/19/98 kdq the rect values were changed so Standard buttom displays correctly when it has focus
  381.     'Draw The Dotted Focus lines, but not for the soft button
  382.     If m_Style = [Standard Button] Then
  383.         If mbHasFocus Then
  384.             udtRect.Top = udtTextRect.Top    'iTextTop - 1
  385.             udtRect.Left = udtTextRect.Left + 1 'iTextLeft - 1
  386.             udtRect.Right = udtTextRect.Right - 1 'iTextLeft + iTextWidth + 1
  387.             udtRect.Bottom = udtTextRect.Bottom + 1 'iTextTop + iTextHeight + 1
  388.             lReturn = DrawFocusRect(UserControl.hDC, udtRect)
  389.         Else
  390.             UserControl.DrawWidth = 2
  391.             UserControl.Line (miClientLeft - 1, miClientTop - 1)-(miClientLeft + miClientWidth, miClientTop + miClientHeight), vb3DFace, B
  392.             UserControl.DrawWidth = 1
  393.         End If
  394.     End If
  395.  
  396.     'Draw the Picture
  397.     If Not picButton Is Nothing And (m_Style = [Cool Button] Or m_Style = [Toolbar Button] Or m_Style = [Standard Button] Or m_Style = [Up-Down Button]) Then
  398.         If UserControl.Enabled Then
  399.             'kdq 10/19/98 added GreyScaling for Coolbutton when mouse is not over it (user defined)
  400.             If m_Style = [Cool Button] And Not mbMouseOver And m_ShowFlatGrey Then
  401.                clsPaint.PaintGreyScaleCornerStdPic UserControl.hDC, iPicLeft + iDownOffset, iPicTop + iDownOffset, iPicWidth, iPicHeight, picButton, 0, 0
  402.                'clsPaint.PaintGreyScaleStdPic UserControl.hDC, iPicLeft + iDownOffset, iPicTop + iDownOffset, iPicWidth, iPicHeight, picButton, 0, 0
  403.             Else
  404.                'clsPaint.PaintTransCornerStdPic UserControl.hDC, iPicLeft + iDownOffset, iPicTop + iDownOffset, iPicWidth, iPicHeight, picButton, 0, 0
  405.                clsPaint.PaintTransparentStdPic UserControl.hDC, iPicLeft + iDownOffset, iPicTop + iDownOffset, iPicWidth, iPicHeight, picButton, 0, 0, m_MaskColor
  406.             End If
  407.         Else
  408.             'clsPaint.PaintDisabledCornerStdPic UserControl.hDC, iPicLeft + iDownOffset, iPicTop + iDownOffset, iPicWidth, iPicHeight, picButton, 0, 0
  409.             clsPaint.PaintDisabledStdPic UserControl.hDC, iPicLeft + iDownOffset, iPicTop + iDownOffset, iPicWidth, iPicHeight, picButton, 0, 0, m_MaskColor
  410.         End If
  411.     End If
  412.  
  413.     'Print the caption on the button
  414.     If m_Style = [Cool Button] Or m_Style = [Toolbar Button] Or m_Style = [Standard Button] Or m_Style = [Up-Down Button] Then
  415.         udtTextRect.Top = udtTextRect.Top + iDownOffset ' + (udtTextRect.Top Mod 2)
  416.         udtTextRect.Left = udtTextRect.Left + iDownOffset ' + (udtTextRect.Left Mod 2)
  417.         udtTextRect.Bottom = udtTextRect.Bottom + iDownOffset
  418.         udtTextRect.Right = udtTextRect.Right + iDownOffset
  419.         If UserControl.Enabled Then
  420.             lReturn = DrawText(UserControl.hDC, m_Caption, Len(m_Caption), udtTextRect, DT_CENTER Or DT_SINGLELINE Or DT_VCENTER)
  421.         Else
  422.             UserControl.ForeColor = vbGrayText
  423.             lReturn = DrawText(UserControl.hDC, m_Caption, Len(m_Caption), udtTextRect, DT_CENTER Or DT_SINGLELINE Or DT_VCENTER)
  424.             UserControl.ForeColor = vbButtonText
  425.         End If
  426.     End If
  427.     
  428.     Refresh
  429.     Set clsPaint = Nothing
  430.     Set picButton = Nothing
  431. End Sub
  432.  
  433. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  434. 'MappingInfo=UserControl,UserControl,-1,BackColor
  435. Public Property Get BackColor() As OLE_COLOR
  436. Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
  437. Attribute BackColor.VB_UserMemId = -501
  438.     BackColor = UserControl.BackColor
  439. End Property
  440.  
  441. Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
  442.     UserControl.BackColor() = New_BackColor
  443.     PropertyChanged "BackColor"
  444.     DrawButton
  445. End Property
  446.  
  447. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  448. 'MappingInfo=UserControl,UserControl,-1,ForeColor
  449. Public Property Get ForeColor() As OLE_COLOR
  450. Attribute ForeColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
  451.     ForeColor = UserControl.ForeColor
  452. End Property
  453.  
  454. Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
  455.     UserControl.ForeColor() = New_ForeColor
  456.     PropertyChanged "ForeColor"
  457.     DrawButton
  458. End Property
  459.  
  460. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  461. 'MappingInfo=UserControl,UserControl,-1,Enabled
  462. Public Property Get Enabled() As Boolean
  463. Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
  464.     Enabled = UserControl.Enabled
  465. End Property
  466.  
  467. Public Property Let Enabled(ByVal New_Enabled As Boolean)
  468.     UserControl.Enabled() = New_Enabled
  469.     PropertyChanged "Enabled"
  470.     DrawButton
  471. End Property
  472.  
  473. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  474. 'MappingInfo=UserControl,UserControl,-1,Font
  475. Public Property Get Font() As Font
  476. Attribute Font.VB_Description = "Returns a Font object."
  477. Attribute Font.VB_UserMemId = -512
  478.     Set Font = UserControl.Font
  479. End Property
  480.  
  481. Public Property Set Font(ByVal New_Font As Font)
  482.     Set UserControl.Font = New_Font
  483.     PropertyChanged "Font"
  484.     DrawButton
  485. End Property
  486.  
  487.  
  488. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  489. 'MappingInfo=UserControl,UserControl,-1,Refresh
  490. Public Sub Refresh()
  491. Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
  492.     UserControl.Refresh
  493. End Sub
  494.  
  495. Private Sub ExitTimer_Timer()
  496.     If Not UnderMouse Then Leave
  497. End Sub
  498.  
  499. Private Sub UserControl_AccessKeyPress(KeyAscii As Integer)
  500.     'kdq 10/19/98 only Click when control is a button
  501.     If m_Style <> [Seperator] And m_Style <> SeperatorH And m_Style <> [Toolbar Handle] And m_Style <> [Toolbar HandleH] Then RaiseEvent Click
  502. End Sub
  503.  
  504. Private Sub UserControl_AmbientChanged(PropertyName As String)
  505.     If PropertyName = "DisplayAsDefault" Then
  506.         DrawButton
  507.     End If
  508.     
  509. End Sub
  510.  
  511. Private Sub UserControl_DblClick()
  512.     RaiseEvent DblClick
  513. End Sub
  514.  
  515. Private Sub UserControl_EnterFocus()
  516.     mbHasFocus = True
  517.     DrawButton
  518. End Sub
  519.  
  520. Private Sub UserControl_ExitFocus()
  521.     mbHasFocus = False
  522.     DrawButton
  523.     Refresh
  524. End Sub
  525.  
  526. Private Sub UserControl_Initialize()
  527. InitializeUpDownDither
  528. End Sub
  529.  
  530. Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
  531.     If KeyCode = 32 Then
  532.       miCurrentButtonPressed = 0
  533.       mbButtonDown = True
  534.       DrawButton
  535.     End If
  536.     RaiseEvent KeyDown(KeyCode, Shift)
  537. End Sub
  538.  
  539. Private Sub UserControl_KeyPress(KeyAscii As Integer)
  540.     RaiseEvent KeyPress(KeyAscii)
  541. End Sub
  542.  
  543. Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
  544.     If KeyCode = 32 Then
  545.       miCurrentButtonPressed = -1
  546.       mbButtonDown = False
  547.       DrawButton
  548.       'kdq 10/19/98 only Click when control is a button
  549.        If m_Style <> [Seperator] And m_Style <> SeperatorH And m_Style <> [Toolbar Handle] And m_Style <> [Toolbar HandleH] Then RaiseEvent Click
  550.     End If
  551.     RaiseEvent KeyUp(KeyCode, Shift)
  552. End Sub
  553.  
  554. Private Sub UserControl_LostFocus()
  555.     mbHasFocus = False
  556.     DrawButton
  557. End Sub
  558.  
  559. Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  560.     If m_DropDown Then
  561.         If x > (UserControl.ScaleWidth - 11) Then
  562.             mbDropDownPressed = True
  563.             miCurrentButtonPressed = 1
  564.         Else
  565.             mbButtonDown = True
  566.             miCurrentButtonPressed = 0
  567.         End If
  568.     Else
  569.         mbButtonDown = True
  570.         miCurrentButtonPressed = 0
  571.     End If
  572.     mbMouseDown = True
  573.     DrawButton
  574.     RaiseEvent MouseDown(Button, Shift, x, y)
  575. End Sub
  576.  
  577. Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  578.     If Button = 1 Then
  579.         If (x < 0 Or y < 0 Or x >= UserControl.ScaleWidth Or y >= UserControl.ScaleHeight) Then
  580.             If miCurrentButtonPressed = 0 Then
  581.                 mbButtonDown = False
  582.             Else
  583.                 mbDropDownPressed = False
  584.             End If
  585.             DrawButton
  586.         Else
  587.             If miCurrentButtonPressed = 0 Then
  588.                 mbButtonDown = True
  589.             Else
  590.                 mbDropDownPressed = True
  591.             End If
  592.             DrawButton
  593.         End If
  594.     End If
  595.     
  596.     If mbMouseOver Then
  597.         If Not UnderMouse Then
  598.             Leave
  599.         End If
  600.     Else
  601.         If UnderMouse Then
  602.             mbMouseOver = True
  603.             RaiseEvent MouseEnter
  604.             DrawButton
  605.             
  606.             'Set up the ExitTimer
  607.             Set ExitTimer = New objTimer
  608.             ExitTimer.Interval = 50
  609.             ExitTimer.Enabled = True
  610.         End If
  611.     End If
  612.     RaiseEvent MouseMove(Button, Shift, x, y)
  613. End Sub
  614.  
  615. Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  616.     Dim bOverButton As Boolean
  617.     
  618.     RaiseEvent MouseUp(Button, Shift, x, y)
  619.     
  620.     'Check the position of the mouse when in was released.
  621.     'We only want to call the click events when the
  622.     'mouse was released over the button.
  623.     If (x < 0 Or y < 0 Or x >= UserControl.ScaleWidth Or y >= UserControl.ScaleHeight) Then
  624.         bOverButton = False
  625.     Else
  626.         bOverButton = True
  627.     End If
  628.     
  629.     If miCurrentButtonPressed = 1 Then
  630.         If bOverButton And x > (UserControl.ScaleWidth - 10) Then RaiseEvent DropDownClick
  631.     End If
  632.     mbButtonDown = False
  633.     mbDropDownPressed = False
  634.     mbMouseDown = False
  635.     
  636.     If m_Style = [Up-Down Button] Then
  637.         m_Value = Not m_Value
  638.         CheckButtonGroup
  639.     End If
  640.     
  641.     DrawButton
  642.     If miCurrentButtonPressed = 0 Then
  643.         If bOverButton And x < (UserControl.ScaleWidth - 10) And m_DropDown Then
  644.                 'kdq 10/19/98 only Click when control is a button
  645.                 If m_Style <> [Seperator] And m_Style <> SeperatorH And m_Style <> [Toolbar Handle] And m_Style <> [Toolbar HandleH] Then RaiseEvent Click
  646.         'kdq 10/19/98 added this because click event wasnt firing for nondropdown buttons all the time
  647.         ElseIf bOverButton And Not m_DropDown Then
  648.                 'kdq 10/19/98 only Click when control is a button
  649.                 If m_Style <> [Seperator] And m_Style <> SeperatorH And m_Style <> [Toolbar Handle] And m_Style <> [Toolbar HandleH] Then RaiseEvent Click
  650.         End If
  651.     End If
  652.     miCurrentButtonPressed = -1
  653.     DrawButton          ' added so flatbutton gets redrawn
  654. End Sub
  655.  
  656. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  657. 'MemberInfo=11,0,0,0
  658. Public Property Get Picture() As Picture
  659. Attribute Picture.VB_Description = "Image to be displayed on the button."
  660.     Set Picture = m_Picture
  661. End Property
  662.  
  663. Public Property Set Picture(ByVal New_Picture As Picture)
  664.     Set m_Picture = New_Picture
  665.     PropertyChanged "Picture"
  666.     DrawButton
  667. End Property
  668.  
  669. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  670. 'MemberInfo=7,0,0,0
  671. Public Property Get PictureAlign() As envbuPictureAlign
  672. Attribute PictureAlign.VB_Description = "Specifies alignment of the picture property."
  673.     PictureAlign = m_PictureAlign
  674. End Property
  675.  
  676. Public Property Let PictureAlign(ByVal New_PictureAlign As envbuPictureAlign)
  677.     m_PictureAlign = New_PictureAlign
  678.     PropertyChanged "PictureAlign"
  679.     DrawButton
  680. End Property
  681.  
  682. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  683. 'MemberInfo=13,0,0,
  684. Public Property Get Caption() As String
  685. Attribute Caption.VB_Description = "Text displayed on the face of the button."
  686. Attribute Caption.VB_UserMemId = -518
  687.     Caption = m_Caption
  688. End Property
  689.  
  690. Public Property Let Caption(ByVal New_Caption As String)
  691.     m_Caption = New_Caption
  692.     PropertyChanged "Caption"
  693.     SetAccessKey
  694.     DrawButton
  695. End Property
  696. Private Sub SetAccessKey()
  697.     Dim iPos As Integer
  698.     Dim sChar As String
  699.     
  700.     iPos = InStr(1, m_Caption, "&")
  701.     If iPos > 0 Then
  702.         sChar = Mid$(m_Caption, iPos + 1, 1)
  703.         If sChar <> "&" Then
  704.             UserControl.AccessKeys = LCase(sChar)
  705.         End If
  706.     End If
  707. End Sub
  708. 'Initialize Properties for User Control
  709. Private Sub UserControl_InitProperties()
  710.     Set UserControl.Font = Ambient.Font
  711.     Set m_Picture = Nothing
  712.     Set m_FlatPicture = Nothing
  713.     Set m_DownPicture = Nothing
  714.     m_PictureAlign = m_def_PictureAlign
  715.     m_Caption = m_def_Caption
  716.     m_MaskColor = m_def_MaskColor
  717.     m_Style = m_def_Style
  718.     m_Value = False
  719.     m_DropDown = m_def_DropDown
  720.     m_ButtonFace = vbButtonFace
  721.     m_ButtonLightShadow = vbButtonShadow
  722.     m_ButtonDarkShadow = vb3DDKShadow
  723.     m_ButtonHighlight = vb3DHighlight
  724.     m_ShowFlatGrey = False
  725.     m_ButtonGroup = m_def_ButtonGroup
  726.     m_ButtonGroupDefault = m_def_ButtonGroupDefault
  727.     m_ButtonGroupDefault2 = m_def_ButtonGroupDefault2
  728.     
  729.     miCurrentButtonPressed = -1
  730.     mbMouseOver = False
  731.     mbButtonDown = False
  732.     mbMouseDown = False
  733.     mbHasFocus = False
  734.     mbDropDownPressed = False
  735.     End Sub
  736.  
  737. Private Sub UserControl_Paint()
  738.     DrawButton
  739. End Sub
  740.  
  741. 'Load property values from storage
  742. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  743.  
  744.     UserControl.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
  745.     UserControl.ForeColor = PropBag.ReadProperty("ForeColor", &H80000012)
  746.     UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
  747.     Set UserControl.Font = PropBag.ReadProperty("Font", Ambient.Font)
  748. '    UserControl.BackStyle = PropBag.ReadProperty("BackStyle", 1)
  749. '    UserControl.BorderStyle = PropBag.ReadProperty("BorderStyle", 0)
  750.     Set m_Picture = PropBag.ReadProperty("Picture", Nothing)
  751.     Set m_DownPicture = PropBag.ReadProperty("DownPicture", Nothing)
  752.     Set m_FlatPicture = PropBag.ReadProperty("FlatPicture", Nothing)
  753.     m_PictureAlign = PropBag.ReadProperty("PictureAlign", m_def_PictureAlign)
  754.     m_Caption = PropBag.ReadProperty("Caption", m_def_Caption)
  755.     m_MaskColor = PropBag.ReadProperty("MaskColor", &HC0C0C0)
  756.     m_Style = PropBag.ReadProperty("Style", m_def_Style)
  757.     m_DropDown = PropBag.ReadProperty("DropDown", m_def_DropDown)
  758.     m_ButtonDarkShadow = PropBag.ReadProperty("ColorDarkShadow", vb3DDKShadow)
  759.     m_ButtonLightShadow = PropBag.ReadProperty("ColorLightShadow", vbButtonShadow)
  760.     m_ButtonHighlight = PropBag.ReadProperty("ColorHighlight", vb3DHighlight)
  761.     m_ShowFlatGrey = PropBag.ReadProperty("ShowFlatGrey", False)
  762.     m_ButtonGroup = PropBag.ReadProperty("ButtonGroup", m_def_ButtonGroup)
  763.     m_ButtonGroupDefault = PropBag.ReadProperty("ButtonGroupDefault", m_def_ButtonGroupDefault)
  764.     m_ButtonGroupDefault2 = PropBag.ReadProperty("ButtonGroupDefault2", m_def_ButtonGroupDefault2)
  765.     m_Value = PropBag.ReadProperty("Value", False)
  766.  
  767.     SetAccessKey
  768.     miCurrentButtonPressed = -1
  769.     DrawButton
  770. End Sub
  771.  
  772. Private Sub UserControl_Resize()
  773.     DrawButton
  774. End Sub
  775.  
  776. 'Write property values to storage
  777. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  778.  
  779.     Call PropBag.WriteProperty("BackColor", UserControl.BackColor, &H8000000F)
  780.     Call PropBag.WriteProperty("ForeColor", UserControl.ForeColor, &H80000012)
  781.     Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
  782.     Call PropBag.WriteProperty("Font", UserControl.Font, Ambient.Font)
  783. '    Call PropBag.WriteProperty("BackStyle", UserControl.BackStyle, 1)
  784. '    Call PropBag.WriteProperty("BorderStyle", UserControl.BorderStyle, 0)
  785.     Call PropBag.WriteProperty("Picture", m_Picture, Nothing)
  786.     Call PropBag.WriteProperty("DownPicture", m_DownPicture, Nothing)
  787.     Call PropBag.WriteProperty("FlatPicture", m_FlatPicture, Nothing)
  788.     Call PropBag.WriteProperty("PictureAlign", m_PictureAlign, m_def_PictureAlign)
  789.     Call PropBag.WriteProperty("Caption", m_Caption, m_def_Caption)
  790.     Call PropBag.WriteProperty("MaskColor", m_MaskColor, &HC0C0C0)
  791.     Call PropBag.WriteProperty("Style", m_Style, m_def_Style)
  792.     Call PropBag.WriteProperty("DropDown", m_DropDown, m_def_DropDown)
  793.     Call PropBag.WriteProperty("ColorDarkShadow", m_ButtonDarkShadow, vb3DDKShadow)
  794.     Call PropBag.WriteProperty("ColorLightShadow", m_ButtonLightShadow, vbButtonShadow)
  795.     Call PropBag.WriteProperty("ColorHighlight", m_ButtonHighlight, vb3DHighlight)
  796.     Call PropBag.WriteProperty("ShowFlatGrey", m_ShowFlatGrey, False)
  797.     Call PropBag.WriteProperty("ButtonGroup", m_ButtonGroup, m_def_ButtonGroup)
  798.     Call PropBag.WriteProperty("ButtonGroupDefault", m_ButtonGroupDefault, m_def_ButtonGroupDefault)
  799.     Call PropBag.WriteProperty("ButtonGroupDefault2", m_ButtonGroupDefault2, m_def_ButtonGroupDefault2)
  800.     Call PropBag.WriteProperty("Value", m_Value, False)
  801. End Sub
  802.  
  803. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  804. 'MemberInfo=10,0,0,0
  805. Public Property Get MaskColor() As OLE_COLOR
  806. Attribute MaskColor.VB_Description = "Sets/gets mask color to use when drawing picture"
  807.     MaskColor = m_MaskColor
  808. End Property
  809.  
  810. Public Property Let MaskColor(ByVal New_MaskColor As OLE_COLOR)
  811.     m_MaskColor = New_MaskColor
  812.     PropertyChanged "MaskColor"
  813.     DrawButton
  814. End Property
  815.  
  816. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  817. 'MemberInfo=7,0,0,0
  818. Public Property Get Style() As vbuStyle
  819. Attribute Style.VB_Description = "Gets/Sets the style of the button"
  820.     Style = m_Style
  821. End Property
  822.  
  823. Public Property Let Style(ByVal New_Style As vbuStyle)
  824.     m_Style = New_Style
  825.     PropertyChanged "Style"
  826.     DrawButton
  827. End Property
  828.  
  829. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  830. 'MemberInfo=0,0,0,False
  831. Public Property Get DropDown() As Boolean
  832. Attribute DropDown.VB_Description = "Determines whether or not to display the Drop Down Button."
  833.     DropDown = m_DropDown
  834. End Property
  835.  
  836. Public Property Let DropDown(ByVal New_DropDown As Boolean)
  837.     m_DropDown = New_DropDown
  838.     PropertyChanged "DropDown"
  839.     DrawButton
  840. End Property
  841.  
  842. 'kdq 10/19/98 added for seperator/handle
  843. Private Sub DrawVLine(ByVal x As Single, ByVal y As Single, ByVal cx As Single, ByVal cy As Single)
  844.     Line (x + 1, y)-(x + 1, y + cy), m_ButtonHighlight
  845.     Line (x, y)-(x, y + cy), m_ButtonLightShadow
  846. End Sub
  847.  
  848. 'kdq 11/03/98 added for seperator/handle
  849. Private Sub DrawHLine(ByVal x As Single, ByVal y As Single, ByVal cx As Single, ByVal cy As Single)
  850.     Line (x, y + 1)-(x + cx, y + 1), m_ButtonHighlight
  851.     Line (x, y)-(x + cx, y), m_ButtonLightShadow
  852. End Sub
  853.  
  854. 'kdq 10/19/98 added for seperator/handle
  855. Private Sub DrawRaisedVLine(ByVal x As Single, ByVal y As Single, ByVal cx As Single, ByVal cy As Single)
  856.     Line (x, y)-(x, y + cy), m_ButtonHighlight
  857.     Line (x + 1, y)-(x + 1, y + cy), m_ButtonHighlight
  858.     Line (x + 2, y)-(x + 2, y + cy), m_ButtonHighlight
  859.     Line (x, y + 1)-(x, y + cy), m_ButtonLightShadow
  860.     Line (x + 1, y + 1)-(x + 1, y + cy), m_ButtonLightShadow
  861.     Line (x + 2, y + 1)-(x + 2, y + cy), m_ButtonLightShadow
  862.     Line (x, y)-(x, y + cy - 1), m_ButtonHighlight
  863.     Line (x + 1, y + 1)-(x + 1, y + cy - 1), m_ButtonFace
  864. End Sub
  865.  
  866. 'kdq 11/03/98 added for seperator/handle
  867. Private Sub DrawRaisedHLine(ByVal x As Single, ByVal y As Single, ByVal cx As Single, ByVal cy As Single)
  868.     Line (x, y)-(x + cx, y), m_ButtonHighlight
  869.     Line (x, y + 1)-(x + cx, y + 1), m_ButtonHighlight
  870.     Line (x, y + 2)-(x + cx, y + 2), m_ButtonHighlight
  871.     Line (x + 1, y)-(x + cx, y), m_ButtonLightShadow
  872.     Line (x + 1, y + 1)-(x + cx, y + 1), m_ButtonLightShadow
  873.     Line (x + 1, y + 2)-(x + cx, y + 2), m_ButtonLightShadow
  874.     Line (x, y)-(x + cx - 1, y), m_ButtonHighlight
  875.     Line (x + 1, y + 1)-(x + cx - 1, y + 1), m_ButtonFace
  876. End Sub
  877.  
  878. 'kdq 10/19/98 added to make thinner border for CoolButton
  879. Private Sub DrawShadowBox(RectSize As RECT, ByVal Pressed As Boolean, ByVal DKShadow As Boolean)
  880.     Dim x As Integer, y As Integer, cx As Integer, cy As Integer
  881.     x = RectSize.Left
  882.     y = RectSize.Top
  883.     cx = RectSize.Right
  884.     cy = RectSize.Bottom
  885.     
  886.     If DKShadow Then
  887.         If Pressed Then
  888.             Line (x, y)-(x + cx - 1, y), m_ButtonDarkShadow
  889.             Line (x, y)-(x, y + cy - 1), m_ButtonDarkShadow
  890.             Line (x + 1, y + 1)-(x + cx - 2, y + 1), m_ButtonLightShadow
  891.             Line (x + 1, y + 1)-(x + 1, y + cy - 2), m_ButtonLightShadow
  892.             Line (x + cx - 1, y)-(x + cx - 1, y + cy), m_ButtonHighlight
  893.             Line (x, y + cy - 1)-(x + cx, y + cy - 1), m_ButtonHighlight
  894.         Else
  895.             Line (x, y)-(x + cx - 1, y), m_ButtonHighlight
  896.             Line (x, y)-(x, y + cy - 1), m_ButtonHighlight
  897.             Line (x + cx - 2, y + 1)-(x + cx - 2, y + cy - 1), m_ButtonLightShadow
  898.             Line (x + 1, y + cy - 2)-(x + cx - 1, y + cy - 2), m_ButtonLightShadow
  899.             Line (x + cx - 1, y)-(x + cx - 1, y + cy), m_ButtonDarkShadow
  900.             Line (x, y + cy - 1)-(x + cx, y + cy - 1), m_ButtonDarkShadow
  901.         End If
  902.     Else
  903.         Dim Color1 As Long
  904.         Dim Color2 As Long
  905.         If Pressed Then
  906.             Color1 = m_ButtonLightShadow
  907.             Color2 = m_ButtonHighlight
  908.         Else
  909.             Color1 = m_ButtonHighlight
  910.             Color2 = m_ButtonLightShadow
  911.         End If
  912.         Line (x, y)-(x + cx - 1, y), Color1
  913.         Line (x, y)-(x, y + cy - 1), Color1
  914.         Line (x + cx - 1, y)-(x + cx - 1, y + cy), Color2
  915.         Line (x, y + cy - 1)-(x + cx, y + cy - 1), Color2
  916.     End If
  917. End Sub
  918.  
  919. Public Property Get ColorLightShadow() As OLE_COLOR
  920. Attribute ColorLightShadow.VB_Description = "Sets/gets color of border light shadow"
  921.     ColorLightShadow = m_ButtonLightShadow
  922. End Property
  923.  
  924. Public Property Let ColorLightShadow(ByVal New_Value As OLE_COLOR)
  925.     If Not (m_ButtonLightShadow = New_Value) Then
  926.         m_ButtonLightShadow = New_Value
  927.         DrawButton
  928.     End If
  929.     PropertyChanged "ColorLightShadow"
  930. End Property
  931.  
  932. 'kdq 10/19/98
  933. Public Property Get ColorDarkShadow() As OLE_COLOR
  934. Attribute ColorDarkShadow.VB_Description = "Sets/gets color of border 3D dark shadow"
  935.     ColorDarkShadow = m_ButtonDarkShadow
  936. End Property
  937.  
  938. Public Property Let ColorDarkShadow(ByVal New_Value As OLE_COLOR)
  939.     If Not (m_ButtonDarkShadow = New_Value) Then
  940.         m_ButtonDarkShadow = New_Value
  941.         DrawButton
  942.     End If
  943.     PropertyChanged "ColorDarkShadow"
  944. End Property
  945.  
  946. 'kdq 10/19/98
  947. Public Property Get ColorHighlight() As OLE_COLOR
  948. Attribute ColorHighlight.VB_Description = "Sets/gets color of border 3D highlight"
  949.     ColorHighlight = m_ButtonHighlight
  950. End Property
  951.  
  952. Public Property Let ColorHighlight(ByVal New_Value As OLE_COLOR)
  953.     If Not (m_ButtonHighlight = New_Value) Then
  954.         m_ButtonHighlight = New_Value
  955.         DrawButton
  956.     End If
  957.     PropertyChanged "ColorHighlight"
  958. End Property
  959.  
  960. 'kdq 10/19/98
  961. Public Sub ShowAbout()
  962. Attribute ShowAbout.VB_Description = "Show about box"
  963. Attribute ShowAbout.VB_UserMemId = -552
  964.     frmAbout.Show vbModal
  965. End Sub
  966.  
  967. 'kdq 10/19/98 picture to display when mousedown on cool button
  968. Public Property Get DownPicture() As Picture
  969. Attribute DownPicture.VB_Description = "Sets/gets picture to be displayed if button is pushed"
  970.     Set DownPicture = m_DownPicture
  971. End Property
  972.  
  973. Public Property Set DownPicture(ByVal New_DownPicture As Picture)
  974.     Set m_DownPicture = New_DownPicture
  975.     PropertyChanged "DownPicture"
  976. End Property
  977.  
  978. 'kdq 10/19/98 picture to display when mouse is not over button on cool button
  979. Public Property Get FlatPicture() As Picture
  980. Attribute FlatPicture.VB_Description = "Sets/gets picture to display when mouse is not over button (Cool button only)"
  981.     Set FlatPicture = m_FlatPicture
  982. End Property
  983.  
  984. Public Property Set FlatPicture(ByVal New_FlatPicture As Picture)
  985.     Set m_FlatPicture = New_FlatPicture
  986.     DrawButton
  987.     PropertyChanged "FlatPicture"
  988. End Property
  989.  
  990. 'kdq 10/19/98 display picture as greyscale when mouse is not over Cool Button
  991. Public Property Get ShowFlatGrey() As Boolean
  992. Attribute ShowFlatGrey.VB_Description = "Sets/gets a value to determine if picture is drawn in greyscale when mouse is not over button"
  993.     ShowFlatGrey = m_ShowFlatGrey
  994. End Property
  995.  
  996. Public Property Let ShowFlatGrey(ByVal New_Value As Boolean)
  997.     m_ShowFlatGrey = New_Value
  998.     PropertyChanged "DropDown"
  999.     DrawButton
  1000. End Property
  1001.  
  1002. Public Property Get ButtonGroup() As String
  1003.     ButtonGroup = m_ButtonGroup
  1004. End Property
  1005.  
  1006. Public Property Let ButtonGroup(ByVal New_ButtonGroup As String)
  1007.     If Not (m_ButtonGroup = New_ButtonGroup) Then
  1008.         m_ButtonGroup = New_ButtonGroup
  1009.         If m_Style = [Up-Down Button] Then
  1010.             CheckButtonGroup
  1011.             Cls
  1012.             UserControl_Paint
  1013.         End If
  1014.     End If
  1015.     PropertyChanged "ButtonGroup"
  1016. End Property
  1017.  
  1018. Public Property Get ButtonGroupDefault() As Boolean
  1019.     ButtonGroupDefault = m_ButtonGroupDefault
  1020. End Property
  1021.  
  1022. Public Property Let ButtonGroupDefault(ByVal New_ButtonGroupDefault As Boolean)
  1023.     'The following line of code ensures that the integer
  1024.     'value of the boolean parameter is either
  1025.     '0 or -1.  It is known that Access 97 will
  1026.     'set the boolean's value to 255 for true.
  1027.     'In this case a P-Code compiled VB5 built
  1028.     'OCX will return True for the expression
  1029.     '(Not [boolean variable that ='s 255]).  This
  1030.     'line ensures the reliability of boolean operations
  1031.     If CBool(New_ButtonGroupDefault) Then New_ButtonGroupDefault = True Else New_ButtonGroupDefault = False
  1032.     If Not (m_ButtonGroupDefault = New_ButtonGroupDefault) Then
  1033.         m_ButtonGroupDefault = New_ButtonGroupDefault
  1034.         If m_Style = [Up-Down Button] Then
  1035.             CheckButtonGroupDefault
  1036.             CheckButtonGroup
  1037.             Cls
  1038.             UserControl_Paint
  1039.         End If
  1040.     End If
  1041.     PropertyChanged "ButtonGroupDefault"
  1042. End Property
  1043.  
  1044. Private Sub CheckButtonGroupDefault()
  1045.     If (Len(m_ButtonGroup) > 0) Then
  1046.         If m_ButtonGroupDefault Then     ' make all others in group not default
  1047.             Dim ctl As Control
  1048.             Dim i As Long
  1049.             For i = 0 To UserControl.ParentControls.Count - 1
  1050.                 If TypeOf UserControl.ParentControls(i) Is Control Then
  1051.                     Set ctl = UserControl.ParentControls(i)
  1052.                     If TypeOf ctl Is axButton Then
  1053.                         If ctl.ButtonGroup = m_ButtonGroup Then
  1054.                             If Not ((ctl Is UserControl.Extender) Or (ctl Is UserControl)) Then
  1055.                                 ctl.ButtonGroupDefault = False
  1056.                             End If
  1057.                         End If
  1058.                     End If
  1059.                 End If
  1060.             Next
  1061.         End If
  1062.     End If
  1063. End Sub
  1064.  
  1065. Public Property Get ButtonGroupDefault2() As Boolean
  1066.     ButtonGroupDefault2 = m_ButtonGroupDefault2
  1067. End Property
  1068.  
  1069. Public Property Let ButtonGroupDefault2(ByVal New_ButtonGroupDefault2 As Boolean)
  1070.     'The following line of code ensures that the integer
  1071.     'value of the boolean parameter is either
  1072.     '0 or -1.  It is known that Access 97 will
  1073.     'set the boolean's value to 255 for true.
  1074.     'In this case a P-Code compiled VB5 built
  1075.     'OCX will return True for the expression
  1076.     '(Not [boolean variable that ='s 255]).  This
  1077.     'line ensures the reliability of boolean operations
  1078.     If CBool(New_ButtonGroupDefault2) Then New_ButtonGroupDefault2 = True Else New_ButtonGroupDefault2 = False
  1079.     If Not (m_ButtonGroupDefault2 = New_ButtonGroupDefault2) Then
  1080.         m_ButtonGroupDefault2 = New_ButtonGroupDefault2
  1081.         If m_Style = [Up-Down Button] Then
  1082.             CheckButtonGroupDefault2
  1083.             CheckButtonGroup
  1084.             Cls
  1085.             UserControl_Paint
  1086.         End If
  1087.     End If
  1088.     PropertyChanged "ButtonGroupDefault2"
  1089. End Property
  1090.  
  1091. Private Sub CheckButtonGroupDefault2()
  1092.     If (Len(m_ButtonGroup) > 0) Then
  1093.         If m_ButtonGroupDefault2 Then     ' make all others in group not default
  1094.             Dim ctl As Control
  1095.             Dim i As Long
  1096.             For i = 0 To UserControl.ParentControls.Count - 1
  1097.                 If TypeOf UserControl.ParentControls(i) Is Control Then
  1098.                     Set ctl = UserControl.ParentControls(i)
  1099.                     If TypeOf ctl Is axButton Then
  1100.                         If ctl.ButtonGroup = m_ButtonGroup Then
  1101.                             If Not ((ctl Is UserControl.Extender) Or (ctl Is UserControl)) Then
  1102.                                 ctl.ButtonGroupDefault2 = False
  1103.                             End If
  1104.                         End If
  1105.                     End If
  1106.                 End If
  1107.             Next
  1108.         End If
  1109.     End If
  1110. End Sub
  1111.  
  1112. Private Sub CheckButtonGroup()
  1113.     If (Len(m_ButtonGroup) > 0) Then
  1114.         Dim ctl As Control
  1115.         Dim i As Long
  1116.         If m_Value Then     ' clear all others in group
  1117.             For i = 0 To UserControl.ParentControls.Count - 1
  1118.                 If TypeOf UserControl.ParentControls(i) Is Control Then
  1119.                     Set ctl = UserControl.ParentControls(i)
  1120.                     If TypeOf ctl Is axButton Then
  1121.                         If ctl.ButtonGroup = m_ButtonGroup Then
  1122.                             If Not ((ctl Is UserControl.Extender) Or (ctl Is UserControl)) Then
  1123.                                 ctl.Value = False
  1124.                             End If
  1125.                         End If
  1126.                     End If
  1127.                 End If
  1128.             Next
  1129.         Else                 ' set group default if necessary
  1130.             Dim GroupValueSet As Boolean
  1131.             Dim ctlDefault As axButton
  1132.             Dim ctlDefault2 As axButton
  1133.             Set ctlDefault = Nothing
  1134.             Set ctlDefault2 = Nothing
  1135.             GroupValueSet = False
  1136.             For i = 0 To UserControl.ParentControls.Count - 1
  1137.                 If TypeOf UserControl.ParentControls(i) Is Control Then
  1138.                     Set ctl = UserControl.ParentControls(i)
  1139.                     If TypeOf ctl Is axButton Then
  1140.                         If ctl.ButtonGroup = m_ButtonGroup Then
  1141. '                            If Not ((ctl Is UserControl.Extender) Or (ctl Is UserControl)) Then
  1142.                                 If ctl.Value Then
  1143.                                     GroupValueSet = True
  1144.                                     Exit For
  1145.                                 ElseIf ctl.ButtonGroupDefault Then
  1146.                                     Set ctlDefault = ctl
  1147.                                 ElseIf ctl.ButtonGroupDefault2 Then
  1148.                                     Set ctlDefault2 = ctl
  1149.                                 End If
  1150. '                            End If
  1151.                         End If
  1152.                     End If
  1153.                 End If
  1154.             Next
  1155.             If Not (GroupValueSet Or (ctlDefault Is Nothing)) Then
  1156.                 If (Not m_ButtonGroupDefault) Or (ctlDefault2 Is Nothing) Then
  1157.                     ctlDefault.Value = True
  1158.                 Else
  1159.                     ctlDefault2.Value = True
  1160.                 End If
  1161.             End If
  1162.         End If
  1163.     End If
  1164. End Sub
  1165.  
  1166. Public Property Get Value() As Boolean
  1167.     Value = m_Value
  1168. End Property
  1169.  
  1170. Public Property Let Value(ByVal New_Value As Boolean)
  1171.     'The following line of code ensures that the integer
  1172.     'value of the boolean parameter is either
  1173.     '0 or -1.  It is known that Access 97 will
  1174.     'set the boolean's value to 255 for true.
  1175.     'In this case a P-Code compiled VB5 built
  1176.     'OCX will return True for the expression
  1177.     '(Not [boolean variable that ='s 255]).  This
  1178.     'line ensures the reliability of boolean operations
  1179.     If CBool(New_Value) Then New_Value = True Else New_Value = False
  1180.     If Not (m_Value = New_Value) Then
  1181.         m_Value = New_Value
  1182.         If m_Style = [Up-Down Button] Then
  1183.             CheckButtonGroup
  1184.             Cls
  1185.             UserControl_Paint
  1186.         End If
  1187.     End If
  1188.     PropertyChanged "Value"
  1189. End Property
  1190.  
  1191. Private Sub PaintUpDownDither(x As Long, y As Long, Width As Long, Height As Long)
  1192.     Dim ret As Long
  1193.     Dim MyRect As RECT
  1194.     'draw on the form with that brush
  1195.     MyRect.Left = x
  1196.     MyRect.Top = y
  1197.     MyRect.Right = x + Width
  1198.     MyRect.Bottom = y + Height
  1199.     ret = FillRect(UserControl.hDC, MyRect, hUpDownDitherBrush)
  1200. End Sub
  1201.  
  1202. Private Sub InitializeUpDownDither()
  1203.     Dim i As Long, j As Long
  1204.     
  1205.     '---one-time setup: put this in it's own routine------
  1206.     'set (invisible) picturebox properties for creating a brush
  1207. '    UserControl.ScaleMode = vbPixels
  1208. '    UserControl.AutoRedraw = True
  1209.     'draw the dither in it
  1210.     For i = 0 To UserControl.ScaleWidth - 1
  1211.         For j = 0 To UserControl.ScaleHeight - 1
  1212.             If (i + j) Mod 2 Then
  1213.                 UserControl.PSet (i, j), vb3DHighlight
  1214.             Else
  1215.                 UserControl.PSet (i, j), vbButtonFace
  1216.             End If
  1217.         Next j
  1218.     Next i
  1219.     '---end of one-time setup------
  1220.  
  1221.     'create the brush from it
  1222.     hUpDownDitherBrush = CreatePatternBrush(UserControl.Image.handle)
  1223.  
  1224. End Sub
  1225.  
  1226.