如何用C#更改win apps中的标题栏字体?

如何用C#更改win apps中的标题栏字体?,第1张

概述我如何通过C#在 Windows应用程序中更改窗体的标题栏字体? 我发现这段代码但没有工作,也没有绘制标题栏: 我怎样才能做到这一点? 谢谢大家 protected override void WndProc(ref Message msg){ base.WndProc(ref msg); const int WM_NCPAINT = 0x85; if (msg.Msg 我如何通过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);
解决方法 在Vista和windows 7上,您需要禁用Aero才能使代码生效.

看看我提供给以下问题的答案
How to add an extra button to the window’s title bar?

总结

以上是内存溢出为你收集整理的如何用C#更改win apps中的标题栏字体?全部内容,希望文章能够帮你解决如何用C#更改win apps中的标题栏字体?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1234467.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存