如何用C#更改win apps中的标题栏字体?
发布时间:2020-12-15 17:24:19 所属栏目:百科 来源:网络整理
导读:我如何通过C#在 Windows应用程序中更改窗体的标题栏字体? 我发现这段代码但没有工作,也没有绘制标题栏: 我怎样才能做到这一点? 谢谢大家 protected override void WndProc(ref Message msg){ base.WndProc(ref msg); const int WM_NCPAINT = 0x85; if (ms
我如何通过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才能使代码生效.
看看我提供给以下问题的答案 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- 关于Ajax无法下载文件到浏览器本地的问题
- ruby-on-rails – Resque和New relic
- postgresql – psql在启动时挂起
- u-boot-2011.03在mini2440/micro2440上的移植(五
- Cocos Creator 创建和销毁节点(官方文档摘录)
- ruby-on-rails – Access-Control-Allow-Origin
- oracle数据库%notfound的理解
- 如何在Ruby中的特定索引处从String中删除字符
- ruby-on-rails – Rails 2.3.5 I18n月/日名称翻译
- PostgreSQL 数据库HAProxy和PgBouncer配置高可用
热点阅读