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
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 { [DllImport("user32.dll")] static extern int ReleaseDC(IntPtr hWnd, IntPtr hDc); [DllImport("User32.dll")] private static extern IntPtr GetWindowDC(IntPtr hWnd); public Form1() { InitializeComponent(); } 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)); g.Flush(); ReleaseDC(m.HWnd, hdc); } } } private void Form1_Load(object sender, EventArgs e) { this.BackColor = System.Drawing.Color.MistyRose; this.StartPosition = FormStartPosition.CenterScreen; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)