Sign in to follow this  
Followers 0
SpecialK

How to disable a ComboBox in a Gui?

4 posts in this topic

#1 ·  Posted (edited)

Hello,

i try to create a little gui with a combo box. The bombo box should only be active when a checkbox is set. When the checkbox is not set, the combo box should be disabled.

I tried it with this piece of code:

GUICreate("Stryker Domain Tool", 250, 700)
    GUISetState(@SW_SHOW)  
    $guimail = GUICtrlCreateCheckbox ("Mailaccount erstellen", 5, 400)
    GUICtrlSetState (-1, $Gui_checked)
    GUICtrlCreateLabel ("Größe der Mailbox:", 5, 432)
    $mailboxgroesse = GUICtrlCreateCombo ("Bis 25 MB", 110, 430)
    GUICtrlSetData (-1, "Bis 300 MB|Bis 1000 MB")
    $guiweiter = GUICtrlCreateButton ("User erstellen", 5, 550, 80)
    $guiabbrechen = GUICtrlCreateButton ("Abbrechen", 100, 550,80)
    

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $guiabbrechen  then Exit
        if GUICtrlRead ($guimail) = $Gui_Unchecked Then 
                              GUICtrlSetState  ($mailboxgroesse, $Gui_Disable)
                        else
              GUICtrlSetState  ($mailboxgroesse, $Gui_Disable)
                        endif
    WEnd
    GUIDelete()

This code works, but the combox is alway blinking. It seems that it get refreshed in eyery loop. Is there a way to realise the enable / disable situation without a blinking combo box?

Thank you

SpecialK

Edited by SpecialK

Share this post


Link to post
Share on other sites



Hello,

i try to create a little gui with a combo box. The bombo box should only be active when a checkbox is set. When the checkbox is not set, the combo box should be disabled.

I tried it with this piece of code:

GUICreate("Stryker Domain Tool", 250, 700)
    GUISetState(@SW_SHOW)  
    $guimail = GUICtrlCreateCheckbox ("Mailaccount erstellen", 5, 400)
    GUICtrlSetState (-1, $Gui_checked)
    GUICtrlCreateLabel ("Größe der Mailbox:", 5, 432)
    $mailboxgroesse = GUICtrlCreateCombo ("Bis 25 MB", 110, 430)
    GUICtrlSetData (-1, "Bis 300 MB|Bis 1000 MB")
    $guiweiter = GUICtrlCreateButton ("User erstellen", 5, 550, 80)
    $guiabbrechen = GUICtrlCreateButton ("Abbrechen", 100, 550,80)
    

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $guiabbrechen  then Exit
        if GUICtrlRead ($guimail) = $Gui_Unchecked Then 
                              GUICtrlSetState  ($mailboxgroesse, $Gui_Disable)
                        else
              GUICtrlSetState  ($mailboxgroesse, $Gui_Disable)
                        endif
    WEnd
    GUIDelete()oÝ÷ Ù8b±Ê{
+Æî¶Ø^r£¬jɹbH§ly鬶­Ø¶·­ë!yا{'«ÊZ(¤-êÞk²¶ÞjX¬zØ^zvïÝÆë"¶æ­ðØhºÖ)äx¢fènS©äÊ¥ç"jR¿ªê-xLZ^jëh×6#include <GuiConstantsEx.au3>

GUICreate("Stryker Domain Tool", 250, 700)

$guimail = GUICtrlCreateCheckbox("Mailaccount erstellen", 5, 400)
GUICtrlSetState(-1, $Gui_checked)

GUICtrlCreateLabel("Gro?e der Mailbox:", 5, 432)

$mailboxgroesse = GUICtrlCreateCombo("Bis 25 MB", 110, 430)
GUICtrlSetData(-1, "Bis 300 MB|Bis 1000 MB")

$guiweiter = GUICtrlCreateButton("User erstellen", 5, 550, 80)
$guiabbrechen = GUICtrlCreateButton("Abbrechen", 100, 550, 80)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $guiabbrechen
            Exit
        Case $guimail
            If BitAND(GUICtrlRead($guimail), $GUI_CHECKED) Then
                GUICtrlSetState($mailboxgroesse, $GUI_ENABLE)
            Else
                GUICtrlSetState($mailboxgroesse, $GUI_DISABLE)
            EndIf
    EndSwitch
WEnd

GUIDelete()

:)

Share this post


Link to post
Share on other sites

Thank you very much!!

Now it works.

But i changed the code a little bite to this:

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $guiabbrechen
            Exit
        Case $guimail
            If GUICtrlRead ($guimail) = $GUI_CHECKED Then
                GUICtrlSetState($mailboxgroesse, $GUI_ENABLE)
            Else
                GUICtrlSetState($mailboxgroesse, $GUI_DISABLE)
            EndIf
    EndSwitch

Because i never used BitAnd before it was new for me so i changed the code to this solution which also works. Or is it better to use the BitAnd solution?

SpecialK

Share this post


Link to post
Share on other sites

SpecialK

Or is it better to use the BitAnd solution?

For a checkbox control - unnecessary.

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