I have an image behind the ListIconGadget() and I need the ListIconGadget to be active to use it. I also wouldn't mind to maybe make the gadget a bit transparent if possible, but not necessary. Mainly just need it active. How would I go about making the gadget active to use it?
I found the following code here on the forums and added and or changed some of the original code to suit my needs. Mainly to make the ListIconGadget headers able to be colored other than grey.
The credit for the original code I believe goes to srod
https://mega.nz/file/t90CmRxJ#mAuxbMdeU ... zXVAU32TD8
Code: Select all
#LVM_GETHEADER = #LVM_FIRST + 31
; Globals
Global oldListIconCallback, hHeader, brush
brush=CreateSolidBrush_(#Yellow)
Procedure SubclassedListIcon(hWnd, uMsg, wParam, lParam)
Protected hdi.hd_item
result = CallWindowProc_(oldListIconCallback, hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_NOTIFY
*pnmh.NMHDR = lparam
;--> Get handle to ListIcon header control
If *pnmh\code = #NM_CUSTOMDRAW
*pnmcd.NMCUSTOMDRAW = lparam
;--> Determine drawing stage
Select *pnmcd\dwDrawStage
Case #CDDS_PREPAINT
result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
text$=GetGadgetItemText(0, -1, *pnmcd\dwItemSpec)
If *pnmcd\uItemState & #CDIS_SELECTED
DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH|#DFCS_PUSHED)
*pnmcd\rc\left+2 : *pnmcd\rc\top+1
Else
DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH)
EndIf
*pnmcd\rc\bottom-1 : *pnmcd\rc\right-1
SetBkMode_(*pnmcd\hdc,#TRANSPARENT)
If *pnmcd\dwItemSpec&1
FillRect_(*pnmcd\hdc, *pnmcd\rc, brush)
SetTextColor_(*pnmcd\hdc, #Blue)
Else
FillRect_(*pnmcd\hdc, *pnmcd\rc, brush)
SetTextColor_(*pnmcd\hdc, #Red)
EndIf
If *pnmcd\rc\right>*pnmcd\rc\left
DrawText_(*pnmcd\hdc, @text$, Len(text$), *pnmcd\rc, #DT_CENTER|#DT_VCENTER|#DT_SINGLELINE|#DT_END_ELLIPSIS)
EndIf
result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
;InitSprite()
UsePNGImageDecoder()
If OpenWindow(0, 0, 0, 1024, 768, "", #PB_Window_ScreenCentered | #PB_Window_BorderLess)
ImgFile = LoadImage(0, "Roster.png", 0)
ImageGadget(1, 0, 0, 1024, 768, ImgFile)
ListIconGadget(0, 175, 150, 700, 500, "No.", 30, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
hHeader = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
;Subclass ListIcon so we can customdraw the header text
oldListIconCallback = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @SubclassedListIcon())
;Add 10 more columns.
;For i = 1 To 13
AddGadgetColumn(0, 1, "Player names", 150)
AddGadgetColumn(0, 2, "Pos", 50)
AddGadgetColumn(0, 3, "KP", 35)
AddGadgetColumn(0, 4, "TA", 35)
AddGadgetColumn(0, 5, "PS", 35)
AddGadgetColumn(0, 6, "SH", 35)
AddGadgetColumn(0, 7, "PC", 35)
AddGadgetColumn(0, 8, "HE", 35)
AddGadgetColumn(0, 9, "ST", 35)
AddGadgetColumn(0, 10, "SP", 35)
AddGadgetColumn(0, 11, "BC", 35)
AddGadgetColumn(0, 12, "FT", 35)
AddGadgetColumn(0, 13, "PF", 35)
;Next
;Add some data
For b=0 To 99; Add 100 rows.
AddGadgetItem(0,-1,"")
Next
For i = 0 To 99
For j = 0 To 50
SetGadgetItemText(0,i,Str(i+j),j)
Next j
Next i
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteObject_(brush)
EndIf