C# Win Form Design - Form design bottom edge not coming properly in Laptop resolution

Gani_tpt 1,586 Reputation points
2020-11-10T15:10:04.59+00:00

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

the same alignment will be working in desktop properly. but, when i am checking the form at my laptop then the bottom edge is not coming properly.

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 resolution and it should be the perfect for both laptop and desktop.

below is the screenshot.

38828-form-design.png

below is the source code.

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);  
    }  

the same alignment will be working in desktop properly. but, when i am checking the form at my laptop then the bottom edge is not coming properly.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,840 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,621 Reputation points
    2020-11-11T05:54:21.767+00:00

    Hi GaneshS,
    There are more discussion in these threads you can refer to.
    How to fit Windows Form to any screen resolution?
    Windows Form size issue on different resolutions
    You can also try to set the form property to open in maximized state as ppiotrowicz said.

    this.WindowState = FormWindowState.Maximized;  
    

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in ourdocumentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments