|
-
Aug 2nd, 2001, 07:17 AM
#1
Thread Starter
Randalf the Red
Who is stupid ??
Me, the Treeview control or the Windows API ?
I ran a brief search on changing the background colour of the Treeview control on the forum and got a small SendMessage API function call to do the job.
I pasted the declaration and the constants in my code and ran the application. The background colour did change, but it seems that there are just about 3 different colours it can take.
How do I set the backcolor of the TreeView control to be the one I have set for my textbox? Remember I set the colour of the TextBox control using the colour palette.
I tried changing the RGB function parameters, but all combinations seem to give me only two or three colours. Can someone please help me in setting the desired colour as the background colour of a TreeView control ?
.
-
Aug 2nd, 2001, 07:24 AM
#2
-= B u g S l a y e r =-
VB 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&
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, 0, 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
found it in the msdn.. maybe it can help you get that color
-
Aug 2nd, 2001, 07:28 AM
#3
A: You
-
Aug 2nd, 2001, 07:36 AM
#4
-= B u g S l a y e r =-
oh ... I missed the question
I refuse to answer it!!
-
Aug 2nd, 2001, 07:41 AM
#5
me too
-
Aug 6th, 2001, 02:02 AM
#6
Thread Starter
Randalf the Red
Well ...
Originally posted by chenko
A: You
The 0th option was Che..
But let it be. Thanks, peet, I shall give it a try.
And Simon, another absurd comment from you as you had already answered the question in your earlier post.
.
-
Aug 6th, 2001, 03:38 AM
#7
Fanatic Member
Peet,
I must be doing something wrong. I looked in MSDN and could not find the example you posted?
What was your search criteria?
-
Aug 6th, 2001, 03:46 AM
#8
-= B u g S l a y e r =-
sorry, don't remember... 
its been a while since this post started out...
-
Aug 6th, 2001, 03:48 AM
#9
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|