Click here to Skip to main content
15,881,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I'm very struggling how to customize win form in C#.Net.

I want to customize win form in c#.Net, like change title bar color and add buttons customize max,mini,close button.

Thanks in Advance.


What I have tried:

I have tried like this but i didn't get Output.

[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

[DllImport("User32.dll")]
private static extern IntPtr GetWindowDC(IntPtr hWnd);

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, 23));
g.Flush();
ReleaseDC(m.HWnd, hdc);
}
}
}
Posted
Updated 13-Apr-16 0:11am

1 solution

C#
 public partial class Form1 : Form  
    {  
        public Form1()  
        {  
            InitializeComponent();  
        }  
  
        [DllImport("user32.dll")] 
        static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); 
 
        [DllImport("User32.dll")] 
 
        private static extern IntPtr GetWindowDC(IntPtr hWnd); 
 
        protected override void WndProc(ref System.Windows.Forms.Message m) 
        { 
            const int WM_NCPAINT = 0x85; 
            base.WndProc(ref m); 
 
            if (m.Msg == WM_NCPAINT) 
            { 
 
                IntPtr hdc = GetWindowDC(m.HWnd); 
                if ((int)hdc != 0) 
                { 
                    Graphics g = Graphics.FromHdc(hdc); 
                    g.DrawLine(Pens.Green, 10, 10, 100, 10); 
                    g.Flush(); 
                    ReleaseDC(m.HWnd, hdc); 
                } 
 
            } 
             
        }  
    }  
}  
 
Share this answer
 
v3
Comments
chellapandi160 13-Apr-16 6:20am    
Is it possible to graphics drawing method?
chellapandi160 13-Apr-16 6:24am    
using Override concept.
[no name] 13-Apr-16 6:37am    
http://skincrafter.com/samples/csharp-skins
chellapandi160 13-Apr-16 6:50am    
I want to change title bar color.
[no name] 13-Apr-16 6:57am    
Now check it. If you are using windows vista it won't work.

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