Announcement

Collapse
No announcement yet.

NM_CUSTOMDRAW with ListView

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NM_CUSTOMDRAW with ListView

    Having issues getting the NM_CUSTOMDRAW message, here is a sample with the issue happening On Show, links are there for the message if anyone knows whats going on:

    ListView.apz

    Should be a simple matter of defining a few structure variables to then change the background and highlight colour along with text colour and font on a line by line basis once the NM_CUSTOMDRAW is confirmed.

  • #2
    So with trial and error I got this working:

    Code:
    WM_NOTIFY [COLOR="#FF0000"]=[/COLOR] 0x4E
    CDDS_PREPAINT [COLOR="#FF0000"]=[/COLOR] 0x00000001
    CDDS_ITEM [COLOR="#FF0000"]=[/COLOR] 0x00010000
    CDDS_PREPAINT [COLOR="#FF0000"]=[/COLOR] 0x00000001
    CDDS_ITEMPREPAINT [COLOR="#FF0000"]=[/COLOR] CDDS_ITEM + CDDS_PREPAINT
    CDRF_NOTIFYITEMDRAW [COLOR="#FF0000"]=[/COLOR] 0x00000020
    CDRF_NOTIFYSUBITEMDRAW [COLOR="#FF0000"]=[/COLOR] 0x00000020
    CDRF_SKIPDEFAULT [COLOR="#FF0000"]=[/COLOR] 0x00000004
    CDRF_DODEFAULT [COLOR="#FF0000"]=[/COLOR] 0x00000000
    CDDS_SUBITEM [COLOR="#FF0000"]=[/COLOR] 0x00020000
    CDRF_NEWFONT [COLOR="#FF0000"]=[/COLOR] 0x00000002
    
    Subclass[COLOR="#FF0000"].[/COLOR]Create(Application[COLOR="#FF0000"].[/COLOR]GetWndHandle()[COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]function[/COLOR](hWnd[COLOR="#FF0000"],[/COLOR] uMsg[COLOR="#FF0000"],[/COLOR] wParam[COLOR="#FF0000"],[/COLOR] lParam)
    
     [COLOR="#0000FF"]if[/COLOR] (uMsg [COLOR="#FF0000"]==[/COLOR] WM_NOTIFY) [COLOR="#0000FF"]then[/COLOR]
      [COLOR="#0000FF"]local[/COLOR] nmhdr [COLOR="#FF0000"]=[/COLOR] MemoryEx[COLOR="#FF0000"].[/COLOR]AssignStruct(lParam[COLOR="#FF0000"],[/COLOR] NMHDR)
       [COLOR="#0000FF"]if[/COLOR] (nmhdr[COLOR="#FF0000"].[/COLOR]hWndFrom [COLOR="#FF0000"]==[/COLOR] LVHDL) [COLOR="#0000FF"]then[/COLOR]
        [COLOR="#0000FF"]if[/COLOR] (nmhdr[COLOR="#FF0000"].[/COLOR]code [COLOR="#FF0000"]==[/COLOR] [COLOR="#000000"]4294967284[/COLOR]) [COLOR="#0000FF"]then[/COLOR]
         [COLOR="#0000FF"]local[/COLOR] nmlv [COLOR="#FF0000"]=[/COLOR] MemoryEx[COLOR="#FF0000"].[/COLOR]AssignStruct(lParam[COLOR="#FF0000"],[/COLOR] NMLVCUSTOMDRAW)
         [COLOR="#0000FF"]if[/COLOR] (nmlv[COLOR="#FF0000"].[/COLOR]nmcd[COLOR="#FF0000"].[/COLOR]dwDrawStage [COLOR="#FF0000"]==[/COLOR] CDDS_PREPAINT) [COLOR="#0000FF"]then[/COLOR]
          [COLOR="#0000FF"]return[/COLOR] CDRF_NOTIFYITEMDRAW
         [COLOR="#0000FF"]end[/COLOR]
         [COLOR="#0000FF"]if[/COLOR] (nmlv[COLOR="#FF0000"].[/COLOR]nmcd[COLOR="#FF0000"].[/COLOR]dwDrawStage [COLOR="#FF0000"]==[/COLOR] CDDS_ITEMPREPAINT) [COLOR="#0000FF"]then[/COLOR]
          [COLOR="#0000FF"]return[/COLOR] CDRF_NOTIFYSUBITEMDRAW
         [COLOR="#0000FF"]end[/COLOR]
         [COLOR="#0000FF"]if[/COLOR] (nmlv[COLOR="#FF0000"].[/COLOR]nmcd[COLOR="#FF0000"].[/COLOR]dwDrawStage [COLOR="#FF0000"]==[/COLOR] CDDS_SUBITEM + CDDS_ITEMPREPAINT) [COLOR="#0000FF"]then[/COLOR]
          [COLOR="#008000"]--nmlv.nmcd.dwItemSpec is the row[/COLOR]
          [COLOR="#008000"]--nmlv.iSubItem is the column[/COLOR]
          [COLOR="#008000"]--return CDRF_NEWFONT return if changed any given colours or fonts[/COLOR]
          [COLOR="#0000FF"]return[/COLOR] CDRF_DODEFAULT
         [COLOR="#0000FF"]end[/COLOR]
        [COLOR="#0000FF"]end[/COLOR]
      [COLOR="#0000FF"]end[/COLOR]
     [COLOR="#0000FF"]end[/COLOR]
     [COLOR="#0000FF"]return[/COLOR] Subclass[COLOR="#FF0000"].[/COLOR]OldWinProc(hWnd[COLOR="#FF0000"],[/COLOR] uMsg[COLOR="#FF0000"],[/COLOR] wParam[COLOR="#FF0000"],[/COLOR] lParam);
    [COLOR="#0000FF"]end[/COLOR])
    
    [COLOR="#008000"]--LVHDL is ListView handle[/COLOR]
    The NM_CUSTOMDRAW message sent via WM_NOTIFY is 4294967284 that is 0xFFFFFFF4 in hexidecimal and that bears no relation to what should be:

    Code:
    NM_FIRST = 0           
    NM_CUSTOMDRAW = NM_FIRST -12
    so the question now is whats going on? Typical messages work OK as the standard defined constraints always work but I've noticed that everything coming through a WM_NOTIFY except the WM_NOTIFY itself is always a long decimal number that makes no sense at all such as NM_CLICK should be:

    Code:
    NM_FIRST = 0           
    NM_CLICK = NM_FIRST -2
    but is coming through as 4294967294 that is FFFFFFFE so how do we easily get the correct, as in published, constraints through the Code value of the NMHDR structure?

    Comment

    Working...
    X