Sign in to follow this  
Followers 0
Roofel

Checkbox clicked checks?

3 posts in this topic

#1 ·  Posted (edited)

Hello:) I have a new problem:)

I got a little project going and need a bit help.

When you check a Checkbox with the task to save the settings to a .ini file when exitting the script and if it isnt checked just close without saving?

I got a fragment of the script here so you can see what i mean:)

#include <GuiConstants.au3>

$GUI=GUICreate("Test greier^^,",200,200)
$Load=GUICtrlCreateButton("Load settings", 95,5,100,30)
$Delete=GUICtrlCreateButton("Delete settings", 95, 67,100,30)
$exit=GUICtrlCreateButton("Exit", 95, 98, 100,30)
$List=GUICtrlCreateInput("", 5, 5, 89, 170)
$Check=GUICtrlCreateCheckbox("Save settings on exit?", 5, 180)
$Iniread=IniRead(@ScriptDir & "\Settings.ini", "Main", "Data", "")

GUISetState()

While 1
    $msg=GUIGetMsg()
    Select
    Case $msg=$Load
        GUICtrlSetData($List,$Iniread)
    Case $msg=$Delete
        FileDelete(@ScriptDir & "\Settings.ini")
    Case $msg=$GUI_EVENT_CLOSE Or $msg=$exit
        Exit
    Case $msg=$Check
        IniWrite(@ScriptDir & "\Settings.ini", "Main","Data", GUICtrlRead($List))
        Exit
    EndSelect
WEnd

I get it to save the settings but when i check the box, it closes at once:S When can i get it to save only when i click Exit?:)

Hope you understand

Edited by Roofel

Never argue with an idiot, he will just bring you down to his own level and beat you with experience! :D

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>

Global $saveonexit = False

$GUI=GUICreate("Test greier^^,",200,200)
$Load=GUICtrlCreateButton("Load settings", 95,5,100,30)
$Delete=GUICtrlCreateButton("Delete settings", 95, 67,100,30)
$exit=GUICtrlCreateButton("Exit", 95, 98, 100,30)
$List=GUICtrlCreateInput("", 5, 5, 89, 170)
$Check=GUICtrlCreateCheckbox("Save settings on exit?", 5, 180)
$Iniread=IniRead(@ScriptDir & "\Settings.ini", "Main", "Data", "")

GUISetState()

While 1
    $msg=GUIGetMsg()
    Select
    Case $msg=$Load
        GUICtrlSetData($List,$Iniread)
    Case $msg=$Delete
        FileDelete(@ScriptDir & "\Settings.ini")
    Case $msg=$GUI_EVENT_CLOSE Or $msg=$exit
        If $saveonexit Then IniWrite(@ScriptDir & "\Settings.ini", "Main","Data", GUICtrlRead($List))
        Exit
    Case $msg=$Check
        $saveonexit = BitAnd(GUICtrlRead($Check),$GUI_CHECKED) = $GUI_CHECKED
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

Thanks alot:)


Never argue with an idiot, he will just bring you down to his own level and beat you with experience! :D

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  
Followers 0