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;