Use the Delphi Program to enable the ClearType display of XP

Source: Internet
Author: User

When the ClearType effect is not enabled, the font of is displayed in a mess. Recently, the font is used in the project, so this function must be automatically enabled when the system starts.

Most of the information on the Internet is for the Registry and is almost useless.

Location: HKEY_CURRENT_USER \ Control Panel \ Desktop

For example:

If NOT reg. ValueExists ('fontsmoothing ') then reg. WriteString ('fontsmoothing', '2 ');

If NOT reg. ValueExists ('fontsmoothingtype') then reg. WriteInteger ('fontsmoothingtype', 2 );

The following method is implemented by calling SystemParametersInfo: 98 and 2000 do not have ClearType.

Usage:

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

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

FE_FONTSMOOTHINGCLEARTYPE: ShowMessage ('smoothing type is cleartype ');

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.