Jump to content
Sign in to follow this  
RZLucian0127

[HELP/REQUEST] BASIC Multi Combo Box Script.

Recommended Posts

RZLucian0127

Guy please help here.. can u guyz give me the sample basic script for this pls..

when the picture in my attached file, the exit button is disabled when the 3 combos has no values. the GUI exit button will enable when 3 combo has a values. the GUI disable when it detects that 1 or 2 combo has no value.. so the GUI needs 3 values to be enable the GUI exit button.. please give me a sample script pls thanks guyz in advance.

post-29264-1195703139_thumb.jpg

Edited by RZLucian0127

Share this post


Link to post
Share on other sites
smashly

Hi, crude example...

#include <GuiConstants.au3>

Global $Combo[4], $cY = 10 

$Gui = GUICreate("Combo", 160, 130)
For $i = 1 To 3    
    $Combo[$i] = GUICtrlCreateCombo("", 10, $cY, 140, 20)
    $cY += 30
Next
$Button = GUICtrlCreateButton("Exit", 50, 100, 60, 20)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $Button
            Exit
        Case Else
            ;;;
    EndSwitch
    ChkState()
WEnd

Func ChkState()
    Local $State
    For $i = 1 To 3
        If GUICtrlRead($Combo[$i]) <> "" Then $State += 1
        If GUICtrlRead($Combo[$i]) = "" And $State > 0 Then $State -= 1
    Next
    If $State = 3 And BitAnd(GUICtrlGetState($Button), $GUI_DISABLE) Then GUICtrlSetState($Button, $GUI_ENABLE)
    If $State < 3 And BitAnd(GUICtrlGetState($Button), $GUI_ENABLE) Then GUICtrlSetState($Button, $GUI_DISABLE)
EndFunc

There's probly better ways to do it, but I'll leave that upto the more experienced members to point the way..

Cheers

Share this post


Link to post
Share on other sites
RZLucian0127

Hi, crude example...

#include <GuiConstants.au3>

Global $Combo[4], $cY = 10 

$Gui = GUICreate("Combo", 160, 130)
For $i = 1 To 3    
    $Combo[$i] = GUICtrlCreateCombo("", 10, $cY, 140, 20)
    $cY += 30
Next
$Button = GUICtrlCreateButton("Exit", 50, 100, 60, 20)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $Button
            Exit
        Case Else
            ;;;
    EndSwitch
    ChkState()
WEnd

Func ChkState()
    Local $State
    For $i = 1 To 3
        If GUICtrlRead($Combo[$i]) <> "" Then $State += 1
        If GUICtrlRead($Combo[$i]) = "" And $State > 0 Then $State -= 1
    Next
    If $State = 3 And BitAnd(GUICtrlGetState($Button), $GUI_DISABLE) Then GUICtrlSetState($Button, $GUI_ENABLE)
    If $State < 3 And BitAnd(GUICtrlGetState($Button), $GUI_ENABLE) Then GUICtrlSetState($Button, $GUI_DISABLE)
EndFunc

There's probly better ways to do it, but I'll leave that upto the more experienced members to point the way..

Cheers

aw bro, the combo has no values.. btw thanks bro ^__^

Share this post


Link to post
Share on other sites
smashly

Hi and your welcome,

The values are upto you to set.. It was mainly an example to show how to enable/disable the button depending if the the combo's have data or not.

But here's some values to keep you happy :P

#include <GuiConstants.au3>

Global $Combo[4], $Label[4], $cY = 30

$Gui = GUICreate("Combo", 260, 160, -1, -1, $WS_POPUP)
GUISetBkColor(0xffffff, $Gui)
GUICtrlCreateGroup("Options", 10, 10, 240, 140)
For $i = 1 To 3
    $Label[$i] = GUICtrlCreateLabel("Combo" & $i, 20, $cY + 3, 40, 20)
    $Combo[$i] = GUICtrlCreateCombo("", 70, $cY, 160, 20)
    For $j = 1 To 10
        GUICtrlSetData($Combo[$i], "Value" & $j, "Value" & $i)
    Next    
    $cY += 30
Next
$Button = GUICtrlCreateButton("Exit", 100, 120, 60, 20)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $Button
            Exit
        Case Else
            ;;;
    EndSwitch
    ChkState()
WEnd

Func ChkState()
    Local $State
    For $i = 1 To 3
        If GUICtrlRead($Combo[$i]) <> "" Then $State += 1
        If GUICtrlRead($Combo[$i]) = "" And $State > 0 Then $State -= 1
    Next
    If $State = 3 And BitAnd(GUICtrlGetState($Button), $GUI_DISABLE) Then GUICtrlSetState($Button, $GUI_ENABLE)
    If $State < 3 And BitAnd(GUICtrlGetState($Button), $GUI_ENABLE) Then GUICtrlSetState($Button, $GUI_DISABLE)
EndFunc

Cheers

Edit: made the example similar to your picture...

Edited by smashly

Share this post


Link to post
Share on other sites
RZLucian0127

Hi and your welcome,

The values are upto you to set.. It was mainly an example to show how to enable/disable the button depending if the the combo's have data or not.

But here's some values to keep you happy ;)

#include <GuiConstants.au3>

Global $Combo[4], $Label[4], $cY = 30

$Gui = GUICreate("Combo", 260, 160, -1, -1, $WS_POPUP)
GUISetBkColor(0xffffff, $Gui)
GUICtrlCreateGroup("Options", 10, 10, 240, 140)
For $i = 1 To 3
    $Label[$i] = GUICtrlCreateLabel("Combo" & $i, 20, $cY + 3, 40, 20)
    $Combo[$i] = GUICtrlCreateCombo("", 70, $cY, 160, 20)
    For $j = 1 To 10
        GUICtrlSetData($Combo[$i], "Value" & $j, "Value" & $i)
    Next    
    $cY += 30
Next
$Button = GUICtrlCreateButton("Exit", 100, 120, 60, 20)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $Button
            Exit
        Case Else
            ;;;
    EndSwitch
    ChkState()
WEnd

Func ChkState()
    Local $State
    For $i = 1 To 3
        If GUICtrlRead($Combo[$i]) <> "" Then $State += 1
        If GUICtrlRead($Combo[$i]) = "" And $State > 0 Then $State -= 1
    Next
    If $State = 3 And BitAnd(GUICtrlGetState($Button), $GUI_DISABLE) Then GUICtrlSetState($Button, $GUI_ENABLE)
    If $State < 3 And BitAnd(GUICtrlGetState($Button), $GUI_ENABLE) Then GUICtrlSetState($Button, $GUI_DISABLE)
EndFunc

Cheers

Edit: made the example similar to your picture...

waaaa T__T bro thanks for the patient ehehe but the exit button is already enabled when the script started.. i just want it to be disable when there is no value selected on 3 combos. and the 3 combo has the unique value for ex:

combo1 has value of enable, disable

combo2 has value of 0 and 1

combo3 has value of yes and no

and that 3 combo has a default blank values.. so when they choose enable and disable on combo1, while the combo2 and 3 has no values(blank), then the exit button is disabled..

and when they complete the form with 3 combos with assigned values, the exit will enable :P thanks bro for your patient.. pls give me the script pls pls pls ehehehe more power bro ^___^ thanks again in

Edited by RZLucian0127

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  

×