Link to home
Start Free TrialLog in
Avatar of Noksok
Noksok

asked on

Disable ClearType on my application

Dear Expert,

How can I disable ClearType anti-aliasing on my application? Can this be archieved using manifest files or normal windows api? The text I don't want anti-aliased is on a label that is located on a usercontrol. The size of the font has to be small and thus the anti-aliasing messes it up.

Thank you for you fast response!
Avatar of Noksok
Noksok

ASKER

Points raised. Urgent.
Avatar of Noksok

ASKER

I solved the problem by setting the global font smoothing property at the start of the program and then resetting it at the end. This is not the optimal solution but works well enough.

Here is the code for it:

-- Declares --
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long

Public Const SPI_GETFONTSMOOTHING = 74
Public Const SPI_SETFONTSMOOTHING = 75
Public Const SPIF_UPDATEINIFILE = &H1
Public Const SPIF_SENDWININICHANGE = &H2

-- In the begining --
    If LenB(GetRegString(HKEY_LOCAL_MACHINE, "SOFTWARE\My program\", "FontSmoothing")) <> 2 Then
     
      SystemParametersInfo SPI_GETFONTSMOOTHING, 0, blFontSmoothing, 0
     
      If blFontSmoothing Then
        SetRegString HKEY_LOCAL_MACHINE, "SOFTWARE\My program\", "FontSmoothing", "T"
       
      Else
        SetRegString HKEY_LOCAL_MACHINE, "SOFTWARE\My program\", "FontSmoothing", "F"
       
      End If
     
    End If
   
    SystemParametersInfo SPI_SETFONTSMOOTHING, False, 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE


-- In the end of the program --
SystemParametersInfo SPI_SETFONTSMOOTHING, (GetRegString(HKEY_LOCAL_MACHINE, "Software\My program\", "FontSmoothing") = "T"), 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE

SetRegString HKEY_LOCAL_MACHINE, "SOFTWARE\My program\", "FontSmoothing", "NONE"
ASKER CERTIFIED SOLUTION
Avatar of RomMod
RomMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial