RagnaroktA Posted October 5, 2006 Share Posted October 5, 2006 Is there a good way while a script is running, to do the following... When any item in a listview/treeview is clicked, write the value of the item clicked to a main script variable that would change each time an item is clicked. How would I go about doing that? Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki Link to comment Share on other sites More sharing options...
GaryFrost Posted October 5, 2006 Share Posted October 5, 2006 if the ListView is created useing autoit here's one way: expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> Global $ListView Global Const $WM_NOTIFY = 0x004E Global Const $DebugIt = 1 $main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX)) $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 5, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL)) _GUICtrlListViewSetColumnWidth($ListView, 0, 100) _GUICtrlListViewSetColumnWidth($ListView, 1, 100) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("Name 1|Category 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2", $ListView) $lbl = GUICtrlCreateLabel("", 5, 295, 195, 20, $SS_SUNKEN) GUISetState() ;Register WM_NOTIFY events GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 $msg = GUIGetMsg() Switch $msg ;----------------------------------------------------------------------------------------- ;This case statement exits and updates code if needed Case $GUI_EVENT_CLOSE Exit ;----------------------------------------------------------------------------------------- ;put all the misc. stuff here Case Else ;;; EndSwitch WEnd Func ListView_Click() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("$NM_CLICK") ;---------------------------------------------------------------------------------------------- GUICtrlSetData($lbl, _GUICtrlListViewGetItemText($ListView, _GUICtrlListViewGetSelectedIndices($ListView))) EndFunc ;==>ListView_Click Func ListView_DoubleClick() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("$NM_DBLCLK") ;---------------------------------------------------------------------------------------------- MsgBox(0, "Double Clicked", _GUICtrlListViewGetItemText($ListView, _GUICtrlListViewGetSelectedIndices($ListView))) EndFunc ;==>ListView_DoubleClick ; ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam ;ListView Events Local Const $NM_FIRST = 0 Local Const $NM_CLICK = ($NM_FIRST - 2) Local Const $NM_DBLCLK = ($NM_FIRST - 3) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $NM_CLICK ListView_Click() Case $event = $NM_DBLCLK ListView_DoubleClick() EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite("!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ddeerr Posted October 11, 2006 Share Posted October 11, 2006 Hi, I have a quick question, is there definitions about windows message ID (WM_MSG) ? 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