2012-03-05 25 views
3

我如何通過C#在Windows應用程序中更改窗體的標題欄字體?如何通過C#更改win應用程序中的標題欄字體?

我發現此代碼,但不工作,並沒有繪製標題欄: 我該怎麼做? 感謝所有

protected override void WndProc(ref Message msg) 
{ 
    base.WndProc(ref msg); 
    const int WM_NCPAINT = 0x85; 

    if (msg.Msg == WM_NCPAINT) 
    { 
     this.Text = "";// remove the original title text 

     IntPtr hdc = GetWindowDC(msg.HWnd); 
     Graphics g = Graphics.FromHdc(hdc); 
     Font ft = new Font("Arial", 16); 

     g.DrawString("Hello World title", ft, Brushes.Red, new PointF(20.0f, 0.0f)); 

     ReleaseDC(msg.HWnd, hdc); 
    } 
} 

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

[DllImport("User32.dll")] 
private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); 

回答

0

我不知道這是否是可能的,因爲你只能編輯文本而不是標記。

我認爲它只是使用了Windows使用的字體大小...

+0

提供的答案,我覺得應該有一個方式與Windows API來做到這一點。 – RobinJ 2012-03-05 12:36:19

+0

庫爾布,如果是這樣,我沒有線索...... 這正是我在想什麼。 – 2012-03-05 12:49:56

相關問題