Font for one specific ListIconGadget column?
Posted: Wed Oct 17, 2018 12:42 pm
I've got this code where I want the second ListIconGadget's second column to be "Times New Roman" font. But as you can see, both columns of the second ListIconGadget are that font, instead of the first column being the default system font. What am I missing?



Code: Select all
Global tnr_font=LoadFont(1,"TIMES NEW ROMAN",12,#PB_Font_Bold |#PB_Font_Italic)
Procedure WinCallbackProc(hWnd,uMsg,wParam,lParam)
Protected result,col
Protected *pnmh.NMHDR,*LVCDHeader.NMLVCUSTOMDRAW
result=#PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
*pnmh.NMHDR=lParam
Select *pnmh\code
Case #NM_CUSTOMDRAW
*LVCDHeader.NMLVCUSTOMDRAW=lParam
Select *LVCDHeader\nmcd\dwDrawStage
Case #CDDS_SUBITEMPREPAINT
col=*LVCDHeader\iSubItem
If col=2 And hWnd=GadgetID(2)
SelectObject_(*LVCDHeader\nmcd\hDC,tnr_font)
EndIf
result=#CDRF_NEWFONT
EndSelect
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0,200,200,600,350,"",#PB_Window_SystemMenu)
ListIconGadget(1,50,50,500,100,"Column 1",140)
AddGadgetColumn(1,1,"Column 2",300)
AddGadgetItem(1,-1,"one"+#LF$+"one")
AddGadgetItem(1,-1,"two"+#LF$+"two")
ListIconGadget(2,50,200,500,100,"Column 1",140)
AddGadgetColumn(2,1,"Column 2",300)
SetGadgetFont(2,#PB_Default) : AddGadgetItem(2,-1,"one"+#LF$+"one")
SetGadgetFont(2,tnr_font) : AddGadgetItem(2,-1,"two"+#LF$+"two")
SetWindowCallback(@WinCallbackProc())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf