Results 1 to 6 of 6

Thread: [2005] How to Shape a winform to our desired shape?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    144

    Arrow [2005] How to Shape a winform to our desired shape?

    Hai all,
    I have a normal win form.I want that form to have shape with ellipsed corner on all four sides with enlarged size.
    Can anyone of u plz tell me that how to do this?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [2005] How to Shape a winform to our desired shape?

    this will shape your form

    Code:
    me.region = RoundedRec(10,10,200,100)
    Code:
    Private Function RoundedRec(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer) As System.Drawing.Drawing2D.GraphicsPath
            ' Make and Draw a path.
            Dim graphics_path As New System.Drawing.Drawing2D.GraphicsPath
            graphics_path.AddLine(X + 10, Y, X + Width, Y) 'add the Top line to the path
    
            'Top Right corner        
            Dim tr() As Point = { _
            New Point(X + Width, Y), _
            New Point((X + Width) + 4, Y + 2), _
            New Point((X + Width) + 8, Y + 6), _
            New Point((X + Width) + 10, Y + 10)}
    
            graphics_path.AddCurve(tr)  'Add the Top right curve to the path
    
            'Bottom right corner 
            Dim br() As Point = { _
            New Point((X + Width) + 10, Y + Height), _
            New Point((X + Width) + 8, (Y + Height) + 4), _
            New Point((X + Width) + 4, (Y + Height) + 8), _
            New Point(X + Width, (Y + Height) + 10)}
    
            graphics_path.AddCurve(br)  'Add the Bottom right curve to the path
    
            'Bottom left corner
            Dim bl() As Point = { _
            New Point(X + 10, (Y + Height) + 10), _
            New Point(X + 6, (Y + Height) + 8), _
            New Point(X + 2, (Y + Height) + 4), _
            New Point(X, Y + Height)}
    
            graphics_path.AddCurve(bl)  'Add the Bottom left curve to the path
    
            'Top left corner
            Dim tl() As Point = { _
            New Point(X, Y + 10), _
            New Point(X + 2, Y + 6), _
            New Point(X + 6, Y + 2), _
            New Point(X + 10, Y)}
    
            graphics_path.AddCurve(tl)  'add the Top left curve to the path
    
            Return graphics_path
    
        End Function

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] How to Shape a winform to our desired shape?

    This line
    Code:
    me.region = RoundedRec(10,10,200,100)
    Should be this
    Code:
    m.region = New System.Drawing.Region(RoundedRec(10, 10, 200, 100))

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [2005] How to Shape a winform to our desired shape?

    my mistake. stanavs right

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    144

    Re: [2005] How to Shape a winform to our desired shape?

    Hai paul,
    Thank u very much for ur help..I have tried ur code..I have got the shaped form with curve edges...But the only thing is I couldnt get the smooth curve..b'coz some projections are coming in the curve on all four sides...is there any way to reduce that projections and to make the curve to be smooth in ur code???

  6. #6
    Hyperactive Member cptHotkeys's Avatar
    Join Date
    Apr 2007
    Location
    New Zealand
    Posts
    294

    Re: [2005] How to Shape a winform to our desired shape?

    you could try setting the smoothing mode...
    e.graphics.smoothingMode = SmoothingMode.AntiAliased

    Signatures suck

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