Sign in to follow this  
Followers 0
Fire

Trouble With CheckBox

4 posts in this topic

Hi to all.

I try create simple Gui which contain

1:)Checkbox

2:)Inputbox

3:)Button

But i just wondering that why after the second time after uncheck checkbox and when i try to click on deactivated Inputbox its automatically

enabled?

For example my script below.

Pliz say me where is my mistakes and what i`m doing incorrect or any other ways for fix it...

Thanks.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=Form1.kxf\Рабочий стол\Form1.kxf
$Form1 = GUICreate("Form1", 633, 447, 303, 224)
$Input1 = GUICtrlCreateInput("Input1", 120, 72, 169, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 464, 72, 65, 25)
$Button1 = GUICtrlCreateButton("Button1", 232, 192, 97, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            Case $Checkbox1
            If BitAND(GUICtrlRead($checkbox1), $GUI_CHECKED) Then
                MsgBox(64, "Gui Chcked!", "Gui Checked")
                $Input1 = GUICtrlCreateInput("Input1", 120, 72, 169, 21)
            Else
                $Input1 = GUICtrlCreateInput("Input1", 120, 72, 169, 21)
                GUICtrlSetState(-1, $GUI_DISABLE)
            EndIf
            Case $Button1
          If BitAND(GUICtrlRead($checkbox1), $GUI_CHECKED) Then
                MsgBox(64, "Gui Chcked!", "Gui Checked")
                $Input1 = GUICtrlCreateInput("Input1", 120, 72, 169, 21)
            Else
                MsgBox(64, "Not Checked!", "Not Checked!")
            EndIf




    EndSwitch
WEnd

[size="5"] [/size]

Share this post


Link to post
Share on other sites



Sh3llC043r,

I am unsure what exactly you want to do. ;) This script enables/disables the input depending on the checkbox state:

#include <GUIConstantsEx.au3>  ; <<<<<<<<<<<<<<<<<<<<<<< Note correct include to use

#Region ### START Koda GUI section ### Form=Form1.kxf\??????? ????\Form1.kxf
$Form1 = GUICreate("Form1", 633, 447, 303, 224)
$Input1 = GUICtrlCreateInput("Input1", 120, 72, 169, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 464, 72, 65, 25)
$Button1 = GUICtrlCreateButton("Button1", 232, 192, 97, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then
                MsgBox(64, "Gui Checked!", "Gui Checked")
                GUICtrlSetState($Input1, $GUI_ENABLE)
            Else
                MsgBox(64, "Not Checked!", "Not Checked!")
                GUICtrlSetState($Input1, $GUI_DISABLE)
            EndIf
    EndSwitch
WEnd

If you require a different functionality (did I really just type that? :) ), please explain what you want to happen when the checkbox is clicked without the button being pressed. B)

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

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

$Form1 = GUICreate("Form1", 236, 70, -1, -1)
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 75, 25, $WS_GROUP)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 8, 97, 17)
$Input1 = GUICtrlCreateInput("Input1", 112, 8, 121, 21)
GUICtrlSetState($Input1, $GUI_DISABLE)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If GUICtrlRead($Checkbox1) = 1 Then
                GUICtrlSetData($Button1,"checked")
            Else
                GUICtrlSetData($Button1,"unchecked")
            EndIf
        Case $Checkbox1
            If GUICtrlRead($Checkbox1) = 1 Then
                GUICtrlSetState($Input1, $GUI_ENABLE) ; enable Input1
                GUICtrlSetState($Input1, $GUI_FOCUS) ; focus Input1
            Else
                GUICtrlSetState($Input1, $GUI_DISABLE) ; disable Input1
            EndIf
    EndSwitch
WEnd

?

Share this post


Link to post
Share on other sites

Thanks you Melba23.

I forgot about

GUICtrlSetState($Input1, $GUI_DISABLE)

Yes you fix it Thanks you very very much for this.You always help me. :)

Info Thnk you very much too solved Thanks to all again.;)

Now i know where is my mistakes.


[size="5"] [/size]

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