views:

412

answers:

2

For our Windows Mobile application I want to enable the ClearType option on the device. According to this article on MSDN it should be done be setting the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\GDI\Cleartype

But nothing happens after setting this particular key. Even a soft reset does not enable it, but simply gets rid of the registry key I just created.

Strange thing is that when I set it manually using Settings->System->Screen->ClearType it works immediately. And comparing the registry exports before and after changing the setting show that it is just the key mentioned above that changes.

I don't quite understand why it wouldn't work when I change the registry key myself. Anyone who knows what I'm doing wrong here?

[update] It looks like the solution is to do either:

  • Broadcast a WM_SETTINGCHANGE message with the correct parameters like:

    SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 1)

    But that has not worked so far. I guess the wParam parameter might need a different value.

  • Or call CreateEvent with the relevant event for ClearType changes. A bit like BacklightChangeEvent or SDKBacklightChangeEvent would work. But so far I haven't seen any documentation on these events, so I can't work out what the event would be.

A: 

Did you flush the registry after changing the value and before doing the Soft Reset?
Sounds like the change did not persist.

Shaihi
Yes, the registry was flushed after making the change.
tomlog
+1  A: 

I have found the solution myself. It turns out that making the registry change is not needed, but just a call to SystemParametersInfo with the SPI_SETFONTSMOOTHING parameter is enough to make it 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);
tomlog