Don't think it works with 'standard' flags - so custom drawing has do be done (once again)...
Code: Select all
#LST_Ownerdraw = 1
Structure LBITEMEX
Icon.i
Title.i
Text.i
EndStructure
Procedure WindowCallback(hWnd,uMsg,wParam,lParam)
Select uMsg
Case #WM_DRAWITEM
Protected *lpdis.DRAWITEMSTRUCT = lParam
Protected *lbex.LBITEMEX = GetGadgetItemData(#LST_Ownerdraw,*lpdis\itemID)
Protected hbrFace, hdcMem, lplf.LOGFONT, hfntPrevious, hfntTitle
; Draw item rectangle (normal/highlighted)
If *lpdis\itemState & #ODS_SELECTED
hbrFace = CreateSolidBrush_(GetSysColor_(#COLOR_HIGHLIGHT))
FillRect_(*lpdis\hdc,*lpdis\rcItem,hbrFace)
DrawFocusRect_(*lpdis\hdc,*lpdis\rcItem)
SetTextColor_(*lpdis\hdc,GetSysColor_(#COLOR_HIGHLIGHTTEXT))
Else
hbrFace = CreateSolidBrush_(GetSysColor_(#COLOR_WINDOW))
FillRect_(*lpdis\hdc,*lpdis\rcItem,hbrFace)
SetTextColor_(*lpdis\hdc,GetSysColor_(#COLOR_WINDOWTEXT))
EndIf
DeleteObject_(hbrFace)
; Draw the icon
DrawIcon_(*lpdis\hdc,8,*lpdis\rcItem\top + 8,*lbex\Icon)
; Create large font
GetObject_(SendMessage_(*lpdis\hWndItem,#WM_GETFONT,0,0),SizeOf(LOGFONT),lplf)
lplf\lfHeight = -MulDiv_(12,GetDeviceCaps_(*lpdis\hdc,#LOGPIXELSY),72)
hfntTitle = CreateFontIndirect_(lplf)
; Draw the title / text
SetBkMode_(*lpdis\hdc,#TRANSPARENT)
hfntPrevious = SelectObject_(*lpdis\hdc,hfntTitle)
TextOut_(*lpdis\hdc,60,*lpdis\rcItem\top + 2,*lbex\title,lstrlen_(*lbex\title))
SelectObject_(*lpdis\hdc,hfntPrevious)
TextOut_(*lpdis\hdc,60,*lpdis\rcItem\top + 28,*lbex\text,lstrlen_(*lbex\text))
DeleteObject_(hfntTitle)
ProcedureReturn #True
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure AddLBItemEx(Gadget,Position,Icon,Title$,Text$)
Protected *lbex.LBITEMEX = AllocateMemory(SizeOf(LBITEMEX)), Index
*lbex\Icon = Icon
CompilerIf #PB_Compiler_Unicode
*lbex\Title = AllocateMemory(Len(Title$) * 2 + 2)
*lbex\Text = AllocateMemory(Len(Text$) * 2 + 2)
CompilerElse
*lbex\Title = AllocateMemory(Len(Title$) + 1)
*lbex\Text = AllocateMemory(Len(Text$) + 1)
CompilerEndIf
PokeS(*lbex\Title,Title$)
PokeS(*lbex\Text,Text$)
Index = SendMessage_(GadgetID(Gadget),#LB_ADDSTRING,0,"")
SetGadgetItemData(Gadget,Index,*lbex)
EndProcedure
OpenWindow(0,0,0,360,300,"°v°",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(#LST_Ownerdraw,0,0,360,300,#LBS_OWNERDRAWFIXED)
SendMessage_(GadgetID(#LST_Ownerdraw),#LB_SETITEMHEIGHT,0,60)
SetWindowCallback(@WindowCallback())
;LoadImage(0,"..\Data\1.ico")
CreateImage(0,32,32,32,#Red)
NewIcon.ICONINFO
NewIcon\fIcon = #True
NewIcon\hbmMask = ImageID(0)
NewIcon\hbmColor = ImageID(0)
Icon=CreateIconIndirect_(@NewIcon)
AddLBItemEx(#LST_Ownerdraw,-1,icon,"Item Caption #1","This is the subtext for the item")
AddLBItemEx(#LST_Ownerdraw,-1,icon,"Item Caption #2","This is the subtext for the item")
AddLBItemEx(#LST_Ownerdraw,-1,icon,"Item Caption #3","This is the subtext for the item")
SetActiveGadget(#LST_Ownerdraw)
SetGadgetState(#LST_Ownerdraw,0)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow