Sign in to follow this  
Followers 0
McGod

Checkbox Mayhem

4 posts in this topic

Ok, so I'm coding a GUI config that uses SQLite. I've been working on the save part of it. Now when it comes to checkboxs its pissing me off. There is no way to tell what control is what. I need to convert 1($GUI_CHECKED) and 4($GUI_UNCHECKED) to

Yes and No. Now i tried using GUICtrlRead ( $checkbox, 1) which would give me its name then i would name all checkboxes CB but the GUICtrlRead starting screwing up and not giving name so i cant use it anymore. My Question is: Is there any sure proof method to figure out what control is what?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm a little bit unsure but I think this does what you want :

#include <GUIConstants.au3>

GUICreate("", 100, 40)
$checkbox = GUICtrlCreateCheckbox ("No", 10, 10, 180, 20)
GUISetState()

While 1
    $iMsg = GUIGetMsg()
    If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop
   
    If $iMsg = $checkbox Then
        If BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) Then
            GUICtrlSetData($checkbox, "Yes")
        Else
            GUICtrlSetData($checkbox, "No")
        EndIf
    EndIf   
Wend

Edited by Helge

Share this post


Link to post
Share on other sites

I'm a little bit unsure but I think this does what you want :

#include <GUIConstants.au3>

GUICreate("", 100, 40)
$checkbox = GUICtrlCreateCheckbox ("No", 10, 10, 180, 20)
GUISetState()

While 1
    $iMsg = GUIGetMsg()
    If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop
   
    If $iMsg = $checkbox Then
        If BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) Then
            GUICtrlSetData($checkbox, "Yes")
        Else
            GUICtrlSetData($checkbox, "No")
        EndIf
    EndIf   
Wend
Kinda.

I arrayd all my inputs and checkboxes. So i dont know which ones are inputs and which ones are checkboxes

My save func looks like

Do
$data[$i] = GUICtrlRead ( $S_GUI[$i] )
$name = GUICtrlRead ( $S_GUI[$i], 1)
If $name = "CB" Then
Select
    Case $data[$i] = $GUI_CHECKED
    $data[$i] = "Yes"
Case $data[$i] = $GUI_UNCHECKED
    $data[$i] = "No"
EndSelect
EndIf
$final = $final & "'" & $data[$i] & "', "
$i = $i + 1
Until $i = UBound ( $S_GUI )

It will Get the data of control 0 then check if its a checkbox though the checkbox check part doesnt work.

the $data will get saved with the code that wasnt posted.

Share this post


Link to post
Share on other sites

The important part in my code is the use of BitAND, which you haven't used in yours.

I'm extremely tired as it's very late here now, but you could try this code below which

should work.. I think. Good night...eer, morning.

Do
$data[$i] = GUICtrlRead ( $S_GUI[$i] )
$name = GUICtrlRead ( $S_GUI[$i], 1)
If $name = "CB" Then
Select
    Case BitAND($data[$i], $GUI_CHECKED)
    $data[$i] = "Yes"
Case BitAND($data[$i], $GUI_UNCHECKED)
    $data[$i] = "No"
EndSelect
EndIf
$final = $final & "'" & $data[$i] & "', "
$i = $i + 1
Until $i = UBound ( $S_GUI )

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