Hello All,
I am changing color of title bar using following code but when I maximise my or resize form then control box not appear. when I mouse over then again control box will appear so any one know what is the issue in following code?
[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);
SolidBrush b = new SolidBrush(Color.FromArgb(0, 116, 212));
g.FillRectangle(b, new Rectangle(0, 0, 4800, 30));
g.Flush();
ReleaseDC(m.HWnd, hdc);
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.BackColor = Color.FromArgb(214, 236, 246);
this.StartPosition = FormStartPosition.CenterScreen;
}
What I have tried:
I tried above code. and many other code but I face same issue with control box.