iAmNewbe Posted January 8, 2012 Author Posted January 8, 2012 You guys are awesome. I am really brain dead right now but looking over your ideas it all seems to be pointing into the right direction. Thanks.
LarsJ Posted January 8, 2012 Posted January 8, 2012 iAmNewbe, Here is a little interactive example. May be this can help you. Right click to add siblings and children. expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Opt( "MustDeclareVars", 1 ) MainProgram() Func MainProgram() ; Create GUI Local $hGui = GUICreate( "TreeView Control", 400, 300, 600, 300, BitOR( $GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX ) ) ; Create TV Local $iBorderWidth = 4, $aPos = WinGetClientSize( $hGui ) Local $idTV = GUICtrlCreateTreeView( $iBorderWidth, $iBorderWidth, $aPos[0]-2*$iBorderWidth, $aPos[1]-2*$iBorderWidth, -1, $WS_EX_CLIENTEDGE ) Local $hTV = ControlGetHandle( $hGui, "", $idTV ) ; Add root Local $iItem = 0, $hItem = _GUICtrlTreeView_Add( $hTV, 0, $iItem ) _GUICtrlTreeView_SelectItem( $hTV, $hItem ) $iItem += 1 ; Context menu Local $cmTV = GUICtrlCreateContextMenu( $idTV ) Local $cmTV0 = GUICtrlCreateMenuItem( "Add sibling before", $cmTV ) Local $cmTV1 = GUICtrlCreateMenuItem( "Add sibling after", $cmTV ) Local $cmTV2 = GUICtrlCreateMenuItem( "Add child", $cmTV ) GUISetState() While 1 Local $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $cmTV0 ; Add sibling before $hItem = _GUICtrlTreeView_GetSelection( $hTV ) Local $hParent = _GUICtrlTreeView_GetParentHandle( $hTV, $hItem ) Local $hPrev = _GUICtrlTreeView_GetPrevSibling( $hTV, $hItem ) If $hPrev = 0 Then _GUICtrlTreeView_AddFirst( $hTV, $hItem, $iItem ) Else _GUICtrlTreeView_InsertItem( $hTV, $iItem, $hParent, $hPrev ) EndIf $iItem += 1 Case $cmTV1 ; Add sibling after $hItem = _GUICtrlTreeView_GetSelection( $hTV ) Local $hParent = _GUICtrlTreeView_GetParentHandle( $hTV, $hItem ) _GUICtrlTreeView_InsertItem( $hTV, $iItem, $hParent, $hItem ) $iItem += 1 Case $cmTV2 ; Add child $hItem = _GUICtrlTreeView_GetSelection( $hTV ) _GUICtrlTreeView_AddChild( $hTV, $hItem, $iItem ) _GUICtrlTreeView_Expand( $hTV, $hItem ) $iItem += 1 EndSwitch WEnd GUIDelete( $hGui ) Exit EndFunc Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
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