|
-
Jun 7th, 2012, 10:53 PM
#1
Thread Starter
Addicted Member
TreeView problem
I have a TreeView control (ver. 6.0 SP6) sitting directly on a form.
The TreeView control has a bug, so I wish to call it, in that when You use the method to Edit a label, The BeforeLabelEdit event gets hit, BUT the Lost Focus events get hits simutaneously, which is not good because the AfterLabelEdit event only gets hit if the label name changes, and I need to keep track of whenEVER i am editing a label, because when the TreeView looses focus, the editing stops too, but guess what, if your editing a label and after the LostFocus event gets hit initially, it never gets hit again when the control ACTUALLY DOES LOOSE FOCUS. So on to Subclassing, but I cant seem to find any of the TVM messages flying by in Spy++. Should I be subclassing the form or the TreeView control? Anyway I locked onto both with Spy, and see no TVM messages. I was hoping to do my thing upon seeing the TVM_ENDEDITLABELNOW.
Thanks
-
Jun 7th, 2012, 11:31 PM
#2
Re: TreeView problem
 Originally Posted by vb_lover
The TreeView control has a bug, so I wish to call it, in that when You use the method to Edit a label..
I don't understand what that means. What's the bug in Treeview control and what's that you need to do with the Treeview?
The other part about the problems with the Label events is clear, but i just wanted to understand first what's the problem with the Treeview.
-
Jun 8th, 2012, 12:06 AM
#3
Re: TreeView problem
Now I see you were talking about the Node Labels, ok, about this:
but guess what, if your editing a label and after the LostFocus event gets hit initially, it never gets hit again when the control ACTUALLY DOES LOOSE FOCUS
This is not true, the Lost_Focus event always fires, but if you stop the code in AfterLabelEdit for example adding a breakpoint in this event, then Lost_Focus event won't fire, but this only happens when debbuging in VB IDE and you stop execution. For example, as a test, printing each event to Form when they occur, don't add breakpoints in code:
Code:
Private Sub TreeView1_AfterLabelEdit(Cancel As Integer, NewString As String)
Me.Print "TreeView1_AfterLabelEdit"
End Sub
Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)
Me.Cls
Me.Print "TreeView1_BeforeLabelEdit"
End Sub
Private Sub TreeView1_LostFocus()
Me.Print "TreeView1_LostFocus"
End Sub
So simply using a boolean variable, setting it to true on BeforeLabelEdit and cheking it's value when LostFocus() triggers should be enough for the particular case when the user moves focus away from the Treeview.
Also as an alternative, you have Validate event, that fires before LostFocus() event.
You're right about the other problem about AfterLabelEdit not firing when the label is edited and no change is done, there is no event fired when this happen. If you need to solve this particular case i think a good idea would be in the Hook process (you need to hook the Treeview) debug.print all messages processed by the control and see what messages are triggered just when you exit editing a label without making changes, you'll just see numbers in the debug window but one of them should be what you need.
Last edited by jcis; Jun 8th, 2012 at 12:45 AM.
-
Jun 8th, 2012, 09:40 PM
#4
Thread Starter
Addicted Member
Re: TreeView problem
Hi JCIS,
Thanks for your help, I was adding a node with a generic node label then invoking the StartLabelEdit, and the add node code was setting an unwanted setfocus to another control and it was delayed so it appeared the TV had a glitch. 
Ah but you mention hooking the TV is there another way other than using SetWindowLong message?
P.S. yo vivi en BSAS for cinco meses muchos anos hace
Last edited by vb_lover; Jun 8th, 2012 at 09:57 PM.
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
|