Desha

Combobox Help

2 posts in this topic

Hi all , need your support very urgent  I have 2 questions and they are related to each other please check my Script and advice

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=d:\sct\form1.kxf
$Form1_1 = GUICreate("Form1", 615, 438, -1, -1)
GUISetBkColor(0x000000)
GUICtrlCreateLabel("Welcom to SCT", 192, 8, 173, 33)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008080)
$Combo1 = GUICtrlCreateCombo("New device", 56, 88, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "1-Local loop ATM|2-Local Loop EFM|3-3 G|4-MW&WM|5-Ethernet|6-Modems|7-Network")
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008080)
$Combo2 = GUICtrlCreateCombo("Old device", 320, 88, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "1-Soho|2-1941|3-1921|4-1841|5-Huawie")
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008080)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit


 EndSwitch

WEnd

------------------------------------------------------------

First question : I need to make submenu in the first combobox with the second combobox , for example when I choose first option in combo1 another menu appears with the options in combo 2

 

second question : i need to know how can i set certain function for each Element in the combobox , for example when i choose first option in combo1 it opens notepad

 

 

Share this post


Link to post
Share on other sites



You can do something like this.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ComboConstants.au3>
#include <GuiComboBox.au3>



Local $Type, $Select, $Result, $msg
GUICreate("My GUI combo")

$Type = GUICtrlCreateCombo("Choose TYPE", 10, 10, 150, 20, $CBS_DROPDOWNLIST);
GUICtrlSetData(-1, "|TYPE A|TYPE B|TYPE C")

$Select = GUICtrlCreateCombo("", 10, 35, 200, 20, $CBS_DROPDOWNLIST)
$Result = GUICtrlCreateInput("", 200, 10, 50, 20)

GUISetState()
Local Const $aData[] = ["A-02|A-03|Calc", "SndVol|Notepad|B-03|", "C-01|Taskmgr|C-03"]
Local $idMsg = 0
While 1
    $idMsg = GUIGetMsg()
    Select
        Case $idMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $idMsg = $Type
            GUICtrlSetData($Select, "")
            GUICtrlSetData($Select, $aData[_GUICtrlComboBox_GetCurSel($Type)])
        Case $idMsg = $Select
            GUICtrlSetData($Result, GUICtrlRead($Select))
            Switch GUICtrlRead($Select)
                Case "SndVol"
                    ShellExecute("SndVol.exe")

                Case "Notepad"
                    ShellExecute("Notepad.exe")
                Case "Taskmgr"
                    ShellExecute("Taskmgr.exe")
                Case "Calc"
                    ShellExecute("Calc.exe")
                Case Else

            EndSwitch

    EndSelect


WEnd
GUIDelete()

Saludos

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