Sign in to follow this  
Followers 0
AlienStar

checkbox function .... please

5 posts in this topic

#1 ·  Posted (edited)

hello everybody

I use this script to make GUI readme for just once

and this is :

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $gobutton, $state, $msg, $Chekbox
    Local $pic
    #forceref $separator1

    GUICreate("Readme", 600, 400)

    $gobutton = GUICtrlCreateButton("GO", 265, 350, 100, 25)
    $pic = GuiCtrlCreatePic("pic.jpg",0,0, 600,300)
    $Chekbox = GuiCtrlCreateCheckbox("Don't show this message again", 25, 370, 200, 20)
    $state = GuiCtrlSetState(-1, $GUI_UNCHECKED)
    GUISetState()
    While 1
        $msg = GUIGetMsg()

        Select
            Case $msg = $GUI_EVENT_CLOSE 
                MsgBox(0, "Click", "good bye")
                ExitLoop
                                
            Case $msg = $gobutton
                MsgBox(0, "Click", "You clicked OK!")
                ExitLoop
                
        EndSelect
    WEnd

    GUIDelete()
    Exit
EndFunc

I suggest when the box is checked write text file somewhere and next time check that file then won't show this again

and I used in Func _Main() for checkbox :

when it's checked ---- > write a text file

when it's unchecked ---- > delete that file

like this

Func _Main()
    While 1

        Select
            Case $state =  GuiCtrlSetState(1, $GUI_CHECKED) 
                FileWrite ("File.txt","Text")
                
            Case $state =  GuiCtrlSetState(-1, $GUI_UNCHECKED)
                FileDelete("File.txt")
                
        EndSelect
    WEnd
    Exit
EndFunc

but it didn't work

please help me

Edited by AlienStar

Share this post


Link to post
Share on other sites



AlienStar,

Using -1 in commands like $state = GuiCtrlSetState(-1, $GUI_UNCHECKED) is shorthand for "the control just created". So when you come to your loop and use Case $state = GuiCtrlSetState(1, $GUI_CHECKED) AutoIt has probably forgotten what that was!

You also need to look at the current state of the checkbox - not compare it with what it was. Try using this:

Case GUICtrlRead($Chekbox) = 1 ; This is checked

Case GUICtrlRead($ChekBox) = 4 ; This is unchecked

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

@Melba23

it works fine

thanks so so much

you are amazing

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@Melba23

I have another question please

as you see in script above

$pic = GuiCtrlCreatePic("pic.jpg",0,0, 600,300)

I wanna put a button or checkbox where the pic is placed but they set behind it

now how can arrange it to back (bring them to front) ??

and thanks

Edited by AlienStar

Share this post


Link to post
Share on other sites

thanks Thanubis but I found that's not enough

because nothing happen after putting this

$pic = GuiCtrlCreatePic("pic.jpg",0,0, 600,400)
GuiCtrlSetState(-1,$GUI_DISABLE)

so I looked for that in help and found

GuiCtrlSetState(-1,$GUI_ONTOP)

after using this

$pic = GuiCtrlCreatePic("pic.jpg",0,0, 600,400)
GuiCtrlSetState(-1,$GUI_DISABLE)
GuiCtrlSetState(-1,$GUI_ONTOP)

everything becomes well

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