Adblock breaks this site

how to make shapes?

Discussion in 'Programming General' started by Mocro4LifeG, Feb 3, 2007.

  1. Mocro4LifeG

    Mocro4LifeG Newcomer

    Joined:
    Jan 28, 2007
    Posts:
    4
    Referrals:
    0
    Sythe Gold:
    0
    how to make shapes?

    how can you make shapes on vb2005?
     
  2. Flaming Idiots

    Flaming Idiots Active Member
    Visual Basic Programmers

    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User
    how to make shapes?

    If you want shaped controls, you need to make them. If you want to draw them to the form, you just do it in the Paint event.

    Here's some examples of the shape controls.
    Code:
    Public Class Circle
        Inherits Control
        Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
            Dim Circle As New Drawing2D.GraphicsPath
            Circle.AddEllipse(New Rectangle(New Point(0, 0), Me.Size))
            Me.Region = New Region(Circle)
            Circle.Reset() : Circle.AddEllipse(New Rectangle(New Point(1, 1), Me.Size - New Size(2, 2)))
            e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
            e.Graphics.Clear(Me.Parent.BackColor)
            e.Graphics.FillPath(New SolidBrush(Me.BackColor), Circle)
            e.Graphics.DrawPath(New Pen(Me.ForeColor), Circle)
            Circle.Dispose()
            MyBase.OnPaint(e)
        End Sub
    End Class
    
    Public Class Square
        Inherits Control
        Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
            Dim Circle As New Drawing2D.GraphicsPath
            Circle.AddRectangle(New Rectangle(New Point(0, 0), Me.Size))
            Me.Region = New Region(Circle)
            Circle.Reset() : Circle.AddRectangle(New Rectangle(New Point(1, 1), Me.Size - New Size(2, 2)))
            e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
            e.Graphics.Clear(Me.Parent.BackColor)
            e.Graphics.FillPath(New SolidBrush(Me.BackColor), Circle)
            e.Graphics.DrawPath(New Pen(Me.ForeColor), Circle)
            Circle.Dispose()
            MyBase.OnPaint(e)
        End Sub
    End Class
     
  3. Mocro4LifeG

    Mocro4LifeG Newcomer

    Joined:
    Jan 28, 2007
    Posts:
    4
    Referrals:
    0
    Sythe Gold:
    0
    how to make shapes?

    aaaaahhh ok now i get it ty
     
< Hot keys made easy | Opening links in a custom webbrowser >


 
 
Adblock breaks this site