zoukankan      html  css  js  c++  java
  • Delphi程序开启XP的ClearType显示效果

    微软雅黑字体在没有开启ClearType效果时显示会一塌糊涂,最近项目中因使用了雅黑字体,所以系统启动时候需要自动开启这个功能.

    网上大部份资料都是针对注册表的,几乎没有什么用.

    相关位置:HKEY_CURRENT_USER\Control Panel\Desktop

    类似如下:

    if NOT reg.ValueExists('FontSmoothing') then reg.WriteString('FontSmoothing','2');

    if NOT reg.ValueExists('FontSmoothingType') then reg.WriteInteger('FontSmoothingType',2);

    下面的方法是通过调用SystemParametersInfo来实现:98和2000没有ClearType的功能

    使用方法:

    Font smoothing is handled by the OS, but can be controlled via the SystemParametersInfo API. Please note that the smoothing type does not apply to Win2K, only XP and above.

    // Example usage

    const

    FE_FONTSMOOTHINGSTANDARD   = $00000001;

    FE_FONTSMOOTHINGCLEARTYPE = $00000002;

    SPI_GETFONTSMOOTHINGTYPE   = $0000200A;

    SPI_SETFONTSMOOTHINGTYPE   = $0000200B;

    procedure TForm1.Button1Click(Sender: TObject);

    var dwType:        DWORD;

         bIsSet:        BOOL;

    begin

    if SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, @bIsSet, 0) then

    begin

         if bIsSet then

         begin

            ShowMessage('Font smoothing is applied');

            if SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, @dwType, 0) then

            begin

               case dwType of

                  FE_FONTSMOOTHINGSTANDARD   : ShowMessage('Smoothing type is standard');

                  FE_FONTSMOOTHINGCLEARTYPE : ShowMessage('Smoothing type is clear type');

               end;

            end;

         end

         else

            ShowMessage('Font smoothing not is applied');

    end;

    // Enable clear type font smoothing

    SystemParametersInfo(SPI_SETFONTSMOOTHING, 1, nil, SPIF_UPDATEINIFILE or SPIF_SENDCHANGE);

    SystemParametersInfo(SPI_SETFONTSMOOTHINGTYPE, 0, Pointer(FE_FONTSMOOTHINGCLEARTYPE), SPIF_UPDATEINIFILE or SPIF_SENDCHANGE);

    // Disable font smoothing

    SystemParametersInfo(SPI_SETFONTSMOOTHING, 0, nil, SPIF_UPDATEINIFILE or SPIF_SENDCHANGE);

    end;

  • 相关阅读:
    在opencv3中实现机器学习之:利用正态贝叶斯分类
    在opencv3中进行图片人脸检测
    在opencv3中利用SVM进行图像目标检测和分类
    在opencv3中实现机器学习之:利用svm(支持向量机)分类
    在matlab和opencv中分别实现稀疏表示
    opencv2学习:计算协方差矩阵
    用python简单处理图片(3):添加水印
    Google protocol buffer在windows下的编译
    GEOS库学习之五:与GDAL/OGR结合使用
    GEOS库学习之四:几何关系判断
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/3123745.html
Copyright © 2011-2022 走看看