Hi all! Little question:
i am trying to set a background image in a ListView control, i searched in this board and i've found that i have to use the message LVM_SETBKIMAGE. I use it but it never works :-( The problem is: i set the fields of LVBKIMAGE in this way:
lvbkimage.xOffsetPercent = 100;
lvbkimage.yOffsetPercent = 100;
lvbkimage.hbm = hbit;
and then i use sendmessage, but it always doesnt work. hbit is a valid bitmap, i am sure because i use it elsewhere in the program and it works, the msdn reference says the hbm member is not currently used, but if it is not used how do i specify an image? only whith pszText member? But i dont want to set a path or url!
Can anyone help me?
Thanx a lot
Posted on 2002-05-23 05:15:56 by AndreaGeddon
Looked at MSDN and several other sides related to this. You are correct in that all the references I have found state that the hbm field of the LVBKIMAGE structure is not currently in use.

I also looked at several example codes from Visual Basic on this topic and *all* of them use the LVBKIF_SOURCE_URL flag to set it from file.

Just as a side note:
If you change your mind about using that flag and a seperate BM file, dont forget to make calls to CoInitialize or OleInitialize before sending the SendMessage message to the ListView. Has something to do with the control using OLE COM to manipulate the background. And when you exit the process you will need to call CoUninitialize or OleUninitialize.

Also for the image to display correctly it would also be prudent to call SendMessage with LVM_SETTEXTBKCOLOR, 0, CLR_NONE to make the list items background transparent.
Posted on 2002-05-23 08:42:15 by Graebel
Here's part of my program that use listview background bitmap, and it works just fine.

Good luck


adrBit db "mybmp.bmp",0
buffer5 db 256 dup(?),0
buffer40 db 1 dup (?),0

WndProc proc hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

szText Fiche1," .BMP file missing, ",0

.if uMsg==WM_CREATE

invoke CoInitialize,NULL

invoke SearchPath,NULL,addr adrBit,NULL,128,ADDR buffer5,addr buffer40

.if eax == 0
invoke MessageBox,hWin,addr Fiche1,NULL,MB_OK
invoke EndDialog,hWin,NULL
INVOKE ExitProcess,0
lea eax,buffer5
mov lvb.pszImage,eax
mov lvb.cchImageMax,128
mov lvb.xOffsetPercent,100
mov lvb.yOffsetPercent,100
invoke SendMessage,hList,LVM_SETBKIMAGE,0,addr lvb
invoke SendMessage,hList, LVM_SETTEXTBKCOLOR, 0, CLR_NONE
Posted on 2002-05-23 08:49:52 by Guy
You know. I have not tested this (and dont really plan to) but maybe we can get around this.

I was thinking about the WM_ERASEBKGND message. This is sent when a control needs to erase the background for a repaint yes? Well it passes the DC in the wParam so it might be possible to tile a bitmap into this DC to achieve the same effect...

Just a thought.
Posted on 2002-05-23 09:35:47 by Graebel
My foolish example
Posted on 2002-05-23 11:31:15 by The Svin