Share via


How to make perfect rounded corner shape in Windows Form using C#

Question

Monday, March 2, 2020 8:07 AM

I want to design perfect rounded corner shape in Windows Form using C#.

i tried the shape using below code. But, i am not getting the clear resolution in the form.

   [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        private static extern IntPtr CreateRoundRectRgn
        (
            int nLeftRect,     // x-coordinate of upper-left corner
            int nTopRect,      // y-coordinate of upper-left corner
            int nRightRect,    // x-coordinate of lower-right corner
            int nBottomRect,   // y-coordinate of lower-right corner
            int nWidthEllipse, // width of ellipse
            int nHeightEllipse // height of ellipse
        );

  public frmMain()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.None;
            Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 25, 30));

        }

pls. find attached screenshot for reference.

pls. give more suggestion to make perfect rounded corner using win form c#

All replies (27)

Monday, March 2, 2020 10:11 AM ✅Answered

Thanks for your reply..

Can we have any other examples...?

For example =>

(I added Right-Click to close the Form) =>

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        base.FormBorderStyle = FormBorderStyle.None;
        BackColor = System.Drawing.Color.Yellow;

        using (Graphics gr = Graphics.FromHwnd(Handle))
        {               
            gr.SmoothingMode = SmoothingMode.AntiAlias;
            using (System.Drawing.Drawing2D.GraphicsPath gp = CreatePath(new Rectangle(System.Drawing.Point.Empty, base.Size), 45))
            {                  
                gr.FillPath(SystemBrushes.Window, gp);
                Region region = new Region(gp);
                base.Region = region;
            }
        }

    }
    public static System.Drawing.Drawing2D.GraphicsPath CreatePath(Rectangle rect, int nRadius)
    {
        System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
        path.AddArc(rect.X, rect.Y, nRadius, nRadius, 180f, 90f);
        path.AddArc((rect.Right - nRadius), rect.Y, nRadius, nRadius, 270f, 90f);
        path.AddArc((rect.Right - nRadius), (rect.Bottom - nRadius), nRadius, nRadius, 0f, 90f);
        path.AddArc(rect.X, (rect.Bottom - nRadius), nRadius, nRadius, 90f, 90f);
        path.CloseFigure();
        return path;
    }

    public const int WM_NCHITTEST = 0x0084;
    public const int WM_NCRBUTTONDOWN = 0x00A4;
    public const int WM_NCRBUTTONUP = 0x00A5;
    public const int WM_RBUTTONDOWN = 0x0204;
    public const int WM_RBUTTONUP = 0x0205;

    public const int HTCAPTION = 2;

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == WM_NCHITTEST)
        {
            m.Result = new IntPtr(HTCAPTION);
            return;
        }
        if (m.Msg == WM_NCRBUTTONDOWN)
        {
            m.Result = (IntPtr)0;
            System.Threading.Thread.Sleep(200);
            this.Close();
            return;
        }
        else
            base.WndProc(ref m);
    }
}

Tuesday, March 3, 2020 9:03 AM ✅Answered

You can draw the border in Paint event :

(test with red color, pen size = 1)

protected override void OnPaint(PaintEventArgs e)
{
    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
    using (System.Drawing.Drawing2D.GraphicsPath gp = CreatePath(new Rectangle(System.Drawing.Point.Empty, base.Size), 45, true))
    {
        Pen redPen = new Pen(Color.Red, 1);
        e.Graphics.DrawPath(redPen, gp);
    }
    base.OnPaint(e);
}

Update the path function like this (new bOutline parameter) :

public static System.Drawing.Drawing2D.GraphicsPath CreatePath(Rectangle rect, int nRadius, bool bOutline)
{
    int nShift = bOutline ? 1 : 0;
    System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
    path.AddArc(rect.X + nShift, rect.Y, nRadius, nRadius, 180f, 90f);
    path.AddArc((rect.Right - nRadius) - nShift, rect.Y, nRadius, nRadius, 270f, 90f);
    path.AddArc((rect.Right - nRadius) - nShift, (rect.Bottom - nRadius) - nShift, nRadius, nRadius, 0f, 90f);
    path.AddArc(rect.X + nShift, (rect.Bottom - nRadius) - nShift, nRadius, nRadius, 90f, 90f);
    path.CloseFigure();
    return path;
}

and the first call at beginning with false for bOutline :

using (System.Drawing.Drawing2D.GraphicsPath gp = CreatePath(new Rectangle(System.Drawing.Point.Empty, base.Size), 45, false))

Monday, March 2, 2020 8:26 AM

I think the rounded corner themselves looks good. Just that your title bar (the cyan color part) and the width of black borders don't match the center of rounded corner, hence make it look weird.

Also note that GDI is very old API, and you should use either GDI+ (Use Region constructor that accepts GraphicsPath) or WPF to render such effect.


Monday, March 2, 2020 9:42 AM

Thanks for your reply..

Can we have any other examples...?


Monday, March 2, 2020 9:58 AM

What kind of example you need?

Check the first link and you can find the code to create GraphicsPath object to feed to new System.Drawing.Region(), and the second link is on how to create rounded corner window on WPF projects directly.

If you need different height and width to the rounded corner you can modify the RoundedRect static method accordingly by supplying different parameters to the arc Rectangle.


Monday, March 2, 2020 10:06 AM

Yes. i already created projects.

I tried first link. but, i didn't get any impact in my form...


Monday, March 2, 2020 10:47 AM

hello friend follow the link may help you

http://dotnetvisio.blogspot.com/2014/02/round-corner-form-in-winforms-c.html


Monday, March 2, 2020 12:30 PM

Thanks. it's working..


Tuesday, March 3, 2020 6:26 AM

How to set outline border for the rounded corner...?


Tuesday, March 3, 2020 8:25 AM

Any update @Castorix31...

Reg : How to set outline border for the rounded corner...?


Tuesday, March 3, 2020 11:24 AM

Excellent and charming...


Tuesday, May 5, 2020 5:01 PM

Can we set top left and right radius curve shape better finishing...?

Now, the top of the corner shape, something like zig zag...pls. zoom the curve edge..not proper radius curve shape...

Note : Is it possible to set minimize and maximize button in top of the form (in the top ..ight corner)


Wednesday, May 6, 2020 2:23 AM

Any Update pls..


Monday, May 11, 2020 4:26 PM

Any update Castorix...


Monday, May 11, 2020 8:12 PM

Like for Buttons, one of the methods for a perfect rounded window is with Window Class

and * AllowsTransparency = 'True'*

Result =>


Tuesday, May 12, 2020 7:35 AM

Excellent. This is i want.

PS : Is it possible to set minimize and maximize button in top of the form (in the top right corner). Because some end user  would like minimize and maximize button or image with rich mini and maximize button design.


Tuesday, May 12, 2020 1:52 PM

I made a test sample based on MS XAML samples, with buttons and a Context Menu =>

You can change the main code in the XAML string sXAML

References :

// https://github.com/microsoft/WPF-Samples/tree/master/Windows/NonRectangularWindow
// https://github.com/cubika/OneCode/tree/master/Visual%20Studio%202010/CSWPFIrregularShapeWindow
// Add reference to PresentationFramework
// Add reference to PresentationCore
// Add reference to WindowsBase

// Add reference to System.Xaml
    
public partial class Form1 : Form
{
    public Form1()
    {
        this.Load += new System.EventHandler(this.Form1_Load);
    }

    private System.Windows.Window dynamicWindow = null;
    private System.Windows.Controls.Button buttonMaximize = null;

    private void Form1_Load(object sender, EventArgs e)
    {
        Visible = false;
        ShowInTaskbar = false;

        string sXAML = @"<Window
            xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
          xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     
            Title='Title' 
            Height='300'
            Width = '300'
            WindowStyle = 'None'
            AllowsTransparency = 'True'>
            <Window.Background>
                <SolidColorBrush />
            </Window.Background>
            <Grid x:Name='MainGrid'>     
                <Border BorderBrush='Red' BorderThickness='4' CornerRadius='25' Name = 'MainBorder'>
                    <Border.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header='Minimize' Name='MenuItemMinimize'/>
                            <MenuItem Header='Maximize/Restore' Name='MenuItemMaximize'/>
                            <MenuItem Header='Close' Name='MenuItemClose'/>
                        </ContextMenu>
                    </Border.ContextMenu>
                    <Border.Background>
                        <LinearGradientBrush StartPoint='0,0' EndPoint='1,1'>
                            <GradientStop Color='Yellow' Offset='0.0' />
                            <GradientStop Color='Red' Offset='0.25' />
                            <GradientStop Color='Blue' Offset='0.75' />
                            <GradientStop Color='LimeGreen' Offset='1.0' />
                        </LinearGradientBrush>
                    </Border.Background>
                </Border>

                <Button x:Name='ButtonClose' HorizontalAlignment='Right' VerticalAlignment='Top' Width='10' Height='0' Margin='20'
                    ToolTip = 'Close the form' >>
                    <Button.Template>
                        <ControlTemplate>
                            <Canvas>
                                <Rectangle Width='15' Height='15' Stroke='Black' RadiusX='3' RadiusY='3'>
                                    <Rectangle.Fill>
                                        <SolidColorBrush x:Name='redBrush' Color='Red' />
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Line X1='3' Y1='3' X2='12' Y2='12' Stroke='White' StrokeThickness='2' />
                                <Line X1='12' Y1='3' X2='3' Y2='12' Stroke='White' StrokeThickness='2' />
                            </Canvas>
                        </ControlTemplate>
                    </Button.Template>
                </Button>

                <Button x:Name='ButtonMaximize' HorizontalAlignment='Right' VerticalAlignment='Top' Width='30' Height='0' Margin='20'
                    ToolTip = 'Maximize/Restore the form' >>
                    <Button.Template>
                         <ControlTemplate>
                            <Canvas>
                                <Rectangle Width='15' Height='15' Stroke='DarkBlue' RadiusX='2' RadiusY='2'>
                                    <Rectangle.Fill>
                                        <SolidColorBrush x:Name='blueBrush' Color='Blue' />
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Width='12' Height='12' Stroke='White' RadiusX='2' RadiusY='2'  StrokeThickness='2' Canvas.Left='2' Canvas.Top='2'>
                                </Rectangle>                                   
                            </Canvas>
                        </ControlTemplate>
                    </Button.Template>
                </Button>

                <Button x:Name='ButtonMinimize' HorizontalAlignment='Right' VerticalAlignment='Top' Width='50' Height='0' Margin='20'
                    ToolTip = 'Minimize the form' >
                    <Button.Template>
                        <ControlTemplate>
                            <Canvas>
                                <Rectangle Width='15' Height='15' Stroke='DarkBlue' RadiusX='2' RadiusY='2'>
                                    <Rectangle.Fill>
                                        <SolidColorBrush x:Name='blueBrush' Color='Blue' />
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Line X1='3' Y1='10' X2='12' Y2='10' Stroke='White' StrokeThickness='2'></Line>
                            </Canvas>
                        </ControlTemplate>
                    </Button.Template>
                </Button>  
            </Grid>
            </Window>";

        dynamicWindow = (System.Windows.Window)System.Windows.Markup.XamlReader.Parse(sXAML);

        System.Windows.Controls.Button buttonMinimize = System.Windows.LogicalTreeHelper.FindLogicalNode(dynamicWindow, "ButtonMinimize") as System.Windows.Controls.Button;
        buttonMinimize.Click += new System.Windows.RoutedEventHandler(Button_Minimize);

        buttonMaximize = System.Windows.LogicalTreeHelper.FindLogicalNode(dynamicWindow, "ButtonMaximize") as System.Windows.Controls.Button;
        buttonMaximize.Click += new System.Windows.RoutedEventHandler(Button_Maximize);

        System.Windows.Controls.Button buttonClose = System.Windows.LogicalTreeHelper.FindLogicalNode(dynamicWindow, "ButtonClose") as System.Windows.Controls.Button;
        buttonClose.Click += new System.Windows.RoutedEventHandler(Button_Close);

        System.Windows.Controls.Border mainBorder = System.Windows.LogicalTreeHelper.FindLogicalNode(dynamicWindow, "MainBorder") as System.Windows.Controls.Border;

        System.Windows.Controls.MenuItem menuitemMinimize = System.Windows.LogicalTreeHelper.FindLogicalNode(mainBorder.ContextMenu, "MenuItemMinimize") as System.Windows.Controls.MenuItem;
        menuitemMinimize.Click += new System.Windows.RoutedEventHandler(Button_Minimize);

        System.Windows.Controls.MenuItem menuitemMaximize = System.Windows.LogicalTreeHelper.FindLogicalNode(mainBorder.ContextMenu, "MenuItemMaximize") as System.Windows.Controls.MenuItem;
        menuitemMaximize.Click += new System.Windows.RoutedEventHandler(Button_Maximize);

        System.Windows.Controls.MenuItem menuitemClose = System.Windows.LogicalTreeHelper.FindLogicalNode(mainBorder.ContextMenu, "MenuItemClose") as System.Windows.Controls.MenuItem;
        menuitemClose.Click += new System.Windows.RoutedEventHandler(Button_Close);

        dynamicWindow.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(Window_MouseLeftButtonDown);
        dynamicWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
        dynamicWindow.Show();
    }

    private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        dynamicWindow.DragMove();
    }

    private void Button_Minimize(object sender, System.Windows.RoutedEventArgs e)
    {
        dynamicWindow.WindowState = System.Windows.WindowState.Minimized;
    }

    private void Button_Maximize(object sender, System.Windows.RoutedEventArgs e)
    {
        if (dynamicWindow.WindowState != System.Windows.WindowState.Maximized)
        {
            string sControlTemplate = @"<ControlTemplate 
            xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
          xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' 
            TargetType ='Button'>
            <Canvas>
                    <Rectangle Width='15' Height='15' Stroke='DarkBlue' RadiusX='2' RadiusY='2'>
                        <Rectangle.Fill>
                            <SolidColorBrush x:Name='blueBrush' Color='Blue' />
                        </Rectangle.Fill>
                    </Rectangle>
                    <Line X1='5' Y1='4' X2='12' Y2='4' Stroke='White' StrokeThickness='2'></Line>
                    <Line X1='5' Y1='10' X2='12' Y2='10' Stroke='White' StrokeThickness='2'></Line>
                    <Line X1='5' Y1='5' X2='5' Y2='10' Stroke='White' StrokeThickness='2'></Line>
                    <Line X1='12' Y1='5' X2='12' Y2='10' Stroke='White' StrokeThickness='2'></Line>

                    <Line X1='3' Y1='8' X2='10' Y2='8' Stroke='White' StrokeThickness='2'></Line>
                    <Line X1='3' Y1='14' X2='10' Y2='14' Stroke='White' StrokeThickness='2'></Line>
                    <Line X1='3' Y1='8' X2='3' Y2='14' Stroke='White' StrokeThickness='2'></Line>
                    <Line X1='10' Y1='8' X2='10' Y2='14' Stroke='White' StrokeThickness='2'></Line>
            </Canvas>
            </ControlTemplate>";
            buttonMaximize.Template = (System.Windows.Controls.ControlTemplate)System.Windows.Markup.XamlReader.Parse(sControlTemplate);
            dynamicWindow.WindowState = System.Windows.WindowState.Maximized;
            dynamicWindow.BorderThickness = new System.Windows.Thickness(System.Windows.SystemParameters.WindowResizeBorderThickness.Left +
                System.Windows.SystemParameters.FixedFrameVerticalBorderWidth,
                System.Windows.SystemParameters.WindowResizeBorderThickness.Top + System.Windows.SystemParameters.FixedFrameHorizontalBorderHeight,
                System.Windows.SystemParameters.WindowResizeBorderThickness.Right + System.Windows.SystemParameters.FixedFrameVerticalBorderWidth,
                System.Windows.SystemParameters.WindowResizeBorderThickness.Bottom + System.Windows.SystemParameters.FixedFrameHorizontalBorderHeight);
        }
        else
        {
            string sControlTemplate = @"<ControlTemplate 
            xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
          xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' 
            TargetType ='Button'>
                <Canvas>
                    <Rectangle Width='15' Height='15' Stroke='DarkBlue' RadiusX='2' RadiusY='2'>
                        <Rectangle.Fill>
                            <SolidColorBrush x:Name='blueBrush' Color='Blue' />
                        </Rectangle.Fill>
                     </Rectangle>
                     <Rectangle Width='12' Height='12' Stroke='White' RadiusX='2' RadiusY='2'  StrokeThickness='2' Canvas.Left='2' Canvas.Top='2'>
                     </Rectangle>                                   
                </Canvas>
            </ControlTemplate>";
            buttonMaximize.Template = (System.Windows.Controls.ControlTemplate)System.Windows.Markup.XamlReader.Parse(sControlTemplate);
            dynamicWindow.WindowState = System.Windows.WindowState.Normal;
        }
    }
    private void Button_Close(object sender, System.Windows.RoutedEventArgs e)
    {
        if (dynamicWindow != null)
            dynamicWindow.Close();
        System.Threading.Thread.Sleep(200);
        Application.Exit();
    }
}

Wednesday, May 13, 2020 4:20 PM

Thanks for your reply.

code working perfect.

where is the place to set normal background color in the form and height and width. 

pls. highlight.

Also, how to add controls in that form. like drag and drop from the tool box. will it work..?


Wednesday, May 13, 2020 7:12 PM

The controls can be added in XAML code or dynamically, but WPF controls

Otherwise, a simpler way :

Like for the Button, remove the Region and draw and fill the path in OnPaint

Add a background and transparent color that you don't use, like :

BackColor = System.Drawing.Color.Magenta;
TransparencyKey = System.Drawing.Color.Magenta;

Then you will be able to add standard .NET controls


Thursday, May 14, 2020 1:44 AM

Can you provide the complete code with modified above...?


Thursday, May 14, 2020 4:29 AM

I added FillPath in OnPaint

But in fact rounded borders are not perfect like with WPF controls shown above. I tried to change parameters like CompositingQuality, but same result

You can add standard buttons for Minimize, etc..
I only added a button with "X" for Close to test it :

protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);
    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
    int nBorderSize = 4;
    int nRadius = 45;
    using (System.Drawing.Drawing2D.GraphicsPath gp = CreatePath(new Rectangle(nBorderSize, nBorderSize, Size.Width - nBorderSize * 2, Size.Height- nBorderSize * 2), nRadius, true))
    {
        System.Drawing.Pen pen = new System.Drawing.Pen(Color.Red, nBorderSize);
        pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
        e.Graphics.FillPath(new SolidBrush(Color.Yellow), gp);
        e.Graphics.DrawPath(pen, gp);
    }
}

Thursday, May 14, 2020 4:16 PM

Thanks Castorix.

How to remove background white color in the above form.

my complete code is below.

    public partial class frmRadiusDesign : Form
    {
        public frmRadiusDesign()
        {
            InitializeComponent();

            base.FormBorderStyle = FormBorderStyle.None;
            BackColor = System.Drawing.Color.White;
            base.AllowTransparency = true;
            //this.BackColor = Color.FromArgb(24, 80, 95); // this should be pink-ish

            using (Graphics gr = Graphics.FromHwnd(Handle))
            {
                gr.SmoothingMode = SmoothingMode.AntiAlias;
                using (System.Drawing.Drawing2D.GraphicsPath gp = CreatePath(new Rectangle(System.Drawing.Point.Empty, base.Size), 45, false))
                {
                    gr.FillPath(SystemBrushes.Window, gp);
                    Region region = new Region(gp);
                    base.Region = region;
                }
            }
        }


      
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            int nBorderSize = 4;
            int nRadius = 45;
            using (System.Drawing.Drawing2D.GraphicsPath gp = CreatePath(new Rectangle(nBorderSize, nBorderSize, Size.Width - nBorderSize * 2, Size.Height - nBorderSize * 2), nRadius, true))
            {
                System.Drawing.Pen pen = new System.Drawing.Pen(Color.Red, nBorderSize);
                pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                e.Graphics.FillPath(new SolidBrush(Color.Yellow), gp);
                e.Graphics.DrawPath(pen, gp);
            }
        }

        public static System.Drawing.Drawing2D.GraphicsPath CreatePath(Rectangle rect, int nRadius, bool bOutline)
        {
            int nShift = bOutline ? 1 : 0;
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddArc(rect.X + nShift, rect.Y, nRadius, nRadius, 180f, 90f);
            path.AddArc((rect.Right - nRadius) - nShift, rect.Y, nRadius, nRadius, 270f, 90f);
            path.AddArc((rect.Right - nRadius) - nShift, (rect.Bottom - nRadius) - nShift, nRadius, nRadius, 0f, 90f);
            path.AddArc(rect.X + nShift, (rect.Bottom - nRadius) - nShift, nRadius, nRadius, 90f, 90f);
            path.CloseFigure();
            return path;
        }

        public const int WM_NCHITTEST = 0x0084;
        public const int WM_NCRBUTTONDOWN = 0x00A4;
        public const int WM_NCRBUTTONUP = 0x00A5;
        public const int WM_RBUTTONDOWN = 0x0204;
        public const int WM_RBUTTONUP = 0x0205;

        public const int HTCAPTION = 2;

        protected override void WndProc(ref Message m)
        { 
            if (m.Msg == WM_NCHITTEST)
            {
                m.Result = new IntPtr(HTCAPTION);
                return;
            }
            if (m.Msg == WM_NCRBUTTONDOWN)
            {
                m.Result = (IntPtr)0;
                System.Threading.Thread.Sleep(200);
                this.Close();
                return;
            }
            else
                base.WndProc(ref m);
        }
    }

Thursday, May 14, 2020 4:59 PM

You must add TransparencyKey

TransparencyKey = System.Drawing.Color.White;

Friday, May 15, 2020 2:06 AM

Thanks for all your help...It's really amazing...your tag shows "Unemployed"...any reason..because i don't believe...


Friday, May 15, 2020 5:50 AM

Thanks for all your help...It's really amazing...your tag shows "Unemployed"...any reason..because i don't believe...

Unlucky and probably too old now...


Monday, November 9, 2020 10:49 AM

Hi Castorix,

I am facing one more issue. bottom curve enge not coming properly in my laptop resolution.

when i am using the form at my laptop, the alignment not showing proper in bottom.  But, the same will be working and perfect @ my desktop.

where i want to change the resoluton and it should be the perfect for both laptop and desktop.

below is the screenshot.

   //draw outline border for rectangle corner in the form
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            using (System.Drawing.Drawing2D.GraphicsPath gp = CreatePath(new System.Drawing.Rectangle(System.Drawing.Point.Empty, base.Size), 45, true))
            {
                Pen redPen = new Pen(Color.FromArgb(233, 131, 0), 5);
                e.Graphics.DrawPath(redPen, gp);
            }
            base.OnPaint(e);
        }

        //draw rectangle corner in the form
        public static System.Drawing.Drawing2D.GraphicsPath CreatePath(System.Drawing.Rectangle rect, int nRadius, bool bOutline)
        {
            int nShift = bOutline ? 1 : 0;
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddArc(rect.X + nShift, rect.Y, nRadius, nRadius, 180f, 90f);
            path.AddArc((rect.Right - nRadius) - nShift, rect.Y, nRadius, nRadius, 270f, 90f);
            path.AddArc((rect.Right - nRadius) - nShift, (rect.Bottom - nRadius) - nShift, nRadius, nRadius, 0f, 90f);
            path.AddArc(rect.X + nShift, (rect.Bottom - nRadius) - nShift, nRadius, nRadius, 90f, 90f);
            path.CloseFigure();
            return path;
        }


        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_NCHITTEST)
            {
                m.Result = new IntPtr(HTCAPTION);
                return;
            }
            if (m.Msg == WM_NCRBUTTONDOWN)
            {
                m.Result = (IntPtr)0;
                System.Threading.Thread.Sleep(200);
                this.Close();
                return;
            }
            else
                base.WndProc(ref m);
        }

Tuesday, November 10, 2020 2:18 AM

any update..

we are facing issue in laptop resolution..