|
-
Oct 3rd, 2007, 01:35 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Enable ClearType from registry
Hi guys,
Here is the Story:
I have an app, that has 2 forms, Form #1, uses Verdana, and Form #2 uses consolas font, and this is a cleartype font, so it pretty much sucks if ClearType is not on. Now, form#1, has a button that calls Form#2, and another to set or unset Cleartype.
Now, i know that the RegKeys for cleartype are/and can be set this way:
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothing", "2", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothingType", "2", Microsoft.Win32.RegistryValueKind.DWord)
And this way i can change the registry to turn on ClearType, or so it should.
Here is the issue:
I open form#1, and when i click the button that changes the registry values, and i check them with regedit, i see the change on the registry, but when i click the other button to open form#2 the font its still blurry, i other words, it didnt work. Well it does work only if i restart or log off.
BUT...
If i open form#1, and go the desktop properties/apperance/effects and set cleartype on and hit apply, i also see the same registrykeys changed, and when i open form#2, the form is crisp clear and everything look like a wonder, withour restart or logoff... SO... aparently this apply button on the desktop properties dialog its doing something else than just changing some registry keys. How can i simulate that, to make it work? Any ideas.
Thanks guys.
-
Oct 4th, 2007, 05:03 AM
#2
Re: Enable ClearType from registry
I'm not sure whether this would be overkill or not but you could try calling the CahngeDisplaySettings API. If you include CDS_RESET in the flags without changing the settings then I think the Desktop should be "refreshed" and hopefully pick up your new font smoothing setting. There may be a better way to refresh the Desktop but I don't know of one. Nor do I know of an API function that will set the font smoothing property, as neither ChangeDisplaySettings nor ChangeDisplaySettingsEx seem to do so.
-
Oct 4th, 2007, 08:52 AM
#3
Thread Starter
Addicted Member
Re: Enable ClearType from registry
i have seen another guys post on another forum that sais he has been able to change this kind of stuff, but he wont give the code... very nice of him, and he only changed regkeys, (not so sure about that) so i guess ill find myself a registry tracker, and make the change to se what going on there.
But thanks for the reply jmcilhinney, ill keep that in mind if i run out of luck with the registry.
-
Oct 4th, 2007, 11:32 AM
#4
Thread Starter
Addicted Member
Re: Enable ClearType from registry
ok i have found how to do it, here is the code
Code:
Private Declare Auto Function SystemParametersInfo Lib "user32.dll" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As Integer, ByVal fuWinIni As Integer) As Integer
Turn it on
Code:
SystemParametersInfo(SPI_SETFONTSMOOTHING, SmoothingOn, &H0, &H1 Or &H2)
SystemParametersInfo(SPI_SETFONTSMOOTHINGTYPE, &H0, ClearType, &H1 Or &H2)
Turn it Off
Code:
SystemParametersInfo(SPI_SETFONTSMOOTHING, SmoothingOff, &H0, &H1 Or &H2)
SystemParametersInfo(SPI_SETFONTSMOOTHINGTYPE, &H0, NoType, &H1 Or &H2)
Here are some of the constants i used
Code:
Const SPI_GETFONTSMOOTHING As Integer = &H4A
Const SPI_SETFONTSMOOTHING As Integer = &H4B
Const SPI_GETFONTSMOOTHINGTYPE As Integer = &H200A
Const SPI_SETFONTSMOOTHINGTYPE As Integer = &H200B
Const ClearType As Integer = &H2
Const StandardType As Integer = &H1
Const NoType As Integer = &H0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|