Hi

DWM method does not work, you can remove the default title bar and create a custom header.

 using System;

using System.Drawing;

using System.Windows.Forms;


public class CustomForm : Form

{

    private Panel headerPanel;

    private Label titleLabel;


    public CustomForm()

    {

        // Remove default title bar

        this.FormBorderStyle = FormBorderStyle.None;

        this.Size = new Size(500, 300);


        // Create custom header panel

        headerPanel = new Panel

        {

            Height = 40,

            Dock = DockStyle.Top,

            BackColor = Color.DarkBlue  // Title bar background color

        };

        this.Controls.Add(headerPanel);


        // Create title text label

        titleLabel = new Label

        {

            Text = "Custom Title",

            ForeColor = Color.White,    // Title bar text color

            Font = new Font("Segoe UI", 12, FontStyle.Bold),

            AutoSize = true,

            Location = new Point(10, 10)

        };

        headerPanel.Controls.Add(titleLabel);


        // Enable dragging

        headerPanel.MouseDown += HeaderPanel_MouseDown;

    }


    private void HeaderPanel_MouseDown(object sender, MouseEventArgs e)

    {

        if (e.Button == MouseButtons.Left)

        {

            this.Capture = false;

            Message m = Message.Create(this.Handle, 0xA1, (IntPtr)2, IntPtr.Zero);

            this.WndProc(ref m);

        }

    }


    [STAThread]

    public static void Main()

    {

        Application.EnableVisualStyles();

        Application.Run(new CustomForm());

    }

}


Previous
Next Post »