Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

treeview and icon from imagelist1 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
425
IT
my old code:

Code:
 Private Sub FILL_TREEVIEW()

    Dim M As Long
    Dim D As Long
    Dim nodRoot As Node
    Dim nodMonth As Node

    With Me.TreeView1

        .Nodes.Clear
        
        Set Me.TreeView1.ImageList = ImageList1
        
        .LineStyle = tvwRootLines
        .Style = tvwTreelinesPlusMinusText
        Set nodRoot = .Nodes.Add(Text:=ANNO)
        
        For M = 1 To 12
        
            Set nodMonth = .Nodes.Add(Relative:=nodRoot, _
                                      Relationship:=tvwChild, _
                                      Text:=Format(M, "00") & "-" & UCase(MonthName(M)))
                                      
            For D = 1 To Day(DateSerial(ANNO, M + 1, 0))
                .Nodes.Add Relative:=nodMonth, _
                           Relationship:=tvwChild, _
                           Text:=UCase(Format(DateSerial(ANNO, M, D), "dd/mm/yyyy")) & "-" & UCase(Format(DateSerial(ANNO, M, D), "dddd"))
            
            Next D
            
        Next M

    End With

End Sub

how to assign icon inde=1 to the mopnth node, and icon index=2 for each days of month, all during the code fill treeview.
Tks.
 
Code:
Private Sub FILL_TREEVIEW()
    Dim M As Long
    Dim D As Long
    Dim nodRoot As Node
    Dim nodMonth As Node

    With Me.TreeView1

        
        .Nodes.Clear
        
        Set Me.TreeView1.ImageList = ImageList1
        
[COLOR=green]        ' Set these at design time rather than runtime to avoid issues
'        .LineStyle = tvwRootLines
'        .Style = tvwTreelinesPlusMinusText[/color]
        Set nodRoot = .Nodes.Add(Text:=ANNO)
        
        For M = 1 To 12
        
            Set nodMonth = .Nodes.Add(Relative:=nodRoot, _
                                      Relationship:=tvwChild, _
                                      Text:=Format(M, "00") & "-" & UCase(MonthName(M))[b][COLOR=#EF2929], _
                                      Image:=1[/color][/b])
                                      
                                      
                                      
            For D = 1 To Day(DateSerial(ANNO, M + 1, 0))
                .Nodes.Add Relative:=nodMonth, _
                           Relationship:=tvwChild, _
                           Text:=UCase(Format(DateSerial(ANNO, M, D), "dd/mm/yyyy")) & "-" & UCase(Format(DateSerial(ANNO, M, D), "dddd"))[COLOR=#EF2929][b], _
                           Image:=2[/b][/color]
            
            Next D
            
        Next M

    End With

End Sub
 
A few points

1) You should ask a new question in a new thread
2) The code you sent is broken
3) Not quite sure I even understand the question

That being said, try the following minor change to your TreeView1_MouseMove event:

Code:
Private Sub TreeView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    [COLOR=#EF2929]Static OldNODX As Node[/color]
    
    Dim NODX As MSComctlLib.Node
    Set NODX = TreeView1.HitTest(x, y)

    If NODX Is Nothing Then

        If m_bInLable Then
            m_bInLable = False
            TT.Title = ""
            TT.TipText = ""
            TT.Destroy
        End If

    Else
        [COLOR=#EF2929]If OldNODX Is Nothing Then Set OldNODX = NODX
        If NODX <> OldNODX Then
            Set OldNODX = NODX[/color]
            TT.Title = "INFO"
            TT.TipText = NODX
            TT.Create Me.TreeView1.hwnd
        End If

    End If

End Sub
 
strong, tks work perfect...

but if i move the mouse on the bigroot to for the first time, in my case 2022, the code dont show the balloon.(!?)
if i move the cursor on one nodes, for the first time, work perfect, bho....
 
Code:
Private Sub TreeView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    Static OldNODX As Node
    
    Dim NODX As MSComctlLib.Node
    Set NODX = TreeView1.HitTest(x, y)

    If NODX Is Nothing Then

        If m_bInLable Then
            m_bInLable = False
            TT.Title = ""
            TT.TipText = ""
            TT.Destroy
        End If

    Else
        [COLOR=#EF2929]If OldNODX Is Nothing Then Set OldNODX = TreeView1.Nodes(TreeView1.Nodes.Count)[/color][COLOR=green] ' This is a crude workaround for this specific case to deal with VB's lack of boolean short-circuit[/color]
        If NODX <> OldNODX Then
            Set OldNODX = NODX
            TT.Title = "INFO"
            TT.TipText = NODX
            TT.Create Me.TreeView1.hwnd
        End If

    End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top