2009. január 9., péntek

How to turn off Windows' font anti-aliasing


Problem/Question/Abstract:

How can I temporally turn off the Windows font anti-aliasing and turn it on after drawing?

Answer:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    SmoothFonts: Boolean;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  SystemParametersInfo(SPI_GETFONTSMOOTHING, 1, @SmoothFonts, 0);
  if SmoothFonts then
    SystemParametersInfo(SPI_SETFONTSMOOTHING, 0, nil, SPIF_UPDATEINIFILE);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  if SmoothFonts then
    SystemParametersInfo(SPI_SETFONTSMOOTHING, 1, nil, SPIF_UPDATEINIFILE);
end;

end.

Under Win95 it has only an effect if the Plus! Pack is installed (NT4 by default).

Nincsenek megjegyzések:

Megjegyzés küldése