Results 1 to 9 of 9

Thread: Who is stupid ??

  1. #1

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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 ?

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Option Explicit
    2.  
    3.       Private Declare Function SendMessage Lib "User32" _
    4.          Alias "SendMessageA" _
    5.          (ByVal hWnd As Long, _
    6.          ByVal wMsg As Long, _
    7.          ByVal wParam As Long, _
    8.          lParam As Long) As Long
    9.  
    10.       Private Declare Function GetWindowLong Lib "User32" _
    11.          Alias "GetWindowLongA" _
    12.          (ByVal hWnd As Long, _
    13.          ByVal nIndex As Long) As Long
    14.  
    15.       Private Declare Function SetWindowLong Lib "User32" _
    16.          Alias "SetWindowLongA" _
    17.          (ByVal hWnd As Long, _
    18.          ByVal nIndex As Long, _
    19.          ByVal dwNewLong As Long) As Long
    20.  
    21.       Private Const GWL_STYLE = -16&
    22.       Private Const TVM_SETBKCOLOR = 4381&
    23.       Private Const TVM_GETBKCOLOR = 4383&
    24.       Private Const TVS_HASLINES = 2&
    25.  
    26.       Dim frmlastForm As Form
    27.  
    28.       Private Sub Form_Load()
    29.           Dim nodX As Node
    30.           Set nodX = TreeView1.Nodes.Add(, , "R", "Root")
    31.           Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")
    32.           Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")
    33.           Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")
    34.           Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")
    35.           nodX.EnsureVisible
    36.           TreeView1.style = tvwTreelinesText ' Style 4.
    37.           TreeView1.BorderStyle = vbFixedSingle
    38.       End Sub
    39.  
    40.       Private Sub Command1_Click()
    41.          Dim lngStyle As Long
    42.  
    43.          Call SendMessage(TreeView1.hWnd, _
    44.                            TVM_SETBKCOLOR, _
    45.                            0, _
    46.                            ByVal RGB(255, 0, 0))  'Change the background
    47.                                                   'color to red.
    48.  
    49.       ' Now reset the style so that the tree lines appear properly
    50.          lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
    51.          Call SetWindowLong(TreeView1.hWnd, _
    52.                            GWL_STYLE, _
    53.                            lngStyle - TVS_HASLINES)
    54.          Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle)
    55.       End Sub

    found it in the msdn.. maybe it can help you get that color
    -= a peet post =-

  3. #3
    chenko
    Guest
    A: You

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    oh ... I missed the question

    I refuse to answer it!!
    -= a peet post =-

  5. #5
    chenko
    Guest
    me too

  6. #6

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Peet,

    I must be doing something wrong. I looked in MSDN and could not find the example you posted?

    What was your search criteria?

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    sorry, don't remember...

    its been a while since this post started out...
    -= a peet post =-

  9. #9
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Found it afterall

    search for Q178491 in MSDN and it will show u the sample listed above

    hope that helps
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width