Thetan Posted May 18, 2008 Share Posted May 18, 2008 (edited) This is probably a simple fix, but here is my question. I would like to Create a treeview inside a tab and whenever you click on a different treeview item it will display something different. I'm not sure if this is even close to right, thanks for looking. $TabSheet2 = GUICtrlCreateTabItem("List") $TreeView2 = GUICtrlCreateTreeView(8, 48, 137, 217) GUICtrlSetFont(-1, 9, 600, 0, "Arial") $theitem = GUICtrlCreateTreeViewItem ("First",$TreeView2) GUICtrlSetData( $thelabel, "Description of first") $theitem = GUICtrlCreateTreeViewItem ("Second",$TreeView2) GUICtrlSetData( $thelabel, "Description of second") EDIT: code mistake. Edited May 18, 2008 by Thetan Link to comment Share on other sites More sharing options...
BrettF Posted May 18, 2008 Share Posted May 18, 2008 This is probably a simple fix, but here is my question. I would like to Create a treeview inside a tab and whenever you click on a different treeview item it will display something different. I'm not sure if this is even close to right, thanks for looking. $TabSheet2 = GUICtrlCreateTabItem("List") $TreeView2 = GUICtrlCreateTreeView(8, 48, 137, 217) GUICtrlSetFont(-1, 9, 600, 0, "Arial") $theitem = GUICtrlCreateTreeViewItem ("First",$TreeView2) GUICtrlSetData( $thelabel, "Description of first") $theitem = GUICtrlCreateTreeViewItem ("Second",$TreeView2) GUICtrlSetData( $thelabel, "Description of second") EDIT: code mistake.Need more infomation on what you want to achieve.... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Thetan Posted May 19, 2008 Author Share Posted May 19, 2008 Ok, basically I just want a simple treeview that displays names of things and when you click on any of the names it will display a description of that item. Maybe a treeview isn't the best way to go, but it seemed easy at first.I think I may have found something like it in the examples, but I cant seem to figure it out. Link to comment Share on other sites More sharing options...
rasim Posted May 19, 2008 Share Posted May 19, 2008 This? expandcollapse popup#include <GuiConstants.au3> #include <GuiTreeView.au3> #include <WinAPI.au3> $hGUI = GUICreate("Test", 300, 200) $hTab = GUICtrlCreateTab(10, 10, 280, 180) $TabItem1 = GUICtrlCreateTabItem("TabItem 1") $hTreeView1 = GUICtrlCreateTreeView(25, 40, 100, 140, -1, $WS_EX_CLIENTEDGE) For $i = 1 To 10 GUICtrlCreateTreeViewItem("Item" & $i, $hTreeView1) Next $hEdit1 = GUICtrlCreateEdit("", 150, 80, 110, 60, $ES_WANTRETURN) GUICtrlCreateTabItem("") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $IdFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $IdFrom = DllStructGetData($tNMHDR, "IdFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $IdFrom Case $hTreeView1 Switch $iCode Case $NM_CLICK Local $tPoint = _WinAPI_GetMousePos(True, GUICtrlGetHandle($hTreeView1)) Local $iX = DllStructGetData($tPoint, "X") Local $iY = DllStructGetData($tPoint, "Y") Local $iItem = _GUICtrlTreeView_HitTestItem($hTreeView1, $iX, $iY) If $iItem <> 0 Then Local $iText = _GUICtrlTreeView_GetText($hTreeView1, $iItem) GUICtrlSetData($hEdit1, $iText) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Link to comment Share on other sites More sharing options...
Thetan Posted May 19, 2008 Author Share Posted May 19, 2008 No that's close but not it. I'm sorry I don't think I explained myself well enough. I would need to manually create the name for each item, and manually write a description. How can I link a description with a TreeView Item so that when the Item is clicked the Description is shown? I will try to use your example and fix it to my needs. Thanks for the help. GUICtrlCreateTreeViewItem("Car" & 1, $hTreeView1) GUICtrlCreateTreeViewItem("SUV" & 2, $hTreeView1) GUICtrlCreateTreeViewItem("Truck" & 2, $hTreeView1) GUICtrlCreateTreeViewItem("Motorcycle" & 4, $hTreeView1) GUICtrlSetData( $thelabel, "Description of Car") GUICtrlSetData( $thelabel, "Description of SUV") GUICtrlSetData( $thelabel, "Description of Truck") GUICtrlSetData( $thelabel, "Description of Motorcycle") Link to comment Share on other sites More sharing options...
GaryFrost Posted May 20, 2008 Share Posted May 20, 2008 expandcollapse popup#include <GuiConstants.au3> #include <GuiTreeView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Global $aTreeItemDesc[4] = ["Description of Car", "Description of SUV", "Description of Truck", "Description of Motorcycle"] $hGUI = GUICreate("Test", 300, 200) $hTab = GUICtrlCreateTab(10, 10, 280, 180) $TabItem1 = GUICtrlCreateTabItem("TabItem 1") $hTreeView1 = GUICtrlCreateTreeView(25, 40, 100, 140, -1, $WS_EX_CLIENTEDGE) GUICtrlCreateTreeViewItem("Car" & 1, $hTreeView1) GUICtrlCreateTreeViewItem("SUV" & 2, $hTreeView1) GUICtrlCreateTreeViewItem("Truck" & 2, $hTreeView1) GUICtrlCreateTreeViewItem("Motorcycle" & 4, $hTreeView1) $hEdit1 = GUICtrlCreateEdit("", 150, 80, 110, 60, $ES_WANTRETURN) GUICtrlCreateTabItem("") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $IdFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $IdFrom = DllStructGetData($tNMHDR, "IdFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $IdFrom Case $hTreeView1 Switch $iCode Case $NM_CLICK Local $tPoint = _WinAPI_GetMousePos(True, GUICtrlGetHandle($hTreeView1)) Local $iX = DllStructGetData($tPoint, "X") Local $iY = DllStructGetData($tPoint, "Y") Local $iItem = _GUICtrlTreeView_HitTestItem($hTreeView1, $iX, $iY) If $iItem <> 0 Then GUICtrlSetData($hEdit1, $aTreeItemDesc[_GUICtrlTreeView_Index($hTreeView1, $iItem)]) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc 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...
Thetan Posted May 22, 2008 Author Share Posted May 22, 2008 Thanks for all of the help guys, that works perfect Gary. 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