Is there any way to determine which node the user has clicked on via the NM_CLICK message or does that have to be determined via the TVN_SELCHANGING message and the NM_TREEVIEW structure?
Announcement
Collapse
No announcement yet.
Treeview - NM_CLICK
Collapse
X
-
Try the following:
Code:Local pNMTV As NM_TREEVIEW Ptr pNMTV = lParam hNode = @pNMTV.itemNew.hItem
Paul Squires
FireFly Visual Designer (for PowerBASIC Windows 10+)
Version 3 now available.
http://www.planetsquires.com
-
-
Perhaps I should explain what I'm trying to do.
I have two treeviews. Each has the same number of root nodes with the same text, but they may have a different number of children items with different text. I want to enable one-click expansion and contraction of both treeview root nodes when a user clicks on either control. The synchronization of the treeviews is no problem but the one-click aspect is.
Another aspect is suppressing the highlight when the user selects either a root node or child item. I have not found a way to do that.Walt Decker
Comment
-
-
From the WinAPI help file:
Code:Action flag. This parameter can be one of the following values: Value Meaning TVE_COLLAPSE Collapses the list. TVE_COLLAPSERESET Collapses the list and removes the child items. Note that TVE_COLLAPSE must also be specified. TVE_EXPAND Expands the list. TVE_TOGGLE Collapses the list if it is currently expanded or expands it if it is currently collapsed.
Paul Squires
FireFly Visual Designer (for PowerBASIC Windows 10+)
Version 3 now available.
http://www.planetsquires.com
Comment
-
-
this link http://www.powerbasic.com/support/pb...ight=walk+tree includes code to suppress the "flashing" of the cursor and also HITTEST code and a link to Steve Rossell's Treeview example which is very useful for many TreeView applications.
Comment
-
-
>It may not be necessary to hook the NM_CLICK message
If your application is as described... you want to synchronize the selection and expand/collapse status of the two treeview contols.... it is NOT necessary at all.
Just pick up the WM_NOTIFY/TVN_SELCHANGED (or CHANGING) and the WM_NOTIFY/TVN_ITEMEXPANDED (or EXPANDING) notifications.
Now... for EXTRA credit... handle both controls with the same code WITHOUT ever interrogating which control actually generated the notification message.
(Yes, it can be done).
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
Michael:
I'm already doing that. I use two arrays containing the item handles of the root items. I interrogate the NM_TREEVIEW structure for the itemnew element handle then parse through the arrays until I find the element handle then expand/contract both. There probably is another method, but this is the one I'm using.
By the way, in the TV_ITEM structure there is a "state" element and a "statemask" element. If you know what the "state" element is, e.g. "TVIS_EXPANDED", why do you have to know which bits, from the "statemask" element, are valid?Walt Decker
Comment
-
-
By the way, in the TV_ITEM structure there is a "state" element and a "statemask" element. If you know what the "state" element is, e.g. "TVIS_EXPANDED", why do you have to know which bits, from the "statemask" element, are valid?Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
Michael:
Just pick up the WM_NOTIFY/TVN_SELCHANGED (or CHANGING) and the WM_NOTIFY/TVN_ITEMEXPANDED (or EXPANDING) notifications.
According to the WinAPI help the state element can be zero or one or more of the TVIS_ constants. If one ANDs the state element with the TVIS_ constants of interest, what good is the statemask? Seems kinda redundant to me.Last edited by Walt Decker; 16 Dec 2008, 05:24 PM.Walt Decker
Comment
-
-
Must AND statemask vs State BEFORE testing vs TVIS_xxxx values.
ie if Statemask AND State AND TVIS_xxx = TVIS THEN it's true.
If state AND TVIS_xxxx then ... it's only true of Statemask AND TVIS_xxxx is true.
When retrieving state (TVM_GETITEMSTATE) you will only get valid bits for those bits which on ON in the transmitted statemask. Normally you'd set that mask to &hFFFF because you want all state bits, but that is not a requirement.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
-
My SDK doc (which you could have looked up yourself at MSDN)
action
Notification-specific action flag.
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
Comment