GraaF1337 Posted September 7, 2014 Share Posted September 7, 2014 (edited) So i'ev been trying to create a drop down menu, without luck, but then i found this code on the forum: #include <GUIConstantsEx.au3> ; Here is the array Global $aArray[5] = ["A", "B", "C", "D", "E"] ; And here we get the elements into a list $sList = "" For $i = 0 To UBound($aArray) - 1 $sList &= "|" & $aArray[$i] Next ; Create a GUI #include <GUIConstantsEx.au3> $hGUI = GUICreate("Form1", 500, 500) ; Create the combo $hCombo = GUICtrlCreateCombo("", 10, 10, 250, 20) ; And fill it GUICtrlSetData($hCombo, $sList) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd And it works like a charm, but i have another issue. I want to let's say that the user picks the first one on the drop down menu, that a msgbox should popup. I've tried this so far without luck: If $i = 1 Then MsgBox(0, "asd", "asdas") EndIf And If $aArray = "A" Then MsgBox(0, "asd", "asdas") EndIf And If $aArray = 1 Then MsgBox(0, "asd", "asdas") EndIf And now im kinda clueless, it's propperly just me completely doing this wrong, so i would like some help Edited September 7, 2014 by GraaF1337 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 7, 2014 Moderators Share Posted September 7, 2014 GraaF1337,Look for the "combo event" message and then read the selection:expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Here is the array Global $aArray[5] = ["A", "B", "C", "D", "E"] ; And here we get the elements into a list $sList = "" For $i = 0 To UBound($aArray) - 1 $sList &= "|" & $aArray[$i] Next ; Create a GUI #include <GUIConstantsEx.au3> $hGUI = GUICreate("Form1", 500, 500) ; Create the combo $hCombo = GUICtrlCreateCombo("", 10, 10, 250, 20) ; And fill it GUICtrlSetData($hCombo, $sList) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hCombo Switch GUICtrlRead($hCombo) Case "A" MsgBox($MB_SYSTEMMODAL, "Hi", "A") Case "B" MsgBox($MB_SYSTEMMODAL, "Hi", "B") Case "C" MsgBox($MB_SYSTEMMODAL, "Hi", "C") Case "D" MsgBox($MB_SYSTEMMODAL, "Hi", "D") Case "E" MsgBox($MB_SYSTEMMODAL, "Hi", "E") EndSwitch EndSwitch WEndAll clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mikell Posted September 7, 2014 Share Posted September 7, 2014 Case $hCombo Msgbox(0,"", GuiCtrlRead($hCombo)) Link to comment Share on other sites More sharing options...
GraaF1337 Posted September 7, 2014 Author Share Posted September 7, 2014 GraaF1337, Look for the "combo event" message and then read the selection: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Here is the array Global $aArray[5] = ["A", "B", "C", "D", "E"] ; And here we get the elements into a list $sList = "" For $i = 0 To UBound($aArray) - 1 $sList &= "|" & $aArray[$i] Next ; Create a GUI #include <GUIConstantsEx.au3> $hGUI = GUICreate("Form1", 500, 500) ; Create the combo $hCombo = GUICtrlCreateCombo("", 10, 10, 250, 20) ; And fill it GUICtrlSetData($hCombo, $sList) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hCombo Switch GUICtrlRead($hCombo) Case "A" MsgBox($MB_SYSTEMMODAL, "Hi", "A") Case "B" MsgBox($MB_SYSTEMMODAL, "Hi", "B") Case "C" MsgBox($MB_SYSTEMMODAL, "Hi", "C") Case "D" MsgBox($MB_SYSTEMMODAL, "Hi", "D") Case "E" MsgBox($MB_SYSTEMMODAL, "Hi", "E") EndSwitch EndSwitch WEnd All clear? M23 Thank you! Once again you have done me a big favor Link to comment Share on other sites More sharing options...
GraaF1337 Posted September 7, 2014 Author Share Posted September 7, 2014 Ohhh! I got 1 more question! Why is it, that i can type in this box? And if i choose something from the dropdown that it's all "marked" with blue? o.O Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 7, 2014 Moderators Share Posted September 7, 2014 GraaF1337,I got 1 more questionThat is 2 questions! If you do not want to type in the combo edit you need to apply the $CBS_DROPDOWNLIST to make it read-only. Windows automatically selects the text in an active combo edit when a selection in made - but if you apply the read-only style as above it no longer happens. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GraaF1337 Posted September 7, 2014 Author Share Posted September 7, 2014 GraaF1337, That is 2 questions! If you do not want to type in the combo edit you need to apply the $CBS_DROPDOWNLIST to make it read-only. Windows automatically selects the text in an active combo edit when a selection in made - but if you apply the read-only style as above it no longer happens. M23 Awesome thank you so much once again! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now