API font colouring to add to existing callback help

Just starting out? Need help? Post your questions and find answers here.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

API font colouring to add to existing callback help

Post by Fangbeast »

I've gone to the limit of my knowledge with this one. At the section marked "; Column 0, Change font to red colour if item marked deleted", i've set the column text colour to red if the item has been marked deleted,

If I toggle the item as undeleted, that works too, removes all effects, colours and underlines.

If I toggle item as deleted again, all item effects are applied except for the font colour of red until I manually click back on the ListIconGadget.

Where I set the selected record to be deleted, I have a "RedrawWindow_(GadgetID(#Gadget_booklist_booklist), 0, 0, #RDW_INVALIDATE | #RDW_ERASE)" but I suspect that operation precedence is at work here.

In my DeleteOldBook routine, I set the gadgetitemdata flag to 1 and the effects are applied immediately to the gadget so I know it works. Why would my redraw command not be trigerring the colour change even though the other effects are trigerred??

Would API expert please look at this callback and suggest where I went wrong?

Code: Select all

      SetGadgetItemData(#Gadget_booklist_booklist, Track\Number("current item line"), Val(DeletedState.s))
      RedrawWindow_(GadgetID(#Gadget_booklist_booklist), 0, 0, #RDW_INVALIDATE | #RDW_ERASE)

Code: Select all

Procedure WindowCallback(hWnd, uMsg, wParam, lParam)
  
  Result = #PB_ProcessPureBasicEvents
  
  Select uMsg

      ; Draw a line through an item to indicate its deleted state
    
    Case #WM_NOTIFY
    
      *nmhdr.NMHDR = lParam
      
      *lvCD.NMLVCUSTOMDRAW = lParam
      
      If IsGadget(#Gadget_booklist_booklist)
        
        If *lvCD\nmcd\hdr\hwndFrom = GadgetID(#Gadget_booklist_booklist) And *lvCD\nmcd\hdr\code = #NM_CUSTOMDRAW
          
          Select *lvCD\nmcd\dwDrawStage
              
            Case #CDDS_PREPAINT
              
              result = #CDRF_NOTIFYITEMDRAW
              
            Case #CDDS_ITEMPREPAINT
              
              result = #CDRF_NOTIFYSUBITEMDRAW
              
            Case #CDDS_ITEMPREPAINT | #CDDS_SUBITEM
              
              thisRow = *lvCD\nmcd\dwItemSpec
              
              thisCol = *lvCD\iSubItem
              
              on_off = GetGadgetItemData(#Gadget_booklist_booklist, thisRow)
              
              ; If thisCol = 0 And on_off. Specifically for column 0. You can change this to any or just use on_off to set all columns
              
              If thisCol = 0 And on_off
                
                ; Column 0, Change font to red colour if item marked deleted
                
                *lvCD\clrText   = $1925E3                                                               
                
                SelectObject_(*lvCD\nmcd\hdc, FontID(Track\Number("font strikeout yes")))
                
                result = #CDRF_NEWFONT; | #CDRF_DODEFAULT
                
              ; Set data type field to be bold and italic
              
              ElseIf thisCol = 1  And on_off    ; This is the author column
                
                ; Column 1, Change font to red colour if item marked deleted
                
                *lvCD\clrText   = $1925E3
                
                SelectObject_(*lvCD\nmcd\hdc, FontID(Track\Number("font all effects")))
                
                result = #CDRF_NEWFONT; | #CDRF_DODEFAULT
                
              Else
                
                SelectObject_(*lvCD\nmcd\hdc, FontID(Track\Number("font strikeout no")))
                
                result = #CDRF_NEWFONT   
                
              EndIf
              
              ; Proper colour banding in listicons
              
             ;If Track\Number("colour band") = #True  ;<-----------Add This Block (Paul Leischow)
                
                If (thisRow / 2) * 2 = thisRow
                  
                  ;*lvCD\clrText   = $000000
                  
                  *lvCD\clrTextBk = $EEEEEE
                  
                Else
                  
                  ;*lvCD\clrText   = $484848
                  
                  *lvCD\clrTextBk = $DADADA
                  
                EndIf
                
             ;EndIf
              
          EndSelect
          
        EndIf
        
      EndIf
      
  EndSelect ; uMsg

  ProcedureReturn Result
  
EndProcedure
Amateur Radio, D-STAR/VK3HAF