The Hobo
Jul 3rd, 2001, 05:44 PM
Is there some way to use API and maybe the SendMessage to modify the hottracking style in a treeview?
To be more specific, I want to call a background color for the hottracking style, or atleast change the font from blue to another color and from underlie to bold.
Can this be done, and how?
crispin
Jul 4th, 2001, 02:30 AM
on what event - what message - do you want to change the background color?
crispin
Jul 4th, 2001, 02:44 AM
heres the code for the background color anyway - from MSDN:
Option Explicit
Private Declare Function SendMessage Lib "User32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Long) As Long
Private Declare Function GetWindowLong Lib "User32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "User32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = -16&
Private Const TVM_SETBKCOLOR = 4381&
Private Const TVM_GETBKCOLOR = 4383&
Private Const TVS_HASLINES = 2&
Dim frmlastForm As Form
Private Sub Form_Load()
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(, , "R", "Root")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")
nodX.EnsureVisible
TreeView1.Style = tvwTreelinesText ' Style 4.
TreeView1.BorderStyle = vbFixedSingle
End Sub
Private Sub Command1_Click()
Dim lngStyle As Long
Call SendMessage(TreeView1.hWnd, _
TVM_SETBKCOLOR, _
0, _
ByVal RGB(255, 150, 0)) 'Change the background
'color to red.
' Now reset the style so that the tree lines appear properly
lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
Call SetWindowLong(TreeView1.hWnd, _
GWL_STYLE, _
lngStyle - TVS_HASLINES)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle)
End Sub
The Hobo
Jul 4th, 2001, 11:21 AM
I just want to change the background color of the node only as the mouse moves over it, like hot tacking. That's why I wanted to know if it was possible to change the hottracking styles?