Colouring a ListIconGadget header
Posted: Sun Nov 05, 2006 9:32 am
I found code in the forums to colour ListIconGadget headings but when I go past 2 callbacks to colour 2 different gadgets, I get syntax errors, even though there is none.
is there any way to make the below code generic so it can be used on as many ListIcons as I need? (The below one is for my first gadget)
is there any way to make the below code generic so it can be used on as many ListIcons as I need? (The below one is for my first gadget)
Code: Select all
Procedure AddressListSubclassed(hwnd, msg, wparam, lparam)
Protected hdi.hd_item
result = CallWindowProc_(form\AddressCallback, hwnd, msg, wparam, lparam); Used for my first gadget
Select msg
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 ; Get header text.
text$ = Space(100)
hdi\mask = #HDI_TEXT
hdi\psztext = @text$
hdi\cchtextmax = Len(text$)
SendMessage_(form\hAddresslist, #HDM_GETITEM, *pnmcd\dwItemSpec, hdi) ; Check button state.
If *pnmcd\uItemState & #CDIS_SELECTED
DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH | #DFCS_PUSHED) ; Offset text because of the selected button.
InflateRect_(*pnmcd\rc, -1, -1)
Else
DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH)
EndIf ; Draw background. ; Here we alternate red text on blue background.
InflateRect_(*pnmcd\rc, -1, -1)
SetBkMode_(*pnmcd\hdc, #TRANSPARENT)
;If *pnmcd\dwItemSpec & 1
FillRect_(*pnmcd\hdc, *pnmcd\rc, Colour)
SetTextColor_(*pnmcd\hdc, $000000)
;Else
; FillRect_(*pnmcd\hdc, *pnmcd\rc, Colour)
; SetTextColor_(*pnmcd\hdc, $000000)
;EndIf
DrawText_(*pnmcd\hdc, @text$, Len(text$), *pnmcd\rc, #DT_LEFT | #DT_VCENTER | #DT_END_ELLIPSIS)
result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
form\hAddresslist = SendMessage_(GadgetID(#Gadget_listform_names), #LVM_GETHEADER, 0, 0) ; Subclass ListIcon so we can customdraw the header text
form\AddressCallback = SetWindowLong_(GadgetID(#Gadget_listform_names), #GWL_WNDPROC, @AddressListSubclassed())