客户区绘图:

 

 
  
  1. public partial class MyForm : Form 
  2.  
  3.     public MyForm() 
  4.     { 
  5.         InitializeComponent(); 
  6.         BackColor = Color.Red; 
  7.         Text = "Hello World"
  8.     } 
  9.  
  10.     protected override void OnPaint(PaintEventArgs e) 
  11.     { 
  12.         //base.OnPaint(e); 
  13.         e.Graphics.DrawString("Hello,WinForm程序.", Font, Brushes.White, 0, 0); 
  14.     } 

重载winproc,屏蔽WM_NCPAINT等:

 

 
  
  1. protected override void WndProc(ref Message m) 
  2.     if (m.Msg == 0x83 || m.Msg == 0x85 || m.Msg==0x86) 
  3.         return
  4.     base.WndProc(ref m); 

 

 

窗体最大化,最小化,关闭:

 

 
  
  1. private void btnMin_Click(object sender, EventArgs e) 
  2.     WindowState = FormWindowState.Minimized; 
  3.  
  4. private void btnMaxNormal_Click(object sender, EventArgs e) 
  5.     if (WindowState == FormWindowState.Normal) 
  6.     { 
  7.         WindowState = FormWindowState.Maximized; 
  8.         button2.Text = "还原"
  9.     } 
  10.     else 
  11.     { 
  12.         WindowState = FormWindowState.Normal; 
  13.         button2.Text = "最大化"
  14.     } 
  15.  
  16. private void btnClose_Click(object sender, EventArgs e) 
  17.     Application.Exit();