Results 1 to 6 of 6

Thread: Rounded Corners In VB.NET (Forms)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    2

    Rounded Corners In VB.NET (Forms)

    I have been looking all other the net, searching the forum. I can't find any API for rouding corners for forms in VB.NET.

    Please help me find a example code, since I am kind of newbie!

    Thanks in advance.

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Check out Region Master Controls - not only rounded corners, but even discontinious forms - really neat stuff.
    http://www.windowsforms.net/ControlG...219&tabindex=0

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    Perhaps you can obtain the same effect by coding if you create an ellipse with a different backcolor and place all your controls inside it. Then make the form fullscreen, set the form.text to "" and hide the controlbox. viz

    VB Code:
    1. With Me
    2. .WindowState = FormWindowState.Maximized
    3. .Text = ""
    4. .ControlBox = False
    5. End With

    You can, of course, put hyperbolic curves on your form and backcolor the area inside or outside of them different colors, if you don't want a pure ellipse.
    Last edited by taxes; Jul 11th, 2004 at 01:27 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    2
    Still need help

    I need a example-code of rounded corners in a form!

  5. #5
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    The Region Master download is an example, complete with full source code. Have you even tried it?

  6. #6
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    To draw rounded corners it is necessary to familiarize yourself with the GraphicsPath object as well as Arcs and pretty much all drawing concepts.

    This code will do what you ask, but you will have to modify it for your purposes:

    VB Code:
    1. Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    2.         Dim gpBrush As LinearGradientBrush
    3.         Dim gp As New GraphicsPath
    4.         gpBrush = New LinearGradientBrush(New Point(0, 0), New Point(Me.Width, 40), Color.MidnightBlue, Color.White)
    5.         gp.AddArc(0, 0, 20, 20, 180, 90)
    6.         gp.AddArc(Me.Width - 22, 0, 20, 20, 270, 90)
    7.         'e.Graphics.FillRectangle(gpBrush, New Rectangle(0, 0, Me.Width, 20))
    8.         e.Graphics.FillPath(gpBrush, gp)
    9.     End Sub
    Whadayamean it doesn't work....
    It works fine on my machine!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width