写自制控件控件求教各位高手,谢谢!!!
我想做一个图控件,调用时(有以下几个简单属性:1:能够改变背景色 2:改变控件大小时,里面图也改变大小 3:能改变里面绘制图的颜色 4:当鼠标移到上面时,能有提示(自定义提示能容))
请高手们给与帮助,谢谢!!!
Public Class FM Dim Controlvalve As Bitmap Private Sub FM_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Pi1.BackColor = Me.BackColor Drawimge() End Sub Private Sub Drawimge() Controlvalve = New Bitmap(Pi1.Width, Pi1.Height) Using G As Graphics = Graphics.FromImage(Controlvalve) Dim myColor As Color Dim mPen As New Pen(myColor) mPen.Color = Color.Red mPen.Width = 2 Dim p1 As New Point(Pi1.Width * 0.01, Pi1.Height * 0.4) Dim p2 As New Point(Pi1.Width * 0.01, Pi1.Height * 0.98) Dim p3 As New Point(Pi1.Width * 0.98, Pi1.Height * 0.4) Dim p4 As New Point(Pi1.Width * 0.98, Pi1.Height * 0.98) Dim ps As Point() = {p1, p2, p3, p4} G.DrawPolygon(mPen, ps) G.DrawLine(mPen, CInt(Pi1.Width * 0.5), CInt(Pi1.Height * 0.3), CInt(Pi1.Width * 0.5), CInt(Pi1.Height * 0.69)) G.DrawLine(mPen, CInt(Pi1.Width * 0.2), CInt(Pi1.Height * 0.3), CInt(Pi1.Width * 0.8), CInt(Pi1.Height * 0.3)) Dim rect1 As New Rectangle(CInt(Pi1.Width * 0.2), CInt(Pi1.Height * 0.05), CInt(Pi1.Width * 0.6), CInt(Pi1.Height * 0.3)) G.DrawArc(mPen, rect1, 0, -180) ' G.FillPolygon() Pi1.Image = Controlvalve End Using Pi1.Refresh() End Sub Private Sub FM_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove Drawimge()End Sub End Class