Jump to content
Sign in to follow this  
Fossil Rock

EnvUpdate() not working for me....

Recommended Posts

Fossil Rock

Am I implementing it wrong or missing something ?

#include <GUIConstants.au3>

$Form1 = GUICreate("Font Smoothing Example", 410, 218, -1, -1)
$Label1 = GUICtrlCreateLabel("Example", 8, 8, 398, 114)
GUICtrlSetFont(-1, 72, 800, 2, "Arial")
$Font_Smoothing = GUICtrlCreateCheckbox("Font Smoothing  ", 8, 144, 97, 17)
$Standard = GUICtrlCreateRadio("Standard  ", 32, 168, 113, 17)
$ClearType = GUICtrlCreateRadio("ClearType  ", 32, 192, 113, 17)
GUISetBkColor(16777215)
$fsa = ""
$fst = ""
    
_RegRead()

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Font_Smoothing
            If GUICtrlRead($Font_Smoothing) = $GUI_CHECKED Then
                RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothing", "REG_DWORD", 2)
                RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothingType", "REG_DWORD", 1)
                GUICtrlSetState($Standard, $GUI_ENABLE)
                GUICtrlSetState($ClearType, $GUI_ENABLE)
                EnvUpdate()
                _RegRead()
            EndIf
            If GUICtrlRead($Font_Smoothing) = $GUI_UNCHECKED Then
                RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothing", "REG_DWORD", 0)
                RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothingType", "REG_DWORD", 0)
                GUICtrlSetState($Standard, $GUI_DISABLE)
                GUICtrlSetState($ClearType, $GUI_DISABLE)
                EnvUpdate()
                _RegRead()
            EndIf
        Case $Standard
                RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothingType", "REG_DWORD", 1)
                EnvUpdate()
                _RegRead()
        Case $ClearType
                RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothingType", "REG_DWORD", 2)
                EnvUpdate()
                _RegRead()
    EndSwitch
WEnd

Func _RegRead()
    $fsa = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothing")
    $fst = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothingType")
    If $fsa = 2 Then GUICtrlSetState($Font_Smoothing, $GUI_CHECKED)
    If $fst = 1 Then GUICtrlSetState($Standard, $GUI_CHECKED)
    If $fst = 2 Then GUICtrlSetState($ClearType, $GUI_CHECKED)
EndFunc

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
GaryFrost

If I read it correctly I believe its for the environment variables as the help explains.

If you change the %path% you would update it by executing EnvUpdate() so you wouldn't have to log off and back on.

For reg keys seems like I seen something might work somewhere on the forum, but for the life of me I can't remember what was at this time.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Fossil Rock

I noticed that when I turn the font smoothing on and off with the Display Properties it stores different data than the script. I don't know if they are considered to be the same or not.

http://www.autoitscript.com/fileman/users/Fossil%20Rock/RegDiff.jpg

The top pair are from turning the font smoothing on to off from the Display Properties.

The bottom pair are from turning the font smoothing on to off from the script.

The help file states the TYPE is optional, but when I leave it blank [ RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "FontSmoothing", "", 0) ] I get ERROR: RegWrite() called with illegal argument 3: ""

Do you know of any method to force an update like the 'Apply' button in the Display Properties ?


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.