dbalman
asked on
How to launch the Display, Appearance, Effects window from VB programmatically
I need to check if a XP user has Smooth Edges of Screen Fonts/ClearType selected and if not, give them the option to change it. I check this by looking at the following DWORD value:
HKCU\Control Panel\Desktop - "FontSmoothingType"
Where 0=No Font Smoothing, 1=Standard and 2=ClearType
I can change this via the registry, but it doesn't apply until after reboot. If you use the display applet, it takes effect immediately.
The display properties window with the appearance tab selected can be launched with the following command:
RUNDLL32.EXE SHELL32.DLL,Control_RunDLL desk.cpl,,2
How can I programmatically open the Effects window that opens when you click on it's button?
How can I change this setting via the registry, and apply it without a reboot like the applet does?
HKCU\Control Panel\Desktop - "FontSmoothingType"
Where 0=No Font Smoothing, 1=Standard and 2=ClearType
I can change this via the registry, but it doesn't apply until after reboot. If you use the display applet, it takes effect immediately.
The display properties window with the appearance tab selected can be launched with the following command:
RUNDLL32.EXE SHELL32.DLL,Control_RunDLL
How can I programmatically open the Effects window that opens when you click on it's button?
How can I change this setting via the registry, and apply it without a reboot like the applet does?
Here's an example foundation of such a hack solution - copy the code below to an empty text file, save it as "whatever.wsf" and run it.
<package>
<job id="vbs">
<script language="VBScript">
set WshShell = WScript.CreateObject("WScr ipt.Shell" )
WshShell.Run "RUNDLL32.EXE SHELL32.DLL,Control_RunDLL desk.cpl,,2"
WScript.Sleep 500
WshShell.SendKeys "^{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "~"
</script>
</job>
</package>
<package>
<job id="vbs">
<script language="VBScript">
set WshShell = WScript.CreateObject("WScr
WshShell.Run "RUNDLL32.EXE SHELL32.DLL,Control_RunDLL
WScript.Sleep 500
WshShell.SendKeys "^{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "~"
</script>
</job>
</package>
You need to SendMessage,HWND_BROADCAST ,WM_FONTCH ANGE. I believe this will update without the re-boot.
Regards, P1 8-)
Regards, P1 8-)
ASKER
Thanks for the suggestions. While the "Hacks" would work, it's not what I'm lookin for. P1 has come the closest with the API call however, I was unable to make this work on XP durning testing using a registry import:
[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="2"
"FontSmoothingOrientation" =dword:000 00001
"FontSmoothingType"=dword: 00000002
to first change the settings via the registry. Then in VB:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HWND_BROADCAST = &HFFFF&
Private Const WM_FONTCHANGE = &H1D
Private Sub Command1_Click()
SendMessage HWND_BROADCAST, WM_FONTCHANGE, 0, 0
End Sub
This would be one of two possible solutions I would find acceptable (and the best) if I could get it to work.
[HKEY_CURRENT_USER\Control
"FontSmoothing"="2"
"FontSmoothingOrientation"
"FontSmoothingType"=dword:
to first change the settings via the registry. Then in VB:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HWND_BROADCAST = &HFFFF&
Private Const WM_FONTCHANGE = &H1D
Private Sub Command1_Click()
SendMessage HWND_BROADCAST, WM_FONTCHANGE, 0, 0
End Sub
This would be one of two possible solutions I would find acceptable (and the best) if I could get it to work.
You need to use SystemParametersInfo API and the following apply to what you are trying to accomplish.
Look under Desktop parameter Section at the following link
http://msdn.microsoft.com/library/en-us/sysinfo/base/systemparametersinfo.asp
SPI_GETFONTSMOOTHING
SPI_GETFONTSMOOTHINGCONTRA ST
SPI_GETFONTSMOOTHINGTYPE
SPI_SETFONTSMOOTHING
SPI_SETFONTSMOOTHINGCONTRA ST
SPI_SETFONTSMOOTHINGTYPE
Look under Desktop parameter Section at the following link
http://msdn.microsoft.com/library/en-us/sysinfo/base/systemparametersinfo.asp
SPI_GETFONTSMOOTHING
SPI_GETFONTSMOOTHINGCONTRA
SPI_GETFONTSMOOTHINGTYPE
SPI_SETFONTSMOOTHING
SPI_SETFONTSMOOTHINGCONTRA
SPI_SETFONTSMOOTHINGTYPE
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
EXCELLANT!!! - but I get a ByRef argument mismatch when I use the ClearType argument - Standard works great.
I was unable to figure out what was wrong - any ideas?
I was unable to figure out what was wrong - any ideas?
Hmmm... I don't seem to get the error. Maybe you should try to create dummy project to make sure. If you added my code above to your existing project than it could be something else conflicting.
New project
Add command button to form1
Copy paste the above code from previous post into Form1
New project
Add command button to form1
Copy paste the above code from previous post into Form1
ASKER
You are right of course, I'll figure this out later. Thank you very much for you help.
RUNDLL32.EXE SHELL32.DLL,Control_RunDLL
And then use "SendKeys" to manipulate the UI.
Like I said, this is a hack solution, someone may come up with something more elegant.