How do you set color to a tree view?
Quote from: McDonalds on May 12, 2004, 07:32 PM
How do you set color to a tree view?
You'd probably be better off placing this in general programming.
Edit: Or maybe a language specific forum.
Quote from: McDonalds on May 12, 2004, 07:32 PM
How do you set color to a tree view?
Have you looked this up? I believe it can be done with SendMessage.
[Edit]
This should answer your question. (http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=22574&lngWId=1)
Please start doing searches before you post here. I found this by simply typing 'TreeView Color' at www.planetsourcecode.com (http://www.planetsourcecode.com).
On a side note, a topic like this should go in the Visual Basic Programming forum next time. ;D
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
everything is fine but the actual nodes turn out white? the rest dont any idea?
That might just be something you have to live with. Do another search you lazy...
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
Ever try right clicking and going to properties of ur tree and taking away the PlusMinus.
Quote from: TheNewOne on May 13, 2004, 12:44 AM
Ever try right clicking and going to properties of ur tree and taking away the PlusMinus.
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
Off-Topic: why do you keep changing accounts, Gosugaming?
does anyone know the format for adding nodes using vbaltreeview6.ocx?
Have you checked vbAccelerator's documentation (http://www.vbaccelerator.com/home/VB/Code/Controls/TreeView/TreeView_Control/article.asp) for vbalTreeView6, or their TreeView demo (http://www.vbaccelerator.com/home/VB/Code/Controls/TreeView/TreeView_Control/VB6_TreeView_Demonstration.asp) yet? They're both quite useful.