Jump to content
Sign in to follow this  
Lunatic

Calling a result from GUICtrlCreateCheckbox

Recommended Posts

Lunatic

I've been awake far too long trying to figure this one out - likely at this point it's staring me in the face and I don't know it. I've checked through the help file in SciTe, done some searching here on the forums, and am still not getting it fixed.

I've had no trouble creating the GUI I want through Koda, but I can't seem to call a result from it. Specifically I'm working with

$Checkbox1 = GUICtrlCreateCheckbox("Text", 0, 0, 0, 0)

As I stated, CREATING the GUI is no problem. I can get it opened up without issue, but after the fact I can't seem to pull a result from the check boxes. (I haven't at this time attempted the other interactive formats; Radio, Button's, Etc.)

After reading the Help file in SciTe, I've tried variations of $GUI_CHECKED and $GUI_UNCHECKED without success.

So, yea. Dumb question of the day. Thanks.


[center][/center]

Share this post


Link to post
Share on other sites
Melba23

Lunatic,

Try:

If BitAnd(GUICtrlRead($hCheckBox_Handle),$GUI_CHECKED) = $GUI_CHECKED

It works for me.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Lunatic

Nevermind, I'm special. Found my own answer - Thanks for any attempted assistance anyway. (And thanks to Pain for answering other dude's question, and thus my own.) Answer is Here if anyone has the same issue. -CORRECTION- this answer only works if you're using an .ini file. (Apparently I forget to read everything when I'm tired.)

Woops - thanks Melba23 - I'll look into that too. Always good to have multiple outlooks. :)

Edited by Lunatic

[center][/center]

Share this post


Link to post
Share on other sites
Melba23

Lunatic,

Re the PM you sent me. You need to have the If...Then statement inside the While...Wend loop or it is never activated. So you need something along the lines of:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=D:\Frank's Documents\Auto-It Scripts Archive\Scripts in Devlopment\Form1.kxf
$Form1 = GUICreate("Test GUI", 327, 351, 193, 125)
$Label1 = GUICtrlCreateLabel("Checkbox Test GUI", 24, 16, 279, 17)
$Checkbox1 = GUICtrlCreateCheckbox("My Checkbox", 25, 40, 97, 15)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    
    If BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED) = $GUI_CHECKED THEN;
        MsgBox(4096, "Test", "CHECKED", 10)
    ElseIf BitAnd(GUICtrlRead($Checkbox1),$GUI_UNCHECKED) = $GUI_UNCHECKED THEN;
        MsgBox(4096, "Test", "UNCHECKED", 10)
    EndIf
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE

        Exit
    EndSwitch
WEnd

But you will notice that the MsgBox is triggered each time you loop - which is pretty often. So I would suggest adding a flag to prevent this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=D:\Frank's Documents\Auto-It Scripts Archive\Scripts in Devlopment\Form1.kxf
$Form1 = GUICreate("Test GUI", 327, 351, 193, 125)
$Label1 = GUICtrlCreateLabel("Checkbox Test GUI", 24, 16, 279, 17)
$Checkbox1 = GUICtrlCreateCheckbox("My Checkbox", 25, 40, 97, 15)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$Checked_State = False

While 1
    
    If BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED) <> $Checked_State Then
        
        $Checked_State = Not $Checked_State
    
        If BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED) = $GUI_CHECKED THEN;
            MsgBox(4096, "Test", "CHECKED", 10)
        ElseIf BitAnd(GUICtrlRead($Checkbox1),$GUI_UNCHECKED) = $GUI_UNCHECKED THEN;
            MsgBox(4096, "Test", "UNCHECKED", 10)
        EndIf
        
    EndIf
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE

        Exit
    EndSwitch
WEnd

M23

P.S. Please do not use PMs to ask questions - that is why we have a forum. Then any interested member or guest can see the problems and solutions. :-)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Lunatic

Ah, makes sense now. Thanks for the assistance again.

And understood - Sent via PM only because it was your assistance specifically I was trying to clarify, and I wasn't sure if you'd see the response to the thread. Won't happen again.


[center][/center]

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  

×