Jump to content

GUICtrlCreateCheckbox ??


trescon
 Share

Recommended Posts

Good evening, I have a problem with the command GUICtrlCreateCheckbox.
So I have a GUI where I have a number of checkboxes, which I select according to my needs.
Except in an array of all selected values ​​and then write it to a file.
For example, and then I go back into the program and restart it.
The problem comes when I have to go read the file and make sure that all the checkboxes that were selected rivengano still selected.
I have no idea how can I do to re-enable the selection of the check.

Who knows how to help me?

Thanks

Alberto

P.S. : I would also like the same form in which I make the initial selections, may be the same one in which I can make changes to the selections at any time.

uonasera, ho un problema con il comando GUICtrlCreateCheckbox.


Allora io ho una GUI ove ho un certo numero di Checkbox , che io seleziono in base alle mie esigenze.
Salvo in un array tutti i valori selezionati per poi scriverli su un file.
Per esempio poi esco e rientro nel programma e lo riavvio.
Il problema arriva quando io devo andare a leggere il file e far in modo che tutte le checkbox che erano state selezionate rivengano ancora selezionate.
Non ho idea di come posso fare a riattivare la selezione delle check.

Chi mi sa aiutare ??

Grazie

Alberto

P.S. : Vorrei anche che la stessa maschera nella quale faccio le selezioni iniziali, possa essere la stessa nella quale io posso fare le modifiche delle selezioni in qualsiasi momento.

Edited by trescon

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Link to comment
Share on other sites

I had a little time so here is basic example.

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("", 200, 300, 200, 200)
;$hButton = GUICtrlCreateButton("x", 10, 10)

Local $xarray[6] = [5]
Local $y = 10
Local $iniarray = IniReadSection("Test.ini", "Items")

For $i = 1 To $xarray[0]
    $xarray[$i] = GUICtrlCreateCheckbox("", 10, $y, 20, 20)
    If Int($iniarray[$i][1]) Then
        GUICtrlSetState($xarray[$i], $GUI_CHECKED)
    EndIf

    $y += 20
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Moderators

Agreed, something like this perhaps (would be easier if you posted your code):

#include <GUIConstantsEx.au3>

Local $sINI = @DesktopDir & "\My.ini"
Local $hGUI = GUICreate("", 200, 220)

GUISetState(@SW_SHOW, $hGUI)
$chk1 = GUICtrlCreateCheckbox("Test 1", 10, 10, 50, 20)
    If IniRead($sINI, "CheckBoxes", "Check1", "") = 4 Then GUICtrlSetState(-1, $GUI_CHECKED)
$chk2 = GUICtrlCreateCheckbox("Test 2", 10, 35, 50, 20)
    If IniRead($sINI, "CheckBoxes", "Check2", "") = 4 Then GUICtrlSetState(-1, $GUI_CHECKED)
$chk3 = GUICtrlCreateCheckbox("Test 3", 10, 60, 50, 20)
    If IniRead($sINI, "CheckBoxes", "Check3", "") = 4 Then GUICtrlSetState(-1, $GUI_CHECKED)
$chk4 = GUICtrlCreateCheckbox("Test 4", 10, 85, 50, 20)
    If IniRead($sINI, "CheckBoxes", "Check4", "") = 4 Then GUICtrlSetState(-1, $GUI_CHECKED)
$chk5 = GUICtrlCreateCheckbox("Test 5", 10, 110, 50, 20)
    If IniRead($sINI, "CheckBoxes", "Check5", "") = 4 Then GUICtrlSetState(-1, $GUI_CHECKED)
$chk6 = GUICtrlCreateCheckbox("Test 6", 10, 135, 50, 20)
    If IniRead($sINI, "CheckBoxes", "Check6", "") = 4 Then GUICtrlSetState(-1, $GUI_CHECKED)
$btn = GUICtrlCreateButton("Go", 10, 170, 40, 30)

While 1
    Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $btn
                IniWrite($sINI, "CheckBoxes", "Check1", GUICtrlRead($chk1))
                IniWrite($sINI, "CheckBoxes", "Check2", GUICtrlRead($chk2))
                IniWrite($sINI, "CheckBoxes", "Check3", GUICtrlRead($chk3))
                IniWrite($sINI, "CheckBoxes", "Check4", GUICtrlRead($chk4))
                IniWrite($sINI, "CheckBoxes", "Check5", GUICtrlRead($chk5))
                IniWrite($sINI, "CheckBoxes", "Check6", GUICtrlRead($chk6))
    EndSwitch
WEnd

GUIDelete($hGUI)

Edit: Too Late :)



Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Or

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("", 200, 300, 200, 200)
;$hButton = GUICtrlCreateButton("x", 10, 10)

Local $xarray[6] = [5]
Local $y = 10
Local $iniarray = IniReadSection("Test.ini", "Items")

For $i = 1 To $xarray[0]
    $xarray[$i] = GUICtrlCreateCheckbox("", 10, $y, 20, 20)
    If Int($iniarray[$i][1]) Then
        GUICtrlSetState($xarray[$i], $GUI_CHECKED)
    EndIf
    $y += 20
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _Exit()
    EndSwitch
WEnd

Func _Exit()
    For $i = 1 To $xarray[0]

        If Int(GUICtrlRead($xarray[$i])) = 1 Then
            IniWrite("Test.ini", "Items", $i, 1)
        Else
            IniWrite("Test.ini", "Items", $i, 0)
        EndIf
    Next
    Exit
EndFunc   ;==>_Exit

Test.ini

[items]
1=0
2=0
3=1
4=0
5=0

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Thank you all for the examples provided, I also like that they are examples seen from different locations.

Now I have to put myself to study, understand how it works and make my program.

For those of you who told me that I should I post my program, you are right, if I had one.

Or rather I have one embryo with which I am testing the command, but I didn't know how to handle the data when the program starts.

When I finished, if you would, the postero.

For now, thank you all.

Alberto

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...