[Windows] Listview background image
Posted: Wed Mar 12, 2014 12:32 pm
Hi @all,
I'm trying to set a background image to a listview (PB: listicon). But it won't work
I'm pretty sure I got the LVBKIMAGE structure right, I also implemented the CoInitialize_() but still the picture's a no show.
Where am I wrong?? I'm still confused with the windows datatypes. The LVBKIMAGE structure sets the bitmap handle (hbm) to long, which is 32 bit (afaik). But the handles on a 64bit OS should be 64bit, right (I'm using Win7 64)?
Thanx!
Fenix
I'm trying to set a background image to a listview (PB: listicon). But it won't work
I'm pretty sure I got the LVBKIMAGE structure right, I also implemented the CoInitialize_() but still the picture's a no show.
Code: Select all
Structure LVBKIMAGE
ulFlags.l ; ULONG
hbm.l ; HBITMAP
pszImage.l ; LPSTR
cchImageMax.l ; UINT -> long
xOffsetPercent.l ; INT
yOffsetPercent.l ; INT -> long
EndStructure
; LV BACKGROUND IMAGE
#LVBKIF_SOURCE_NONE = $0
#LVBKIF_SOURCE_HBITMAP = $1
#LVBKIF_SOURCE_URL = $2
#LVBKIF_STYLE_NORMAL = $0
#LVBKIF_TYPE_WATERMARK = $10000000
#LVBKIF_FLAG_ALPHABLEND = $20000000
Global _lvBkImage.LVBKIMAGE
Procedure listviewSetBackgroundImage(iGadget.i, handleImage.i)
; --- sets a background image (ihandleImage) to a listview (iGadget)
Debug SizeOf(LVBKIMAGE)
Debug "setting lv bkimage"
FillMemory(@_lvBkImage, SizeOf(LVBKIMAGE)) ; clear the structure
_lvBkImage\ulFlags = #LVBKIF_SOURCE_HBITMAP | #LVBKIF_STYLE_NORMAL
_lvBkImage\hbm = handleImage
_lvBkImage\xOffsetPercent = 50
_lvBkImage\yOffsetPercent = 50
SendMessage_(iGadget, #LVM_SETBKIMAGE, #Null, @_lvBkImage)
EndProcedure
If OpenWindow(0, 10, 10, 500, 400, "LV - BK IMAGE", #PB_Window_SystemMenu |#PB_Window_WindowCentered |#PB_Window_ScreenCentered)
handleListView.i = ListIconGadget(#PB_Any, 10, 10, 490, 390, "LV TEST", 100)
CoInitialize_(#Null)
UsePNGImageDecoder()
handleImage.i = CatchImage(#PB_Any, ?IMAGE, ?IMAGEEND - ?IMAGE)
If handleImage
listviewSetBackgroundImage(GadgetID(handleListView), ImageID(handleImage))
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
CoUninitialize_()
EndIf
End
IMAGE:
IncludeBinary "c:\temp\picture.png"
IMAGEEND:Thanx!
Fenix