SpookMeister Posted September 5, 2006 Posted September 5, 2006 I want to create an interactive GUI where a dynamic list on the left side displays pertinent data about a selection on the right side when an item in the list is selected. I think I see how to do this if I make a case statement for each item, but how can I do that if the information is dynamic (loaded from a file). For example: The file contains data like: 1001,Name A,Details A 1002,Name B,Details B 1003,Name C,Details C for this example I want the columns (im assuming listitems is best here) to display: 1001|Name A 1002|Name B 1003|Name C And when either of the line items is clicked on I want a panel/field/input/whatever to display the appropriate "Details" information for the selected item. Consider that the number of line items is going to be constantly changing each time the script is run. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
GaryFrost Posted September 5, 2006 Posted September 5, 2006 How about just making a ListView with 3 columns, 3rd column is hidden, item is selected read 3rd column in and show in a label etc.... SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
SpookMeister Posted September 6, 2006 Author Posted September 6, 2006 (edited) How about just making a ListView with 3 columns, 3rd column is hidden, item is selected read 3rd column in and show in a label etc....I follow your thought there, but I'm a bit sketchy on the implementation.The sample from the help file shows giving the items a handle so they can be referenced by the CASE select statement. How am I going to do that in this situation when the items I'm adding are pulled from a file and not directly coded? Edited September 6, 2006 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
Moderators SmOke_N Posted September 6, 2006 Moderators Posted September 6, 2006 I follow your thought there, but I'm a bit sketchy on the implementation.The sample from the help file shows giving the items a handle so they can be referenced by the CASE select statement. How am I going to do that in this situation when the items I'm adding are pulled from a file and not directly coded?Variables?Arrays? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
GaryFrost Posted September 6, 2006 Posted September 6, 2006 (edited) expandcollapse popup#include <GuiConstants.au3>;Inclusion file for the GUI interface controls #include <GuiListView.au3> #include <GuiStatusBar.au3> Global $ListView Global Const $WM_NOTIFY = 0x004E Global Const $DebugIt = 1 ;ListView Events Global Const $NM_FIRST = 0 Global Const $NM_LAST = (-99) Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1) Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) ;~ Global Const $NM_RETURN = ($NM_FIRST - 4) ;~ Global Const $NM_RCLICK = ($NM_FIRST - 5) ;~ Global Const $NM_RDBLCLK = ($NM_FIRST - 6) ;~ Global Const $NM_SETFOCUS = ($NM_FIRST - 7) ;~ Global Const $NM_KILLFOCUS = ($NM_FIRST - 8) ;~ Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12) ;~ Global Const $NM_HOVER = ($NM_FIRST - 13) ;~ Global Const $NM_NCHITTEST = ($NM_FIRST - 14) ;~ Global Const $NM_KEYDOWN = ($NM_FIRST - 15) ;~ Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16) ;~ Global Const $NM_SETCURSOR = ($NM_FIRST - 17) ;~ Global Const $NM_CHAR = ($NM_FIRST - 18) ;~ Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19) Global Const $LVN_FIRST = -100; Global Const $LVN_ITEMCHANGED = ($LVN_FIRST - 1); #endregion End Global variables Opt("WinTitleMatchMode", 2) $main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX)) $ListView = GUICtrlCreateListView("Entry Name|Category|Hidden", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL)) _GUICtrlListViewSetColumnWidth($ListView, 0, 100) _GUICtrlListViewSetColumnWidth($ListView, 1, 100) _GUICtrlListViewHideColumn($ListView, 2) 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|Hidden 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2|Hidden 2", $ListView) $StatusBar1 = _GuiCtrlStatusBarCreate($main_GUI, 225, "") 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") ;---------------------------------------------------------------------------------------------- EndFunc ;==>ListView_Click Func ListView_DoubleClick() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("$NM_DBLCLK") ;---------------------------------------------------------------------------------------------- _GuiCtrlStatusBarSetText($StatusBar1, _GUICtrlListViewGetItemText($ListView, _GUICtrlListViewGetSelectedIndices($ListView), 2)) EndFunc ;==>ListView_DoubleClick Func ListView_ItemChanged() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("$LVN_ITEMCHANGED: " & _GUICtrlListViewGetItemText($ListView, _GUICtrlListViewGetSelectedIndices($ListView), 2)) ;---------------------------------------------------------------------------------------------- _GuiCtrlStatusBarSetText($StatusBar1, _GUICtrlListViewGetItemText($ListView, _GUICtrlListViewGetSelectedIndices($ListView), 2)) EndFunc ;==>ListView_ItemChanged ; ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam 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() Case $event = $LVN_ITEMCHANGED ListView_ItemChanged() 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 Edit: Don't need the double click setting the Statusbar that was code from my snippets, but shows you that you can use click and double click and updown arrows. Edited September 6, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
SpookMeister Posted September 6, 2006 Author Posted September 6, 2006 Thanks gafrost, While that is a lot to chew on, it is definately what I was looking for. -Spook [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
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