• Welcome to Valhalla Legends Archive.
 

Treeviews

Started by McDonalds, May 12, 2004, 07:32 PM

Previous topic - Next topic

McDonalds

How do you set color to a tree view?

hismajesty

#1
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.

Eli_1

#2
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.
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

McDonalds


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?

Eli_1

That might just be something you have to live with. Do another search you lazy...

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

TheNewOne

Ever try right clicking and going to properties of ur tree and taking away the PlusMinus.

McDonalds

#7
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

Fr0z3N

Off-Topic: why do you keep changing accounts, Gosugaming?

GoSuGaMING

does anyone know the format for adding nodes using vbaltreeview6.ocx?

Stealth

#10
Have you checked vbAccelerator's documentation for vbalTreeView6, or their TreeView demo yet? They're both quite useful.
- Stealth
Author of StealthBot