waltzie Posted January 27, 2009 Posted January 27, 2009 Hi, is it possible to rename items labels on treeeview "directly on treeview GUI" without using a imputbox? Thanks mutch WaltZie
Zedna Posted January 27, 2009 Posted January 27, 2009 Yes it is. Search for TVN_BEGINLABELEDIT, TVN_ENDLABELEDIT Resources UDF ResourcesEx UDF AutoIt Forum Search
waltzie Posted January 28, 2009 Author Posted January 28, 2009 How can i enable or disable EDIT dinamically? Tnx
spudw2k Posted February 4, 2009 Posted February 4, 2009 (edited) Check out the helpfile for _GUICtrlTreeView_EditText(). Here's a crude example. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <WinAPI.au3> GUICreate("My GUI with treeview", 350, 215) $treeview = GUICtrlCreateTreeView(6, 6, 338, 204, BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $generalitem = GUICtrlCreateTreeViewItem("General", $treeview) GUICtrlSetColor(-1, 0x0000C0) $displayitem = GUICtrlCreateTreeViewItem("Display", $treeview) GUICtrlSetColor(-1, 0x0000C0) $aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem) $compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem) $useritem = GUICtrlCreateTreeViewItem("User", $generalitem) $resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem) $otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem) GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndTreeView, $tNMHDR, $hWndFrom, $iCode, $los, $pos $hWndTreeView = $treeview If Not IsHWnd($hWndTreeView) Then $hWndTreeView = GUICtrlGetHandle($hWndTreeView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTreeView Switch $iCode Case $NM_RCLICK Local $tPOINT = _WinAPI_GetMousePos(True, $hWndFrom) Local $iX = DllStructGetData($tPOINT, "X") Local $iY = DllStructGetData($tPOINT, "Y") Local $tTVHITTESTINFO = _GUICtrlTreeView_HitTestEx($hWndFrom, $iX, $iY) Local $iFlags = DllStructGetData($tTVHITTESTINFO, "Flags") If BitAND($iFlags, $TVHT_ONITEM) Or BitAND($iFlags, $TVHT_ONITEMLABEL) Then $hItem = DllStructGetData($tTVHITTESTINFO, "Item") _GUICtrlTreeView_SelectItem($hWndFrom, $hItem, $TVGN_CARET) _GUICtrlTreeView_EditText($hWndTreeView, $hItem) $pos = MouseGetPos() Do sleep(500) $loc = MouseGetPos() Until $loc[0] < $pos[0]-20 Or $loc[0] > $pos[0]+20 Or $loc[1] < $pos[1]-20 Or $loc[1] > $pos[1]+20 _GUICtrlTreeView_EndEdit($hWndTreeView) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc You'll probably want to code some key capture stuff too to handle the Esc and Enter Key, as you'd expect them to work in a traditional GUI. This example stops the edit of an item when the mouse cursor moves 20+ pixels X or Y away from it's start place when right clicking an item. Hope this helps. edit: Disabling the ability to edit a treeview can be accomplished by changing the control's style and revoking (or applying) $TVS_EDITLABELS flag. Edited February 4, 2009 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
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