alansch64 Posted March 17, 2008 Share Posted March 17, 2008 Good evening, How could I get the data from a listbox by just clicking or selecting it and send it to a label for example (without the use of a button) Thanks for your help CODE#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 405, 296, 303, 219) $List1 = GUICtrlCreateList("", 36, 29, 154, 201) GUICtrlSetData(-1, "TEST") $Label1 = GUICtrlCreateLabel("Label1", 230, 32, 36, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Aceguy Posted March 17, 2008 Share Posted March 17, 2008 (edited) See _guictrllistview_create in the help file.... expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Global $hListView Local $GUI, $hImage $GUI = GUICreate("(External) ListView Create", 400, 300) $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 200) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) $label = GUICtrlCreateLabel("log", 5, 210, 275, 25) ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $it = DllStructGetData($tInfo, "Index") GUICtrlSetData($label, _GUICtrlListView_GetItemTextString($hListView, $it)) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Edited March 17, 2008 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
alansch64 Posted March 17, 2008 Author Share Posted March 17, 2008 hmmm much more complicated than with a simple buton action... but I will try .... Thank you very much for the hint Link to comment Share on other sites More sharing options...
rover Posted March 18, 2008 Share Posted March 18, 2008 (edited) from AutoIt Snippets databasehttp://quadryders.com/phpcc/snippet.php?sid=7Edit: double click listbox itemlistbox eventsexpandcollapse popup#include <GuiConstantsEX.au3> #include <WindowsConstants.au3> #include <ListBoxConstants.au3> ;Global Const $WM_COMMAND = 0x0111 $hGui = GUICreate("Doubleclick Listbox Items", 250, 220, -1, -1) $label = GUICtrlCreateLabel("Selected item here", 10, 180, 230, 20) $List = GUICtrlCreateList("ListItem1", 10, 10, 230, 160, _ BitOR($LBS_SORT, $LBS_NOINTEGRALHEIGHT, $LBS_NOTIFY, $WS_TABSTOP)) For $i = 2 To 6 GUICtrlSetData($List, "ListItem" & $i) Next GUISetState() GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func List_DoubleClick() $sListItem = GUICtrlRead($List) ; double clicked listbox item string GUICtrlSetData($label, $sListItem) EndFunc ;==>List_DoubleClick Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) ; HiWord Local $nID = BitAND($wParam, 0xFFFF) ; LoWord Local Const $LBN_DBLCLK = 2 Switch $nID Case $List Switch $nNotifyCode Case $LBN_DBLCLK List_DoubleClick() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Edited March 18, 2008 by rover I see fascists... Link to comment Share on other sites More sharing options...
FreeFry Posted March 18, 2008 Share Posted March 18, 2008 What is it that you want to do exactly? When a input is clicked, your application should read the data in the input? 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