Valhalla Legends Forums Archive | Visual Basic Programming | Treeviews

AuthorMessageTime
McDonalds
How do you set color to a tree view?
May 13, 2004, 12:32 AM
hismajesty
[quote author=McDonalds link=board=17;threadid=6779;start=0#msg59883 date=1084408370]
How do you set color to a tree view?
[/quote]

You'd probably be better off placing this in general programming.

Edit: Or maybe a language specific forum.
May 13, 2004, 12:38 AM
Eli_1
[quote author=McDonalds link=board=17;threadid=6779;start=0#msg59883 date=1084408370]
How do you set color to a tree view?
[/quote]
Have you looked this up? I believe it can be done with SendMessage.

[Edit]
This should answer your question.
Please start doing searches before you post here. I found this by simply typing 'TreeView Color' at www.planetsourcecode.com.

On a side note, a topic like this should go in the Visual Basic Programming forum next time. ;D
May 13, 2004, 12:38 AM
McDonalds
[code]
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&
Private Sub Command1_Click()
Dim nodx As Node
Set nodx = tv1.Nodes.Add(, , "R", "Global")
Set nodx = tv1.Nodes.Add("R", tvwChild, "R1", "Battle.Net")
Set nodx = tv1.Nodes.Add("R1", tvwChild, "R3", "Connection")
Set nodx = tv1.Nodes.Add("R", tvwChild, "R2", "Bot")
End Sub

Private Sub Command2_Click()
Dim lngStyle As String
Call SendMessage(tv1.hWnd, _
TVM_SETBKCOLOR, _
0, _
ByVal RGB(0, 0, 0))

lngStyle = GetWindowLong(tv1.hWnd, GWL_STYLE)

Call SetWindowLong(tv1.hWnd, _
GWL_STYLE, _
lngStyle - TVS_HASLINES)

Call SetWindowLong(tv1.hWnd, GWL_STYLE, lngStyle)

End Sub



Private Sub Form_Load()

End Sub

Private Sub tv1_NodeClick(ByVal Node As MSComctlLib.Node)
If tv1.SelectedItem.Text = "Connection" Then
Frame1.Visible = True
ElseIf tv1.SelectedItem.Text = "Bot" Then
Frame1.Visible = False
End If

End Sub
[/code]

everything is fine but the actual nodes turn out white? the rest dont any idea?
May 13, 2004, 1:12 AM
Eli_1
That might just be something you have to live with. Do another search you lazy...
May 13, 2004, 1:21 AM
McDonalds
i changed the forcolor and all that i did the search but there is still a small display of a square to the very very very very left of the nodes
May 13, 2004, 2:06 AM
TheNewOne
Ever try right clicking and going to properties of ur tree and taking away the PlusMinus.
May 13, 2004, 5:44 AM
McDonalds
[quote author=TheNewOne link=board=31;threadid=6779;start=0#msg59948 date=1084427083]
Ever try right clicking and going to properties of ur tree and taking away the PlusMinus.
[/quote]

ever try i want them there?

i think i need to do sendmessage again like i did for the background but i know its not going to be TVM_SETFORECOLOR like it is TVM_SETBKCOLOR for the background
May 13, 2004, 7:45 PM
Fr0z3N
Off-Topic: why do you keep changing accounts, Gosugaming?
May 13, 2004, 11:29 PM
GoSuGaMING
does anyone know the format for adding nodes using vbaltreeview6.ocx?
May 14, 2004, 11:56 PM
Stealth
Have you checked vbAccelerator's documentation for vbalTreeView6, or their TreeView demo yet? They're both quite useful.
May 15, 2004, 6:25 AM

Search