Jump to content

how to read data of GUICtrlCreateCombo


bills4
 Share

Recommended Posts

i have this program 

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1_1 = GUICreate("check cvv sony v1.1", 379, 155, 438, 309)
$Combo1 = GUICtrlCreateCombo("", 32, 24, 161, 25,BitOR($WS_VSCROLL,$ES_READONLY,$CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetBkColor(-1,0xFFFFFF)
GUISetState(@SW_SHOW)
$CHECK_NOW = GUICtrlCreateButton("CHECK", 264, 16, 81, 49)
#EndRegion ### END Koda GUI section ###


$list = GUICtrlSetData($Combo1,"item1|item2|item3","item1")
$item = GUICtrlRead($list)



While 1
$MSG = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $MSG = $CHECK_NOW
Check()
EndSelect
WEnd

Func Check()
   MsgBox(0, "Bang thong bao:", $item)
   EndFunc

i want when user choose item and click check then it will show value user choose

example you choose item2, when click check , it will show item2

Link to comment
Share on other sites

You're checking the list and not the control.  

You need to check the control within the loop (otherwise you won't know it changed).  You can do this check in your function.  I'm a fan of keeping as much stuff in local scope in the Functions so i'd pass the control to the function and have it check the control.

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1_1 = GUICreate("check cvv sony v1.1", 379, 155, 438, 309)
$Combo1 = GUICtrlCreateCombo("", 32, 24, 161, 25,BitOR($WS_VSCROLL,$ES_READONLY,$CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetBkColor(-1,0xFFFFFF)
GUISetState(@SW_SHOW)
$CHECK_NOW = GUICtrlCreateButton("CHECK", 264, 16, 81, 49)
#EndRegion ### END Koda GUI section ###
 
 
GUICtrlSetData($Combo1,"item1|item2|item3","item1")
 
 
 
 
While 1
$MSG = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $MSG = $CHECK_NOW
Check($Combo1)
EndSelect
WEnd
 
Func Check($hCtrl)
   MsgBox(0, "Bang thong bao:", GUICtrlRead($hCtrl))
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...