使用 SystemParametersInfo SPI_GETICONTITLELOGFONT
我当前正在使用函数 SystemParametersInfo 来检索 SPI_GETICONTITLELOGFONT。根据 MSDN 文档,这是 http://msdn.microsoft.com/en-us /library/ms724947(VS.85).aspx
“检索当前图标标题字体的逻辑字体信息”
但是,即使我将字体更改为“VivlaidD”,它也始终会检索“Segoe UI”。我使用的是 Windows 7 机器。难道这个函数只是获取系统默认值吗?或者“SystemParametersInfo”有问题吗?
这是我检索字体的代码:
procedure GetUserFontPreference(out FaceName: string; out PixelHeight: Integer);
var
lf: LOGFONT;
begin
ZeroMemory(@lf, SizeOf(lf));
if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeOf(lf), @lf, 0) then
begin
FaceName := PChar(Addr(lf.lfFaceName[0]));
PixelHeight := lf.lfHeight;
end
else
begin
{
If we can't get it, then assume the same non-user preferences that
everyone else does.
}
FaceName := 'MS Shell Dlg 2';
PixelHeight := 8;
end;
end;
I am currently using the function SystemParametersInfo to retrieve SPI_GETICONTITLELOGFONT. According to the MSDN documentation this is the
http://msdn.microsoft.com/en-us/library/ms724947(VS.85).aspx
"Retrieves the logical font information for the current icon-title font"
But this always retrieves 'Segoe UI' even when I change my font to 'VivlaidD'. I am on a Windows 7 machine. Is it that this function only retrieves the system default? Or is there something wrong with 'SystemParametersInfo'?
Here is my code for retrieving the font:
procedure GetUserFontPreference(out FaceName: string; out PixelHeight: Integer);
var
lf: LOGFONT;
begin
ZeroMemory(@lf, SizeOf(lf));
if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeOf(lf), @lf, 0) then
begin
FaceName := PChar(Addr(lf.lfFaceName[0]));
PixelHeight := lf.lfHeight;
end
else
begin
{
If we can't get it, then assume the same non-user preferences that
everyone else does.
}
FaceName := 'MS Shell Dlg 2';
PixelHeight := 8;
end;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能是您在个性化菜单中更改了错误的字体?如果我将图标字体从 Segoe UI 更改为 Verdana,以下代码可以正常工作:
May be you change the wrong font in Personalization menu? If I change the Icon font from Segoe UI to Verdana, the following code works properly:
问题不在于您的代码,正如您在以下 D2010 控制台应用程序中看到的那样,更改和检索字体,并且在 Win7 x64 上运行良好:
The problem is not with your code as you can see with the following D2010 console app, changing and retrieving the font, and working well on Win7 x64: