|
-
Jan 13th, 2007, 03:28 PM
#1
Thread Starter
Hyperactive Member
ReDraw UserControl
I have a user control, but I'd like to change its back color during runtime from another form... How do I do that?
The code I am using for the usercontrol
VB Code:
Private Declare Function Arc Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
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
Public Sub DrawArc(ByVal hdc As Long, ByVal X As Integer, ByVal Y As Integer, ByVal StartAngle As Integer, ByVal EndAngle As Integer, ByVal radius As Integer)
Dim xs As Integer, ys As Integer, xe As Integer, ye As Integer
Dim sat As Integer
sat = (StartAngle - 90) Mod 360
If (StartAngle >= 360) And (sat = 0) Then
sat = 360
End If
xs = Int(X - (radius * Sin((sat / 180) * 3.14159267)))
ys = Int(Y - (radius * Cos((sat / 180) * 3.14159267)))
sat = (EndAngle - 90) Mod 360
If (EndAngle >= 360) And (sat = 0) Then
sat = 360
End If
xe = Int(X - (radius * Sin((sat / 180) * 3.14159267)))
ye = Int(Y - (radius * Cos((sat / 180) * 3.14159267)))
If Abs(EndAngle - StartAngle) < 360 Then
Arc hdc, X - radius, Y - radius, X + radius, Y + radius, xs, ys, xe, ye
Else
: Ellipse hdc, X - radius, Y - radius, X + radius, Y + radius
End If
End Sub
Private Sub UserControl_Initialize()
UserControl.ScaleMode = vbPixels
End Sub
Private Sub UserControl_InitProperties()
UserControl_Resize
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
UserControl_Resize
End Sub
Private Sub UserControl_Resize()
Dim intMinSize As Integer
UserControl.BackColor = UserControl.MaskColor
UserControl.FillColor = lngColor 'strClickColor
If UserControl.ScaleWidth <= UserControl.ScaleHeight Then
intMinSize = UserControl.ScaleWidth \ 2
Else
intMinSize = UserControl.ScaleHeight \ 2
End If
DrawArc UserControl.hdc, UserControl.ScaleWidth \ 2, UserControl.ScaleHeight \ 2, 0, 360, intMinSize
UserControl.FillColor = UserControl.MaskColor
DrawArc UserControl.hdc, UserControl.ScaleWidth \ 2, UserControl.ScaleHeight \ 2, 0, 360, intMinSize \ 2
Set UserControl.MaskPicture = UserControl.Image
UserControl.BackColor = lngColor 'strClickColor
End Sub
The usercontrol is supposed to be a clickwheel
Hey... If you found this post helpful please rate it.

-
Jan 13th, 2007, 04:09 PM
#2
Re: ReDraw UserControl
Add a public property to the UserControl that maps to the UserControl.BackColor property. The following was generated by the UserControl
Interface Wizard.
VB Code:
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,BackColor
Public Property Get BackColor() As OLE_COLOR
BackColor = UserControl.BackColor
End Property
Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
UserControl.BackColor() = New_BackColor
PropertyChanged "BackColor"
End Property
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
UserControl.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("BackColor", UserControl.BackColor, &H8000000F)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|