* "Sander R said:
I have problems with a listview control. Hopefully, I am
at the right usergroup, otherwise, I apologize.
Now, I'm finishing off a project where the main interface
is a tree view an two listviews. I would really like to
complete my design with a background image on the main
listview, but I cannot get it to work. I have been
ListView:
Quick and dirty, in VB.NET:
\\\
Private Const NOERROR = &H0
Private Const S_OK = &H0
Private Const S_FALSE = &H1
Private Const LVM_FIRST = &H1000
Private Const LVM_SETBKIMAGE = (LVM_FIRST + 68)
Private Const LVM_SETTEXTBKCOLOR = (LVM_FIRST + 38)
Private Const LVBKIF_SOURCE_URL = &H2
Private Const LVBKIF_STYLE_TILE = &H10
Private Const CLR_NONE = &HFFFFFFFF
Private Structure LVBKIMAGE
Public ulFlags As Int32
Public hbm As IntPtr
Public pszImage As String
Public cchImageMax As Int32
Public xOffsetPercent As Int32
Public yOffsetPercent As Int32
End Structure
Private Declare Sub CoUninitialize Lib "OLE32.DLL" ()
Private Declare Function CoInitialize Lib "OLE32.DLL" ( _
ByVal pvReserved As Int32 _
) As Int32
Private Declare Function SendMessageLong Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByRef lParam As LVBKIMAGE _
) As Int32
Private Sub SetBackground()
Dim sI As String
Dim lHDC As Int32
' Set a background image:
sI = "C:\WINDOWS\Angler.bmp"
' Set the background:
Dim tLBI As LVBKIMAGE
tLBI.pszImage = sI & ControlChars.NullChar
tLBI.cchImageMax = Len(sI) + 1
tLBI.ulFlags = LVBKIF_SOURCE_URL Or LVBKIF_STYLE_TILE
SendMessage(Me.ListView1.Handle, LVM_SETBKIMAGE, 0, tLBI)
' Set the background colour of the ListView to &HFFFFFFFF (-1)
' so it will be transparent!
SendMessageLong( _
Me.ListView1.Handle, _
LVM_SETTEXTBKCOLOR, _
0, _
CLR_NONE _
)
End Sub
Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Dim lR As Int32
'// required for using bitmaps
lR = CoInitialize(0)
SetBackground()
End Sub
///
There is no easy solution for the treeview control.