Sign in to follow this  
Followers 0
matthewst

How do I trigger an event based on the setdata from a combobox?

5 posts in this topic

Here is what I have?

#include <GUIConstants.au3>

Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)

$Gui = GUICreate("Bldg.", 215, 200, 192, 125, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Combo1 = GUICtrlCreateCombo("", 10, 10, 200, 240, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_GROUP))
GUICtrlSetTip(-1, "Select the building with the emergency")
GUICtrlSetFont(-1, 10, 400, 0, "Times New Roman")
GUICtrlSetData(-1, "Bldg 1|Bldg 2|Bldg 3|Bldg 4|Bldg 5")

$Combo2 = GUICtrlCreateCombo("", 10, 40, 200, 240, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_GROUP))
GUICtrlSetTip(-1, "Select the building with the emergency")
GUICtrlSetFont(-1, 10, 400, 0, "Times New Roman")
GUICtrlSetData(-1, "Bldg 1|Bldg 2|Bldg 3|Bldg 4|Bldg 5")

$OK1 = GUICtrlCreateButton ("OK",  25, 70, 50)
GUICtrlSetOnEvent(-1, "OKPressed")
$Cancel1 = GUICtrlCreateButton ("Cancel",  140, 70, 60)
GUICtrlSetOnEvent(-1, "CancelPressed")

GUISetState(@SW_SHOW)
$win_pos = WinGetPos($Gui)
$tmp_pos = $win_pos

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
    EndSelect
Wend

Func OKPressed()
If $Combo1 = "Bldg 1" Then
   Run("pic.bat", "", @SW_HIDE)
EndIF
EndFunc

Func CancelPressed()
    exit
EndFunc

Func SpecialEvents()
Select
  Case @GUI_CTRLID = $GUI_EVENT_CLOSE
     Exit
EndSelect
EndFunc

If I select bldg 1 in the first box and hit ok I want a picture of that building dislayed.

How do I make it do that?

Share this post


Link to post
Share on other sites



I've tried using case instead of if's but still no luck.

Share this post


Link to post
Share on other sites

Sorry manadar, I just can't get that to work either.

Share this post


Link to post
Share on other sites

GOT IT!!!!!!!!!!!!!!!!

Thanks manadar!!!!

Func OKPressed()
$Read = GUICtrlRead($Combo1)
If $Read = "Bldg 1" Then
    Run("pic.bat", "", @SW_HIDE)
EndIf
If $Read = "Bldg 2" Then
    Run("pic2.bat", "", @SW_HIDE)
EndIf

EndFunc

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