ListIconGadget With some Callback code(Window) problem
Posted: Wed Dec 19, 2018 4:56 pm
Change Font types in and listicongadget. but for some reason its not working. I found some code and copied that but for some reasons It does not work as intended. Any idea whats going on?
Lines with the text "A Bold Statement" should be bold, the others not
Lines with the text "A Bold Statement" should be bold, the others not
Code: Select all
EnableExplicit
#PD_GROUP_LENGTH = 6
#TOTALSIZE = 60
Global.i Dim ViewSkillIndexValue(#PD_GROUP_LENGTH)
Global.i RegularFont = LoadFont(#PB_Any, "Arial", 9)
Global.i BoldFont = LoadFont(#PB_Any, "Arial", 9, #PB_Font_Bold)
Procedure lvwSkillCB(Window.i, Message.i, wParam.i, lParam.i)
Protected.i i
Protected *NMLVCustomDraw.NMLVCUSTOMDRAW
Debug "Running"
If Message = #WM_NOTIFY
*NMLVCustomDraw = lParam
If *NMLVCustomDraw\nmcd\hdr\code = #NM_CUSTOMDRAW
;If *NMLVCustomDraw\nmcd\hdr\hWndFrom = GadgetID(GameListIconListViewSkill) And *NMLVCustomDraw\nmcd\hdr\code = #NM_CUSTOMDRAW
Select *NMLVCustomDraw\nmcd\dwDrawStage
Case #CDDS_PREPAINT
ProcedureReturn #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
ProcedureReturn #CDRF_NOTIFYSUBITEMDRAW
Case #CDDS_ITEMPREPAINT | #CDDS_SUBITEM
Repeat
If ViewSkillIndexValue(i) = *NMLVCustomDraw\nmcd\dwItemSpec ; *NMLVCustomDraw\iSubItem *NMLVCustomDraw\nmcd\dwItemSpec
SelectObject_(*NMLVCustomDraw\nmcd\hDC, FontID(BoldFont))
If i = #PD_GROUP_LENGTH
SelectObject_(*NMLVCustomDraw\nmcd\hDC, FontID(RegularFont))
Break
EndIf
EndIf
i + 1
ForEver
ProcedureReturn #CDRF_NEWFONT
EndSelect
EndIf
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Global.i Event, x, Chapter, Tab_Container
Global.i Pnl1, panelgadget, WdwID, IconLvwAttr
ViewSkillIndexValue(0) = 0
ViewSkillIndexValue(1) = 10
ViewSkillIndexValue(2) = 17
viewSkillIndexValue(3) = 23
ViewSkillIndexValue(4) = 35
ViewSkillIndexValue(5) = 42
ViewSkillIndexValue(6) = 55
WdwID = OpenWindow(#PB_Any,0,0,420,650,"TEST")
panelgadget = PanelGadget(#PB_Any, 8,8,404, 634)
AddGadgetItem(panelgadget, -1,"Panel1")
Tab_Container = ContainerGadget(#PB_Any, 0, 0, 404, 634)
IconLvwAttr = ListIconGadget(#PB_Any, 10,30,380,550,"Column #1", 200)
AddGadgetColumn(IconLvwAttr, 1, "Column #2",70)
AddGadgetColumn(IconLvwAttr, 2, "Column #3",70)
CloseGadgetList()
AddGadgetItem(panelgadget, -1,"Panel2")
CloseGadgetList()
For x = 0 To #TOTALSIZE
If x = ViewSkillIndexValue(Chapter)
AddGadgetItem(IconLvwAttr,x,"A Bold Statement")
If chapter < 6
chapter + 1
EndIf
Else
AddGadgetItem(IconLvwAttr,x,"Not A Bold Statement" + #LF$ + Str(x) + ":02" + #LF$ + Str(x) + ":03")
EndIf
Next x
SetWindowCallback(@lvwSkillCB() ,IconLvwAttr)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow