;Autor: Fluid Byte ;http://www.purebasic.fr/english/viewtopic.php?p=294389#p294389 EnableExplicit #LST_Ownerdraw = 101 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 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) DrawIcon_(*lpdis\hdc,2,*lpdis\rcItem\top + 2,*lbex\Icon) GetObject_(SendMessage_(*lpdis\hWndItem,#WM_GETFONT,0,0),SizeOf(LOGFONT),lplf) lplf\lfHeight = -MulDiv_(12,GetDeviceCaps_(*lpdis\hdc,#LOGPIXELSY),72) hfntTitle = CreateFontIndirect_(lplf) SetBkMode_(*lpdis\hdc,#TRANSPARENT) hfntPrevious = SelectObject_(*lpdis\hdc,hfntTitle) TextOut_(*lpdis\hdc,40,*lpdis\rcItem\top + 2,*lbex\title,lstrlen_(*lbex\title)) SelectObject_(*lpdis\hdc,hfntPrevious) TextOut_(*lpdis\hdc,40,*lpdis\rcItem\top + 20,*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 Define a If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) ListViewGadget(#LST_Ownerdraw,10,10,480,230,#LBS_OWNERDRAWFIXED) SendMessage_(GadgetID(#LST_Ownerdraw),#LB_SETITEMHEIGHT,0,36) SetWindowCallback(@WindowCallback()) LoadImage(1,#PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico") For a=1 To 5 AddLBItemEx(#LST_Ownerdraw,-1,ImageID(1),"Maintext "+Str(a),"Subtext "+Str(a)) Next Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) ; CursorPosition = 2 ; Folding = - ; EnableUnicode ; EnableXP ; EnableUser ; EnableCompileCount = 0 ; EnableBuildCount = 0