• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

TreeView - Change Back Color

Any idea how to change the background color of a TreeView Control in VB6 Ent?
0
selectgt
Asked:
selectgt
  • 2
1 Solution
 
kokolokoCommented:
Sure:

'In your declarations:
Private Const TV_FIRST As Long = &H1100
Private Const TVM_SETBKCOLOR As Long = (TV_FIRST + 29)
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long


'In the code to change back color:
SendMessageLong TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal color&

hWnd is the handle of the treeview.
color is the color expressed as COLORREF.


If you're using OLE_COLOR (VB defaults), it is necessary convert it first to COLORREF using OleTranslateColor
Private Declare Function OleTranslateColor Lib "olepro32.dll" (ByVal OLE_COLOR As Long, ByVal HPALETTE As Long, pccolorref As Long) As Long
HPALETTE = 0
0
 
selectgtAuthor Commented:
Thank you very much kind sir.
0
 
kokolokoCommented:
Glad I could help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now