home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.UserControl Gradient
- BorderStyle = 1 'Fixed Single
- ClientHeight = 3600
- ClientLeft = 0
- ClientTop = 0
- ClientWidth = 4800
- ControlContainer= -1 'True
- PropertyPages = "Gradient.ctx":0000
- ScaleHeight = 240
- ScaleMode = 3 'Pixel
- ScaleWidth = 320
- ToolboxBitmap = "Gradient.ctx":0020
- End
- Attribute VB_Name = "Gradient"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = True
- Attribute VB_Ext_KEY = "PropPageWizardRun" ,"Yes"
- Option Explicit
- Enum Directions
- Horizontal
- Vertical
- End Enum
-
- 'Default Property Values:
- Const m_def_StartColor = &H404040
- Const m_def_EndColor = &HC0C0C0
- Const m_def_GradientDirection = Directions.Horizontal
- 'Property Variables:
- Dim m_StartColor As OLE_COLOR
- Dim m_EndColor As OLE_COLOR
- Dim m_GradientDirection As Directions
-
- Event Click() 'MappingInfo=UserControl,UserControl,-1,Click
- Event DblClick() 'MappingInfo=UserControl,UserControl,-1,DblClick
- Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyDown
- Event KeyPress(KeyAscii As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyPress
- Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyUp
- Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseDown
- Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseMove
- Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseUp
-
- ' SUPPORT FUNCTIONS
- Function GetRed(colorVal As Long) As Integer
- GetRed = colorVal Mod 256
- End Function
-
- Function GetGreen(colorVal As Long) As Integer
- GetGreen = ((colorVal And &HFF00FF00) / 256&)
- End Function
-
- Function GetBlue(colorVal As Long) As Integer
- GetBlue = (colorVal And &HFF0000) / (256& * 256&)
- End Function
-
- Public Property Get StartColor() As OLE_COLOR
- StartColor = m_StartColor
- End Property
-
- Public Property Let StartColor(ByVal New_StartColor As OLE_COLOR)
- m_StartColor = New_StartColor
- PropertyChanged "StartColor"
- UserControl_Paint
- End Property
-
- Public Property Get EndColor() As OLE_COLOR
- EndColor = m_EndColor
- End Property
-
- Public Property Let EndColor(ByVal New_EndColor As OLE_COLOR)
- m_EndColor = New_EndColor
- PropertyChanged "EndColor"
- UserControl_Paint
- End Property
-
- Public Property Get GradientDirection() As Directions
- GradientDirection = m_GradientDirection
- End Property
-
- Public Property Let GradientDirection(ByVal New_GradientDirection As Directions)
- m_GradientDirection = New_GradientDirection
- PropertyChanged "GradientDirection"
- UserControl_Paint
- End Property
-
-
- 'Initialize Properties for User Control
- Private Sub UserControl_InitProperties()
- m_StartColor = m_def_StartColor
- m_EndColor = m_def_EndColor
- m_GradientDirection = m_def_GradientDirection
- End Sub
-
-
- Private Sub UserControl_Paint()
- Dim newColor As Long
- Dim ipixel, PSize As Integer
- Dim redInc, greenInc, blueInc As Single
- Dim color1 As Long, color2 As Long
- Dim startRed, startGreen, startBlue As Integer
- Dim endRed, endGreen, endBlue As Integer
-
- color1 = m_StartColor
- color2 = m_EndColor
-
- startRed = GetRed(color1)
- endRed = GetRed(color2)
- startGreen = GetGreen(color1)
- endGreen = GetGreen(color2)
- startBlue = GetBlue(color1)
- endBlue = GetBlue(color2)
-
- If m_GradientDirection = 0 Then
- PSize = UserControl.ScaleWidth
- Else
- PSize = UserControl.ScaleHeight
- End If
-
- redInc = (endRed - startRed) / PSize
- greenInc = (endGreen - startGreen) / PSize
- blueInc = (endBlue - startBlue) / PSize
-
- If m_GradientDirection = 0 Then
- For ipixel = 0 To PSize
- newColor = RGB(startRed + redInc * ipixel, startGreen + greenInc * ipixel, startBlue + blueInc * ipixel)
- UserControl.Line (ipixel, 0)-(ipixel, UserControl.Height), newColor
- Next
- Else
- For ipixel = 0 To PSize
- newColor = RGB(startRed + redInc * ipixel, startGreen + greenInc * ipixel, startBlue + blueInc * ipixel)
- UserControl.Line (0, ipixel)-(UserControl.Width, ipixel), newColor
- Next
- End If
- If Not Ambient.UserMode Then
- UserControl.CurrentX = 0
- UserControl.CurrentY = 0
- UserControl.Print "Design Mode"
- End If
- End Sub
-
- 'Load property values from storage
- Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
- UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
- UserControl.BorderStyle = PropBag.ReadProperty("BorderStyle", 1)
- m_StartColor = PropBag.ReadProperty("StartColor", m_def_StartColor)
- m_EndColor = PropBag.ReadProperty("EndColor", m_def_EndColor)
- m_GradientDirection = PropBag.ReadProperty("GradientDirection", m_def_GradientDirection)
- UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
- UserControl.BorderStyle = PropBag.ReadProperty("BorderStyle", 1)
- End Sub
-
- 'Write property values to storage
- Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
- Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
- Call PropBag.WriteProperty("BorderStyle", UserControl.BorderStyle, 1)
- Call PropBag.WriteProperty("StartColor", m_StartColor, m_def_StartColor)
- Call PropBag.WriteProperty("EndColor", m_EndColor, m_def_EndColor)
- Call PropBag.WriteProperty("GradientDirection", m_GradientDirection, m_def_GradientDirection)
- Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
- Call PropBag.WriteProperty("BorderStyle", UserControl.BorderStyle, 1)
- End Sub
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Enabled
- Public Property Get Enabled() As Boolean
- Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
- Enabled = UserControl.Enabled
- End Property
-
- Public Property Let Enabled(ByVal New_Enabled As Boolean)
- UserControl.Enabled() = New_Enabled
- PropertyChanged "Enabled"
- End Property
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,BorderStyle
- Public Property Get BorderStyle() As Integer
- Attribute BorderStyle.VB_Description = "Returns/sets the border style for an object."
- BorderStyle = UserControl.BorderStyle
- End Property
-
- Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
- UserControl.BorderStyle() = New_BorderStyle
- PropertyChanged "BorderStyle"
- End Property
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Refresh
- Public Sub Refresh()
- Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
- UserControl.Refresh
- End Sub
-
- Private Sub UserControl_Click()
- RaiseEvent Click
- End Sub
-
- Private Sub UserControl_DblClick()
- RaiseEvent DblClick
- End Sub
-
- Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
- RaiseEvent KeyDown(KeyCode, Shift)
- End Sub
-
- Private Sub UserControl_KeyPress(KeyAscii As Integer)
- RaiseEvent KeyPress(KeyAscii)
- End Sub
-
- Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
- RaiseEvent KeyUp(KeyCode, Shift)
- End Sub
-
- Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseDown(Button, Shift, X, Y)
- End Sub
-
- Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseMove(Button, Shift, X, Y)
- End Sub
-
- Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseUp(Button, Shift, X, Y)
- End Sub
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Appearance
- Public Property Get Appearance() As Integer
- Attribute Appearance.VB_Description = "Returns/sets whether or not an object is painted at run time with 3-D effects."
- Appearance = UserControl.Appearance
- End Property
-
-