为我的应用程序单独更改字体平滑,而不是全局Windows字体平滑设置 [英] Changing font smoothing for my application alone and not the global windows font smoothing settings

查看:946
本文介绍了为我的应用程序单独更改字体平滑,而不是全局Windows字体平滑设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C ++编写的Windows应用程序,并使用Win32-API。我想以编程方式更改我的应用程序的字体平滑,从而允许我的应用程序的用户在无,标准和cleartype之间进行选择。

I have a Windows application written in C++, and using Win32-API. I want to change the font smoothing of my application programmatically, thus allowing the user of my application to choose between "none", "standard", and "cleartype".

我使用SystemParametersInfo(SPI_SETFONTSMOOTHING,...)更改平滑类型,但这将更改Windows的全局系统设置,并影响所有其他应用程序。有没有办法改变我的应用程序单独的平滑?

I use SystemParametersInfo(SPI_SETFONTSMOOTHING, ... ) to change the smoothing type, however this changes the global system settings of Windows, and effects all other applications. Is there any way to change the smoothing for my application alone?

编辑:澄清 - 我在窗口中嵌入另一个窗口,因此我无法控制

Clarification - I'm embedding another window within my window, and thus I have no control over the fonts within the embedded window.

谢谢

推荐答案

一个更简单的方法,但一种方法是更改​​所有的字体,你绘制的,和所有的控件使用,反锯齿关闭的那些。

Maybe there's an easier way but one way is to change all the fonts which you paint with, and which all your controls use, to ones with anti-aliasing turned off.

请使用 WM_GETFONT WM_SETFONT 来获取/设置大多数控件使用的字体(他们都使用HFONT对象句柄)。

You can use WM_GETFONT and WM_SETFONT to get/set the fonts used by most controls (they both use HFONT object handles).

您可以使用 GetObject 以获取 LOGFONT 结构,然后调整LOGFONT上的抗锯齿标志,然后通过 CreateFontIndirect 。 (不要忘记在某个地方销毁字体,在没有控件使用它之后。)

You can use GetObject to get a LOGFONT structure for an HFONT, then adjust the anti-aliasing flags on the LOGFONT, then create a new HFONT via CreateFontIndirect. (Don't forget to destroy the font somewhere, after no control is using it anymore.)

这也值得记住,一些字体可能强制 anti-aliasing或cleartype打开。因此,在编辑LOGFONT结构时,您可能需要更改字体名称以及标志。

It's also worth keeping in mind that some fonts may force anti-aliasing or cleartype to be on. So you may need to change the font name as well as the flags when editing the LOGFONT structure.

这篇关于为我的应用程序单独更改字体平滑,而不是全局Windows字体平滑设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆