Below is primarily the code used for it. Really simple, and note that I removed the transparency bg color as this actually degrades performance of the listview as stated in the MSDN listview section.
Let me know if you have any problems. I have not looked at this code in quite a long time, and seem to recall some other changes I made as well but I this should work. I have been using it for quite some time with no issues. The only exception is that you when it resizes, depending on whether or now you have auto redraw and or clip controls you may need to refresh the control. For whatever reason the listview will not update the background fully, but this is really more of an issue with how you are painting your canvas.
Public Property Get BackgroundPicture() As String BackgroundPicture = m_sPictureEnd Property'The Offset is primarily percentage based. 50% is centered ' 0% is far left, 100% is far right and so on. ' Or top and bottom Public Property Let TileBgPicture(bTile As Boolean) m_bTileBgPic = bTile PropertyChanged "TileBgPicture"End PropertyPublic Property Get TileBgPicture() As Boolean TileBgPicture = m_bTileBgPicEnd PropertyPublic Property Let BgPicXOffset(xOffset As Long) m_lBgPicXOffset = xOffset PropertyChanged "BgPicXOffset"End PropertyPublic Property Get BgPicXOffset() As Long BgPicXOffset = m_lBgPicXOffsetEnd PropertyPublic Property Let BgPicYOffset(yOffset As Long) m_lBgPicYOffset = yOffset PropertyChanged "BgPicYOffset"End PropertyPublic Property Get BgPicYOffset() As Long BgPicYOffset = m_lBgPicYOffsetEnd PropertyPublic Property Let BackgroundPicture(ByVal sURL As String)Dim tLBI As LVBKIMAGE m_sPicture = sURL If Not (m_hWnd = 0) Then tLBI.pszImage = sURL & Chr$(0) tLBI.cchImageMax = Len(sURL) + 1 If m_lBgPicXOffset <> 0 Then tLBI.xOffsetPercent = m_lBgPicXOffset End If If m_lBgPicYOffset <> 0 Then tLBI.yOffsetPercent = m_lBgPicYOffset End If If (m_bTileBgPic = False) Then tLBI.ulFlags = LVBKIF_SOURCE_URL Or LVBKIF_STYLE_NORMAL 'LVBKIF_STYLE_TILE Else tLBI.ulFlags = LVBKIF_SOURCE_URL Or LVBKIF_STYLE_TILE End If SendMessage m_hWnd, LVM_SETBKIMAGE, 0, tLBI ' Set the background colour of the ListView to &HFFFFFFFF (-1) ' so it will be transparent! 'SendMessageLong m_hWnd, LVM_SETTEXTBKCOLOR, 0, CLR_NONE ' it will perform worse with transparent color as ' indicated in the online api. do nothing leave it the same 'SendMessageLong m_hWnd, LVM_SETBKCOLOR, 0, TranslateColor(m_oBackColor) 'SendMessageLong m_hWnd, LVM_SETTEXTBKCOLOR, 0, TranslateColor(m_oBackColor) End If PropertyChanged "BackgroundPicture"End Property Public Property Get NoScrollBar() As Boolean NoScrollBar = m_bNoScrollBarEnd PropertyPublic Property Let NoScrollBar(ByVal bState As Boolean) m_bNoScrollBar = bState If bState Then pSetStyle LVS_NOSCROLL, 0 Else pSetStyle 0, LVS_NOSCROLL End If PropertyChanged "NoScrollBar"End Property
Added this to the intialize of the control:
m_bTileBgPic = False m_lBgPicXOffset = 0 m_lBgPicYOffset = 0
To Read Properties:
NoColumnHeaders = PropBag.ReadProperty("NoColumnHeaders", False) TileBgPicture = PropBag.ReadProperty("TileBgPicture", False) BgPicXOffset = PropBag.ReadProperty("BgPicXOffset", 0) BgPicYOffset = PropBag.ReadProperty("BgPicYOffset", 0)
PropBag.WriteProperty "TileBgPicture", TileBgPicture, False PropBag.WriteProperty "BgPicXOffset", BgPicXOffset, 0 PropBag.WriteProperty "BgPicYOffset", BgPicYOffset, 0PropBag.WriteProperty "NoColumnHeaders", NoColumnHeaders, False