CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Rounded Rect

  1. #1
    Join Date
    Jun 2001
    Location
    Newcastle Ontario, Canada
    Posts
    118

    Rounded Rect

    I used to use a rounded rectangle shape in C++, but I dont see anything like that in .NET. I've tried making my own using Lines and Bezier cuves, but the corners never seem to be the same shape (slightly off).

    Does anything like this exist...any suggestions? I dont want to take the function out of an existing Windows DLL btw...

    Thanks,
    Steve

  2. #2
    Join Date
    Nov 2001
    Location
    Irvine CA USA
    Posts
    88
    Im looking for this code too. Best i've found so far is GraphicsPath...

    Graphics g = e.Graphics;
    GraphicsPath gp = new GraphicsPath();
    gp.AddLine(x + radius, y, x + width - radius, y);
    gp.AddArc(x + width - radius, y, radius, radius, 270, 90);
    gp.AddLine(x + width, y + radius, x + width, y + height - radius);
    gp.AddArc(x + width - radius, y + height - radius, radius, radius, 0, 90);
    gp.AddLine(x + width - radius, y + height, x + radius, y + height);
    gp.AddArc(x, y + height - radius, radius, radius, 90, 90);
    gp.AddLine(x, y + height - radius, x, y + radius);
    gp.AddArc(x, y, radius, radius, 180, 90);
    gp.CloseFigure();

    But i need to draw a lot of these and i don't want to create a new path for each one. Anyone have a better solution?

  3. #3
    Join Date
    Sep 1999
    Posts
    67
    Hmm, its really weird that .Net doesnt have a basic function like RounderRect. If anyone know a solution to this problem please let us know.

    /Anders

  4. #4
    Join Date
    Jul 2002
    Location
    India
    Posts
    505

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

Featured