Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <DisplayName("MyExtendedButton")>
- <Description("A extended Button control.")>
- <DesignTimeVisible(True)>
- <DesignerCategory("UserControl")>
- <ToolboxBitmap(GetType(Button), "Button.bmp")>
- <ToolboxItemFilter("System.Windows.Forms", ToolboxItemFilterType.Require)>
- <ClassInterface(ClassInterfaceType.AutoDispatch)>
- <ComVisible(True)>
- <DefaultProperty("Text")>
- <DefaultEvent("Click")>
- Public NotInheritable Class MyButton : Inherits Button
- <Browsable(True)>
- <EditorBrowsable(EditorBrowsableState.Always)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- <Localizable(False)>
- <Description("The border color of the control.")>
- <DefaultValue(GetType(Color), "ControlLight")>
- Public Property BorderColor As Color = Color.Red
- <DebuggerNonUserCode>
- Public Sub New()
- MyBase.SuspendLayout()
- MyBase.SetStyle(ControlStyles.DoubleBuffer, True)
- ' MyBase.SetStyle(ControlStyles.AllPaintingInWmPaint, ...)
- ' MyBase.SetStyle(ControlStyles.ResizeRedraw, ...)
- ' MyBase.SetStyle(ControlStyles.UserPaint, ...)
- ' MyBase.SetStyle(ControlStyles.SupportsTransparentBackColor, ...)
- MyBase.ResumeLayout(performLayout:=False)
- End Sub
- <DebuggerStepThrough>
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- MyBase.OnPaint(e)
- End Sub
- <DebuggerStepThrough>
- Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs)
- MyBase.OnPaintBackground(e)
- End Sub
- <DebuggerStepperBoundary>
- Protected Overrides Sub WndProc(ByRef m As Message)
- MyBase.WndProc(m)
- Select Case m.Msg
- Case 15 ' WM_Paint
- Me.DrawBorder()
- End Select
- End Sub
- <DebuggerStepperBoundary>
- Private Sub DrawBorder()
- Using g As Graphics = MyBase.CreateGraphics()
- ControlPaint.DrawBorder(g, MyBase.ClientRectangle,
- Me.BorderColor, 1, ButtonBorderStyle.Solid, ' left
- Me.BorderColor, 1, ButtonBorderStyle.Solid, ' top
- Me.BorderColor, 1, ButtonBorderStyle.Solid, ' right
- Me.BorderColor, 1, ButtonBorderStyle.Solid) ' bottom
- End Using
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement