|
-
May 29th, 2000, 09:39 PM
#1
Thread Starter
Junior Member
Hi,
Does somebody knows how to prevent a treeview parent node from collapsing on double-click.
I would like to launch something on double click of my nodes but make it impossible to collapse/expand nodes except from the plus/minus sign box.
I know I can probably do it by using subclassing. What I am looking for is the message I have to intercept.
Thanks in advance!
Tipi
-
May 29th, 2000, 10:00 PM
#2
transcendental analytic
Try this
Code:
Private Sub Form_Load()
TreeView1.Nodes.Add TreeView1.Nodes.Add(, , , "A"), 4, , "b"
End Sub
Private Sub TreeView1_Collapse(ByVal Node As MSComctlLib.Node)
Node.Child.EnsureVisible
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 29th, 2000, 10:11 PM
#3
Thread Starter
Junior Member
Not exactly the solution I was looking for since I want to be able to expand/collapse using plus/minus sign...
Thanks,
Tipi
[Edited by Tipi on 05-30-2000 at 11:11 AM]
-
May 30th, 2000, 12:36 AM
#4
Thread Starter
Junior Member
Final Answer
Code:
'This code goes in form
Private Sub Form_Load()
Hook TreeView1.hWnd
End Sub
Private Sub Form_Unload()
Unhook TreeView1.hWnd
End Sub
'This code goes in module
Option Explicit
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const WM_LBUTTONDBLCLICK = &H203
Function WindowProcedure(ByVal hw As Long, ByVal uMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As _
Long
If uMsg = &H203 Then
Call DoWhatYouWant
Exit Function
End If
WindowProcedure = CallWindowProc(lpPrevWndProc, hw, _
uMsg, wParam, lParam)
End Function
Public Sub Hook(hWnd As Long)
lpPrevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProcedure)
End Sub
Public Sub Unhook(hWnd As Long)
Dim temp As Long
temp = SetWindowLong(hWnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
-
May 30th, 2000, 12:42 AM
#5
transcendental analytic
Sorry i didn't test that code, this shoud work:
[/code]
Private stage%
Private Sub Form_Load()
TreeView1.Nodes.Add TreeView1.Nodes.Add(, , , "A"), 4, , "b"
End Sub
Private Sub TreeView1_Collapse(ByVal Node As MSComctlLib.Node)
If stage = 1 Then stage = 2: Node.expanded = True: TreeView1.Tag = ""
End Sub
Private Sub TreeView1_Expand(ByVal Node As MSComctlLib.Node)
If stage = 1 Then stage = 2: Node.Expanded = False: TreeView1.Tag = ""
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
stage = 1
End Sub
[/code]
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 30th, 2000, 11:48 AM
#6
Conquistador
try this:
Code:
Option Explicit
Private Sub Form_Load()
tv1.Nodes.Add , , "main", "Hey"
tv1.Nodes.Add "main", tvwChild, "child", "Hey1"
End Sub
Private Sub tv1_Click()
tv1.SelectedItem.Expanded = True
End Sub
Private Sub tv1_Collapse(ByVal Node As MSComctlLib.Node)
Node.Image = "closed"
End Sub
Private Sub tv1_DblClick()
tv1.SelectedItem.Expanded = False
End Sub
Private Sub tv1_Expand(ByVal Node As MSComctlLib.Node)
Node.Image = "open"
End Sub
-
May 25th, 2004, 07:30 PM
#7
Fanatic Member
whats "Private stage%" do ??
edit: thanks 2 whoever wrote the sol. its in good use
Last edited by SkiNLaB; May 25th, 2004 at 07:45 PM.
-
May 25th, 2004, 08:39 PM
#8
Banned
-
May 25th, 2004, 08:42 PM
#9
Fanatic Member
Originally posted by jhermiz
Nice sig
VB Mods...might want to fix that...or encrypt the data :-)
they already pulled me up about it, and told me to add "Ignoring arc" so that the user was aware what the link was doing...
-
May 26th, 2004, 07:38 AM
#10
Banned
Originally posted by SkiNLaB
they already pulled me up about it, and told me to add "Ignoring arc" so that the user was aware what the link was doing...
whose arc ?
-
May 26th, 2004, 07:09 PM
#11
Fanatic Member
Originally posted by jhermiz
whose arc ?
an [edited by moderator] right wing [edited by moderator] who thinks that every american should live like a king and [edited by moderator] the rest of the world.
thats if my memory serves me correctly.
-
May 26th, 2004, 07:20 PM
#12
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|