Click here to Skip to main content
15,849,829 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai Friends..
I Need Some Code  to change the color of the title bar of a form in c# winforms ?
Actually I Tried by Using USER32.dll..its not Changing The Color Of The Title Bar...Its Just Covering The Title Bar With The Give Color

My Code Snippet Is This:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace TitleBarColorChange
    public partial class Form1 : Form
        static extern int ReleaseDC(IntPtr hWnd, IntPtr hDc);

        private static extern IntPtr GetWindowDC(IntPtr hWnd);

        public Form1()
        protected override void WndProc(ref Message m)
            base.WndProc(ref m);
            const int WM_NCPAINT = 0x85;
            if (m.Msg == WM_NCPAINT)
                IntPtr hdc = GetWindowDC(m.HWnd);
                if ((int)hdc != 0)
                    Graphics g = Graphics.FromHdc(hdc);
                    g.FillRectangle(Brushes.Green, new Rectangle(0, 0, 4800, 30));
                    ReleaseDC(m.HWnd, hdc);

        private void Form1_Load(object sender, EventArgs e)
            this.BackColor = System.Drawing.Color.MistyRose;
            this.StartPosition = FormStartPosition.CenterScreen;

Can any one Pls Help Me....

Thanking You In Advance
Updated 19-Nov-12 21:30pm

1 solution

you can see this
Share this answer
sariqkhan 20-Nov-12 4:49am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900