Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to draw a round rectangle[emergency]

how to draw a round rectangle[emergency]

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MJay
    wrote on last edited by
    #1

    as topic, i can find DrawEllipse, DrawRectangle in picturebox control but i cant find DrawRoundRec in VB.Net !! anyone can help me plz...:confused: this is the roundrectangle i mean...(of coz the lines must be connected each other) ____ (____)

    D C 2 Replies Last reply
    0
    • M MJay

      as topic, i can find DrawEllipse, DrawRectangle in picturebox control but i cant find DrawRoundRec in VB.Net !! anyone can help me plz...:confused: this is the roundrectangle i mean...(of coz the lines must be connected each other) ____ (____)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      That's because there isn't one. You're going to have to draw them yourself, line segment by line segment. You might want to look into GraphicsPath for creating an object that can be drawn all at once. RageInTheMachine9532

      1 Reply Last reply
      0
      • M MJay

        as topic, i can find DrawEllipse, DrawRectangle in picturebox control but i cant find DrawRoundRec in VB.Net !! anyone can help me plz...:confused: this is the roundrectangle i mean...(of coz the lines must be connected each other) ____ (____)

        C Offline
        C Offline
        cnurse
        wrote on last edited by
        #3

        Hi, Here's a couple of functions I wrote that will draw you a rectangle with rounded corners. I just ripped them out of my own code, so I hope I didn't miss anything. Just call DrawRoundedRectangle and pass it your graphics object, a rectangle to draw in and an integer specifying how "round" you want the corners to be. If you have a program drop me a line. ' Draw an empty rectangle with rounded corners using the same pen for all sides Public Sub DrawRoundedRectangle(ByRef prGraphics As Graphics, ByRef prPen As Pen, ByRef prRect As Rectangle, ByVal pvRounding As Integer) Dim lrectSurface As GraphicsPath lrectSurface = BuildRoundedRectangle(CreateRectangle(prRect.Left, prRect.Top, prRect.Width - 1, prRect.Height - 1), pvRounding) prGraphics.DrawPath(prPen, lrectSurface) End Sub ' Build a graphic path for a rounded rectangle/square Public Function BuildRoundedRectangle(ByRef prRect As Rectangle, ByVal pvRounding As Integer) As GraphicsPath Dim lPath As New GraphicsPath() Dim lHalf As Integer = CInt(pvRounding / 2) With prRect lPath.StartFigure() lPath.AddArc(.Left, .Top, pvRounding, pvRounding, 180, 90) lPath.AddLine(.Left + lHalf, .Top, .Right - lHalf, .Top) lPath.AddArc(.Right - pvRounding, .Top, pvRounding, pvRounding, 270, 90) lPath.AddLine(.Right, .Top + lHalf, .Right, .Bottom - pvRounding) lPath.AddArc(.Right - pvRounding, .Bottom - pvRounding, pvRounding, pvRounding, 0, 90) lPath.AddLine(.Right - lHalf, .Bottom, .Left + lHalf, .Bottom) lPath.AddArc(.Left, .Bottom - pvRounding, pvRounding, pvRounding, 90, 90) lPath.AddLine(.Left, .Bottom - lHalf, .Left, .Top + lHalf) lPath.CloseFigure() End With BuildRoundedRectangle = lPath End Function Nursey

        M 1 Reply Last reply
        0
        • C cnurse

          Hi, Here's a couple of functions I wrote that will draw you a rectangle with rounded corners. I just ripped them out of my own code, so I hope I didn't miss anything. Just call DrawRoundedRectangle and pass it your graphics object, a rectangle to draw in and an integer specifying how "round" you want the corners to be. If you have a program drop me a line. ' Draw an empty rectangle with rounded corners using the same pen for all sides Public Sub DrawRoundedRectangle(ByRef prGraphics As Graphics, ByRef prPen As Pen, ByRef prRect As Rectangle, ByVal pvRounding As Integer) Dim lrectSurface As GraphicsPath lrectSurface = BuildRoundedRectangle(CreateRectangle(prRect.Left, prRect.Top, prRect.Width - 1, prRect.Height - 1), pvRounding) prGraphics.DrawPath(prPen, lrectSurface) End Sub ' Build a graphic path for a rounded rectangle/square Public Function BuildRoundedRectangle(ByRef prRect As Rectangle, ByVal pvRounding As Integer) As GraphicsPath Dim lPath As New GraphicsPath() Dim lHalf As Integer = CInt(pvRounding / 2) With prRect lPath.StartFigure() lPath.AddArc(.Left, .Top, pvRounding, pvRounding, 180, 90) lPath.AddLine(.Left + lHalf, .Top, .Right - lHalf, .Top) lPath.AddArc(.Right - pvRounding, .Top, pvRounding, pvRounding, 270, 90) lPath.AddLine(.Right, .Top + lHalf, .Right, .Bottom - pvRounding) lPath.AddArc(.Right - pvRounding, .Bottom - pvRounding, pvRounding, pvRounding, 0, 90) lPath.AddLine(.Right - lHalf, .Bottom, .Left + lHalf, .Bottom) lPath.AddArc(.Left, .Bottom - pvRounding, pvRounding, pvRounding, 90, 90) lPath.AddLine(.Left, .Bottom - lHalf, .Left, .Top + lHalf) lPath.CloseFigure() End With BuildRoundedRectangle = lPath End Function Nursey

          M Offline
          M Offline
          MJay
          wrote on last edited by
          #4

          thanks for replying me!! i think i need ur program understand how the coding works, can u send to me? my email is mjlai83@pd.jaring.my thanks again for help!!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups