eltorro Posted June 10, 2006 Share Posted June 10, 2006 (edited) This function gets the bounding rectangle of a Treeview Item. expandcollapse popup;=============================================================================== ; ; Description: _GUICtrlTreeViewGetItemRect ; Parameter(s): $i_treeview - controlID ; $h_item - item ID/handle to get the bounding rect of ; $b_flag - If set to True, rect returned is just the text area ; else the rect extends out. ; $i_mode - Mode 0 rect relative to Control x,y,r,b ; - Mode 1 Absoulte points relatvie to window.x,y,r,b ; - Mode 2 (Default) Rect relative to Window x,y,w,h ; Requirement: None ; Return Value(s): Returns the item rect on success or 0 otherwise ; User CallTip: ; Author(s): eltorro <steve@ocotillo.sytes.net> ; Note(s): Gets the bounding rectangle of a treeview item. ; ;=============================================================================== Func _GuiCtrlTreeViewGetItemRect($i_treeview, $h_item, $b_flag = True, $i_mode = 1) Local $st_Rect = DllStructCreate("int;int;int;int") If @error Then Return 0 Local $retval[4], $TVM_GETITEMRECT = (0x1100 + 4) ;$TV_FIRST + 4 DllStructSetData($st_Rect, 1, GUICtrlGetHandle($h_item)) If GUICtrlSendMsg($i_treeview, $TVM_GETITEMRECT, $b_flag, DllStructGetPtr($st_Rect)) = 0 Then Return 0 For $x = 0 To 3 $retval[$x] = DllStructGetData($st_Rect, $x + 1) Next If $i_mode = 0 Then Return $retval Local $tv_pos = ControlGetPos("", "", $i_treeview) if @error Then Return 0 ; if errors with ControlGetPos Switch $i_mode Case 1 $retval[0] += $tv_pos[0] $retval[1] += $tv_pos[1] $retval[2] += $tv_pos[0] $retval[3] += $tv_pos[1] Case 2 $retval[2] -= $retval[0] $retval[3] -= $retval[1] $retval[0] += $tv_pos[0] $retval[1] += $tv_pos[1] EndSwitch Return $retval EndFunc ;==>_GuiCtrlTreeViewGetItemRect This would be a useful inclusion to the standard Treeview UDFs Steve Edit1: Clean code, add error check. Edit2: typo Edited June 10, 2006 by eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
Zedna Posted June 10, 2006 Share Posted June 10, 2006 (edited) Here is your code after little cleaning Func _GuiCtrlTreeViewGetItemRect($i_treeview, $h_item, $b_flag = True, $i_mode = 2) Local $st_Rect = DllStructCreate("int;int;int;int") If @error Then Return 0 Local $retval[4], $TVM_GETITEMRECT = (0x1100 + 4) ;$TV_FIRST + 4 DllStructSetData($st_Rect, 1, GUICtrlGetHandle($h_item)) If GUICtrlSendMsg($i_treeview, $TVM_GETITEMRECT, $b_flag, DllStructGetPtr($st_Rect)) = 0 Then Return 0 For $x = 0 To 3 $retval[$x] = DllStructGetData($st_Rect, $x + 1) Next If $i_mode = 0 Then Return $retval Local $tv_pos = ControlGetPos("", "", $i_treeview) Switch $i_mode Case 1 $retval[0] += $tv_pos[0] $retval[1] += $tv_pos[1] $retval[2] += $tv_pos[0] $retval[3] += $tv_pos[1] Case 2 $retval[2] -= $retval[0] $retval[3] -= $retval[1] $retval[0] += $tv_pos[0] $retval[1] += $tv_pos[1] EndSwitch Return $retval EndFunc ;==>_GuiCtrlTreeViewGetItemRect Edited June 10, 2006 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
eltorro Posted June 18, 2006 Author Share Posted June 18, 2006 bump Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
Holger Posted June 18, 2006 Share Posted June 18, 2006 Please post a working sample which uses this function. Without it I see no reason for what it could be helpful. Thanks Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
eltorro Posted June 19, 2006 Author Share Posted June 19, 2006 http://www.autoitscript.com/forum/index.ph...topic=27512&st= Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code 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