Enable ClearType Programmatically on Windows Mobile
For our Windows Mobile app, I want to enable the ClearType setting on the device. According to this article on MSDN, you need to make the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\GDI\Cleartype
But nothing happens after setting that particular key. Even a soft reset doesn't enable it, but just gets rid of the newly created registry key.
The weird thing is that when I set it manually using Settings-> System-> Screen-> ClearType, it works immediately. And a comparison of the registry export before and after changing the parameter shows that the key just mentioned above has changed.
I don't quite understand why it doesn't work when I change the registry key myself. Anyone who knows what I am doing wrong here?
[update] Looks like the solution is to do the following:
-
Pass the WM_SETTINGCHANGE message with the correct parameters, for example:
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 1)
But it hasn't worked yet. I am guessing that a different value may be required for the wParam parameter.
-
Or call CreateEvent with the appropriate event for ClearType changes. Will work a little like BacklightChangeEvent or SDKBacklightChangeEvent. But until now I have not seen any documentation on these events, so I cannot determine what the event will be.
source to share
I found a solution myself. It turns out that you don't need to change the registry, but just call SystemParametersInfo with the SPI_SETFONTSMOOTHING parameter to force it to apply the changes.
This is my code using .NET CF 2.0:
[DllImport("coredll.dll", SetLastError = true)]
static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref int pvParam, uint fWinIni);
const uint SPI_SETFONTSMOOTHING = 0x004b;
const uint SPI_UPDATEINI = 0x1;
int pv = 0;
bool ret = SystemParametersInfo(SPI_SETFONTSMOOTHING, 1, ref pv, SPIF_UPDATEINIFILE);
source to share