So I wanted that if the Checkbox is checked, that the Edit boxes are visible and writeable.. but my problem is that the Checkbox will be enabled but the edit boxes won´t after I saved and restart...
Hope someone can help me..
Code: Select all
Gui, EmailServices: Default
IniRead,WebCheckBox,Settings.ini, Email, WebCheckBox ; Reads what the Checkbox is (1 or 0)
Gui, Add, CheckBox, x10 y9 w70 h30 vWebCheckBox checked%WebCheckBox% gWebCheckBox, Webmail ; The Checkbox which should enable or disable the edits...
Gui, Add, Edit, x82 y13 w100 h20 disabled vWebEmail, Email
Gui, Add, Edit, x192 y13 w100 h20 disabled vWebPassword, Password
Gui, Add, Button, x300 y13 w35 h20 gWebsave, Save ; save the Edits..
Gui, Show, NA x5 y5 w750 h345
return
;Label to activate or deactivate the Edits...
WebCheckBox:
guicontrolget, WebCheckBox
if WebCheckBox = 1
{
IniWrite, %WebCheckBox%, Settings.ini, Settings, WebCheckBox
IniRead, tempWebEmail, Settings.ini, Email, tempWebEmail
IniRead, tempWebPassword, Settings.ini, Email, tempWebPassword
WebEmail := b64Decode(tempWebEmail)
WebPassword := b64Decode(tempWebPassword)
guicontrol, Enable, WebEmail
guicontrol, , WebEmail
guicontrol, , WebEmail, %WebEmail%
guicontrol, Enable, WebPassword
guicontrol, +Password, WebPassword
guicontrol, , WebPassword, %WebPassword%
}
else
{
IniWrite, %WebCheckBox%, Settings.ini, Settings, WebCheckBox
guicontrol, -Password, WebEmail
guicontrol, Disable, WebEmail
guicontrol, , WebEmail, Email
guicontrol, -Password, WebPassword
guicontrol, Disable, WebPassword
guicontrol, , WebPassword, Password
}
return
; Saves the Edits...
Websave:
Gui, Submit,NoHide
tempWebEmail := b64Encode(WebEmail)
tempWebPassword := b64Encode(WebPassword)
IniWrite, %tempWebEmail%, Settings.ini, Email, tempWebEmail
IniWrite, %tempWebPassword%, Settings.ini, Email, tempWebPassword
IniRead, tempWebEmail, Settings.ini, Email, tempWebEmail
IniRead, tempWebPassword, Settings.ini, Email, tempWebPassword
Return
;Encrypt the Edit data...
b64Encode(string)
{
VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1
if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
throw Exception("CryptBinaryToString failed", -1)
VarSetCapacity(buf, size << 1, 0)
if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
throw Exception("CryptBinaryToString failed", -1)
return StrGet(&buf)
}
;Decrypt the Edit data...
b64Decode(string)
{
if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
throw Exception("CryptStringToBinary failed", -1)
VarSetCapacity(buf, size, 0)
if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
throw Exception("CryptStringToBinary failed", -1)
return StrGet(&buf, size, "UTF-8")
}