如何通过C#更改win应用程序中的标题栏字体?

如何通过C#更改win应用程序中的标题栏字体?,c#,winforms,titlebar,C#,Winforms,Titlebar,如何通过C#更改windows应用程序中窗体的标题栏字体 我发现此代码不起作用,并且没有绘制标题栏: 我该怎么做? 谢谢大家 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 o

如何通过C#更改windows应用程序中窗体的标题栏字体

我发现此代码不起作用,并且没有绘制标题栏: 我该怎么做? 谢谢大家

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);

我不知道这是否可行,因为您只能编辑文本,而不能编辑标记


我认为它只是使用了windows使用的字体大小…

在Vista和windows 7上,您需要禁用Aero才能使代码正常工作

看看我对以下问题的回答

我认为应该有一种方法可以通过Windows API实现。如果是这样,我一点都不知道。。。这正是我所想的。