#⌨ Programming

1 messages · Page 4 of 1

topaz blaze
graceful viper
#

My bad probably because it's not defined

#
private const int HTCAPTION = 0x2;

// Override the OnMouseDown method to allow dragging the form from anywhere inside it
protected override void OnMouseDown(MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        ReleaseCapture();
        SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
    }

    base.OnMouseDown(e);
}

// Declare the ReleaseCapture and SendMessage functions from user32.dll
[DllImport("user32.dll")]
private static extern bool ReleaseCapture();

[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);```
#

Define it

graceful viper
topaz blaze
#

now it works ty

graceful viper
#

Cool

#

How is it?

topaz blaze
#

still a little bit blocky but 100x better

graceful viper
#

How you want it?

topaz blaze
#

the corners are like this rn

graceful viper
#

Hm

topaz blaze
#

i want it to be smooth

#

like this

graceful viper
#

Oki

#
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public class CustomForm : Form
{
    // Public properties for customizable rounding parameters
    public int RoundingWidth { get; set; } = 20;
    public int RoundingHeight { get; set; } = 20;

    // Constructor
    public CustomForm()
    {
        // Set the form's background color and border style
        BackColor = Color.White;
        FormBorderStyle = FormBorderStyle.None;

        // Set the title bar height and font
        Height += 30;
        Font = new Font("Arial", 12);

        // Create the title bar controls
        var titleLabel = new Label
        {
            Text = "Custom Form",
            ForeColor = Color.White,
            TextAlign = ContentAlignment.MiddleCenter,
            Dock = DockStyle.Fill
        };

        var minimizeButton = new Button
        {
            Text = "_",
            ForeColor = Color.White,
            BackColor = Color.Gray,
            FlatStyle = FlatStyle.Flat,
            Size = new Size(30, 30),
            Dock = DockStyle.Right
        };
        minimizeButton.Click += (s, e) => WindowState = FormWindowState.Minimized;

        var maximizeButton = new Button
        {
            Text = "□",
            ForeColor = Color.White,
            BackColor = Color.Gray,
            FlatStyle = FlatStyle.Flat,
            Size = new Size(30, 30),
            Dock = DockStyle.Right
        };
        maximizeButton.Click += (s, e) => WindowState = WindowState == FormWindowState.Maximized ? FormWindowState.Normal : FormWindowState.Maximized;

        var closeButton = new Button
        {
            Text = "X",
            ForeColor = Color.White,
            BackColor = Color.Red,
            FlatStyle = FlatStyle.Flat,
            Size = new Size(30, 30),
            Dock = DockStyle.Right
        };
        closeButton.Click += (s, e) => Close();

        var titleBar = new Panel
        {
            Dock = DockStyle.Top,
            Height = 30,
            BackColor = Color.DarkSlateGray
        };
        titleBar.Controls.AddRange(new Control[] { titleLabel, minimizeButton, maximizeButton, closeButton });

        Controls.Add(titleBar);
    }

    // Override the OnPaint method to add anti-aliasing
    protected override void OnPaint(PaintEventArgs e)
    {
        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
        base.OnPaint(e);
    }

    // Override the OnResize method to update the region when the form is resized
    protected override void OnResize(EventArgs e)
    {
        base.OnResize(e);
        Invalidate();
    }

    // Override the OnPaintBackground method to make the form transparent and create a rounded border
    protected override void OnPaintBackground(PaintEventArgs e)
    {
        base.OnPaintBackground(e);

        GraphicsPath path = new GraphicsPath();
        path.AddEllipse(0, 0, RoundingWidth, RoundingHeight);
        path.AddEllipse(Width - RoundingWidth, 0, RoundingWidth, RoundingHeight);
        path.AddEllipse(0, Height - RoundingHeight, RoundingWidth, RoundingHeight);
        path.AddEllipse(Width - RoundingWidth, Height - RoundingHeight, RoundingWidth, RoundingHeight);

        Region = new Region(path);

        e.Graphics.Clear(Color.Fuchsia);
        e.Graphics.FillRegion(new SolidBrush(Color.Fuchsia), new Region(ClientRectangle));
    }```
#
    protected override void WndProc(ref Message m)
    {
        const int WM_NCHITTEST = 0x0084;
        const int HTCLIENT = 0x01;
        const int HTCAPTION = 0x02;

        if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT)
        {
            m.Result = (IntPtr)HTCAPTION;
            return;
        }

        base.WndProc(ref m);
    }

    // Override the OnMouseDown method to allow dragging the form from anywhere inside it
    protected override void OnMouseDown(MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            ReleaseCapture();
            SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
        }

        base.OnMouseDown(e);
    }

    // Declare the ReleaseCapture and SendMessage functions from user32.dll
    [DllImport("user32.dll")]
    private static extern bool ReleaseCapture();

    [DllImport("user32.dll")]
    private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

    // Override the CreateParams method to make the form transparent
    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
            return cp;
        }
    }

    // Override the OnMouseMove method to show tooltips for controls
    protected override void OnMouseMove(MouseEventArgs e)
    {
        base.OnMouseMove(e);

        Control control = GetChildAtPoint(e.Location);
        if (control != null)
        {
            string tooltip = "This is a tooltip.";
            ToolTip.SetToolTip(control, tooltip);
        }
    }

    // Override the OnContextMenuOpening method to show a context menu
    protected override void OnContextMenuOpening(ContextMenuOpeningEventArgs e)
    {
        base.OnContextMenuOpening(e);

        if (e.Cancel || e.MouseEventArgs == null)
            return;

        ContextMenu menu = new ContextMenu();
        menu.MenuItems.Add(new MenuItem("Option 1"));
        menu.MenuItems.Add(new MenuItem("Option 2"));

        Point mousePosition = PointToScreen(e.MouseEventArgs.Location);
        menu.Show(this, mousePosition);
        e.Cancel = true;
    }

    // Entry point
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        CustomForm form = new CustomForm();

        // Set the form's size and position
        form.Size = new Size(600, 400);
        form.StartPosition = FormStartPosition.CenterScreen;

        // Set the form's background color and border style
        form.BackColor = Color.White;
        form.FormBorderStyle = FormBorderStyle.None;

        // Set the form's rounding parameters
        form.RoundingWidth = 50;
        form.RoundingHeight = 50;

        // Set the form's opacity
        form.Opacity = 0.75;

        // Show the form
        Application.Run(form);
    }
}```
#

@topaz blaze

topaz blaze
#

yep

graceful viper
#

Try

graceful viper
#

Like how you wanted

topaz blaze
#

not sure it did

#

thats the window

graceful viper
#

What?

topaz blaze
#

its just 3 pink rounded squares and a black rounded square with a white dot

graceful viper
#

The fok

#

Use the earlier code I sent

topaz blaze
#

ok

graceful viper
#

I will fix it how you wanted

#

And send you later

topaz blaze