how to make shapes?

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

how to make shapes?
  1. Unread #1 - Feb 3, 2007 at 4:27 PM
  2. Mocro4LifeG
    Joined:
    Jan 28, 2007
    Posts:
    4
    Referrals:
    0
    Sythe Gold:
    0

    Mocro4LifeG Newcomer

    how to make shapes?

    how can you make shapes on vb2005?
     
  3. Unread #2 - Feb 4, 2007 at 2:16 AM
  4. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    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
     
  5. Unread #3 - Feb 4, 2007 at 11:29 AM
  6. Mocro4LifeG
    Joined:
    Jan 28, 2007
    Posts:
    4
    Referrals:
    0
    Sythe Gold:
    0

    Mocro4LifeG Newcomer

    how to make shapes?

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

Users viewing this thread
1 guest


 
 
Adblock breaks this site