dabus Posted September 15, 2008 Share Posted September 15, 2008 (edited) Yeah, this sounds a little strange. The reason is that I am creating a bigger script. The main area consists of a treeview. Some items have additional informations. These are stored in an array that is build at the startup of the application. It looks like this: ID Text Info HWND 1...A................0x1234 2...B................0x1235 3...C...... FOO...0x1236 So when I am above the the first two items, nothing happens. When I am above the third treeviewitem, it is selected and a popup shows FOO. I currently do this by an idea that Siao came up with: Func _TreeItemFromPoint($a) Local $tMPos = _WinAPI_GetMousePos(True, $a) Return _GUICtrlTreeView_HitTestItem($a, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) EndFunc ;==>_TreeItemFromPoint This gives me the handle. To get the info, I loop through the stored HWNDs in the array. If Info is not "" then the popup appears. This works,but I would like to know if there is a better way to do this. (I'm sure there is ) I only want to switch the selection when a new info is shown to have a hint/connection that this info belongs to the selected/focused item. So Focusing and doing GUICtrlRead on the treeview is out. Any thoughts? Thx in advance. Edited September 15, 2008 by dabus Link to comment Share on other sites More sharing options...
rasim Posted September 16, 2008 Share Posted September 16, 2008 dabusthis sounds a little strangeYou can't get the ID from a treeviewitems, which was created with _GUICtrlTreeView_* functions. Why you need this? Link to comment Share on other sites More sharing options...
dabus Posted September 16, 2008 Author Share Posted September 16, 2008 (edited) I don't create them with _GUICtrlTreeView_* but with internal functions. ; creation $trees[$s][0] = GUICtrlCreateTreeViewItem($Setup[$s][1], $streeview) ; putting stuff into an array $MsgTrans[$trees[$s][0]][0] = $Setup[$s][0]; current setup $MsgTrans[$trees[$s][0]][1] = $TAG; tag $MsgTrans[$trees[$s][0]][2] = '-'; tag as no component ;... and so on ; later I get a click and I know what's going on $sMsg=GuiReadMsg() ConsoleWrite('Setup ' & $MsgTrans[$sMsg][0] & ' was seleced' & @CRLF) So there is a direct connection between the ControlID and the related informations in the $MsgTrans array. If I hover over an item, I currently only know a way to get the handle. That's why I store HWNDs in MsgTrans and loop through to find the information. If it would be possible to convert them, the app would run faster since no search was needed. Well in this case, getting the ControlID somehow would be enough. Edited September 16, 2008 by dabus Link to comment Share on other sites More sharing options...
smashly Posted September 17, 2008 Share Posted September 17, 2008 (edited) I don't create them with _GUICtrlTreeView_* but with internal functions. ; creation $trees[$s][0] = GUICtrlCreateTreeViewItem($Setup[$s][1], $streeview) ; putting stuff into an array $MsgTrans[$trees[$s][0]][0] = $Setup[$s][0]; current setup $MsgTrans[$trees[$s][0]][1] = $TAG; tag $MsgTrans[$trees[$s][0]][2] = '-'; tag as no component ;... and so on ; later I get a click and I know what's going on $sMsg=GuiReadMsg() ConsoleWrite('Setup ' & $MsgTrans[$sMsg][0] & ' was seleced' & @CRLF) So there is a direct connection between the ControlID and the related informations in the $MsgTrans array. If I hover over an item, I currently only know a way to get the handle. That's why I store HWNDs in MsgTrans and loop through to find the information. If it would be possible to convert them, the app would run faster since no search was needed. Well in this case, getting the ControlID somehow would be enough. If your using the internal GUICtrlCreateTreeViewItem() then use _GUICtrlTreeView_GetItemParam() to retrieve the control ID. Cheers Edited September 17, 2008 by smashly Link to comment Share on other sites More sharing options...
rasim Posted September 17, 2008 Share Posted September 17, 2008 If I hover over an item, I currently only know a way to get the handle.Still i don't understand what you need exactly ID? All operations you can process with handle. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> $Style = BitOR($TVS_HASBUTTONS, $TVS_FULLROWSELECT, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) $hGUI = GUICreate("Test", 300, 300) $hTreeView = _GUICtrlTreeView_Create($hGUI, 10, 10, 280, 280, $Style) For $i = 1 To 10 $hItem = _GUICtrlTreeView_Add($hTreeView, 0, "Item " & $i) For $j = 1 To 10 _GUICtrlTreeView_AddChild($hTreeView, $hItem, "Child " & $j) Next Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hTreeView Switch $iCode Case $NM_SETCURSOR Local $tPOINT = DllStructCreate("int X;int Y") DllStructSetData($tPOINT, "X", MouseGetPos(0)) DllStructSetData($tPOINT, "Y", MouseGetPos(1)) DllCall("user32.dll", "int", "ScreenToClient", "hwnd", $hTreeView, "ptr", DllStructGetPtr($tPOINT)) Local $iItem = _GUICtrlTreeView_HitTestItem($hTreeView, DllStructGetData($tPOINT, "X"), _ DllStructGetData($tPOINT, "Y")) If $iItem <> 0 Then _SendMessage($hTreeView, $TVM_SELECTITEM, $TVGN_CARET, $iItem) ConsoleWrite("!> " & _GUICtrlTreeView_GetText($hTreeView, $iItem) & " is hovered" & @LF) Else _SendMessage($hTreeView, $TVM_SELECTITEM, $TVGN_CARET, 0) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Link to comment Share on other sites More sharing options...
KaFu Posted September 17, 2008 Share Posted September 17, 2008 (edited) I'm not sure, this is more a question than an answer, but how about this: #include <WinAPI.au3> _Main() Func _Main() Local $button GUICreate("test") $button = GUICtrlCreateButton("testing", 0, 0) MsgBox(4096, "ID","Control ID: " & $button & @crlf _ & "Control hWnd: " & GUICtrlGetHandle($button) & @crlf _ & "Control ID from hWnd: " & _WinAPI_GetDlgCtrlID(GUICtrlGetHandle($button)) & @crlf _ & "Control ID from hWnd (cleaned): " & number(_WinAPI_GetDlgCtrlID(GUICtrlGetHandle($button)))) EndFunc ;==>_MainoÝ÷ Øýz-²êÞøÂä±ú+jYl¢»l¡÷(Úè˧µë-yÐ^²Ô^ªÝ°Gbµh^aynØî²Ùǧ¢è!{-y§h}«¢+صÀìÅÕ½Ðí ½¹Ñɽ°%ɽ´¡]¹¡±¹¤èÅÕ½ÐìµÀì¹ÕµÈ¡ÍÑÉ¥¹É¥¡Ð¡}]¥¹A%}ѱ Ñɱ%¡U% ÑɱÑ!¹± ÀÌØíÕÑѽ¸¤¤±ÍÑÉ¥¹±¸¡}]¥¹A%}ѱ Ñɱ%¡U% ÑɱÑ!¹± ÀÌØíÕÑѽ¸¤¤¤´È¤¤¤ Edited September 17, 2008 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
dabus Posted September 17, 2008 Author Share Posted September 17, 2008 smashly: That's exactly what I was searching for. rasim: If you look at my example, you can see that I want to display a hint that is diffrent from the text. So I put these stuff into an array. Since the ControlID is a number, the corresponding values are found directly without a search. I currently store 12 values in this array. I don't want them to be displayed in the text of the TreeViewItem, but I need them for popups and other purposes later. So basicly, I just use the ID to find the items text, setup, type, ... to this item. KaFu: This does not seem to work on TreeViewItems. Thank you all for your time you spend to help me. 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