ListView: Nur horizontale Gridlines ?



  • Hallo mal wieder,

    Mein Problem ist , das sich in meinem ListView LVS_EX_GRIDLINES und LVS_EX_SUBITEMIMAGES in die Quere kommen. Konkret schneiden die vertikalen Gridlines immer die erste Spalte Pixel in den Icons der Subitems ab, was hässlich aussieht. Eigentlich könnte ich auch gut auf die vertikalen Gridlines verzichten, da ich nicht glaube, dass man den Abstand der Icons anpassen kann. Geht das irgendwie ? Danke schonmal...

    P.S. Suchfunktion ist grade deaktiviert.



  • moin meister ...

    Wenn Du nur horizontale Linien benötigst, wird wohl das selber Malen
    der Items und SubItems nicht zu vermeiden sein.

    Suche in der MSDN nach "NM_CUSTOMDRAW"
    unten solltes Du einen Verweis finden :
    "See also Using Custom Draw"

    LRESULT DoNotify(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
       LPNMLISTVIEW  pnm    = (LPNMLISTVIEW)lParam;
    
       switch (pnm->hdr.code){
          case NM_CUSTOMDRAW:{
             LPNMLVCUSTOMDRAW  lplvcd = (LPNMLVCUSTOMDRAW)lParam;
    
             /*
             CDDS_PREPAINT is at the beginning of the paint cycle. You 
             implement custom draw by returning the proper value. In this 
             case, we're requesting item-specific notifications.
             */
             if(lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT)
                // Request prepaint notifications for each item.
                return CDRF_NOTIFYITEMDRAW;
    
             /*
             Because we returned CDRF_NOTIFYITEMDRAW in response to
             CDDS_PREPAINT, CDDS_ITEMPREPAINT is sent when the control is
             about to paint an item.
             */
             if(lplvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT){
                /*
                To change the font, select the desired font into the 
                provided HDC. We're changing the font for every third item
                in the control, starting with item zero.
                */
                if(!(lplvcd->nmcd.dwItemSpec % 3))
                   SelectObject(lplvcd->nmcd.hdc, g_hNewFont);
                else
                   return(CDRF_DODEFAULT);
    
                /*
                To change the text and background colors in a list view 
                control, set the clrText and clrTextBk members of the 
                NMLVCUSTOMDRAW structure to the desired color.
    
                This differs from most other controls that support 
                CustomDraw. To change the text and background colors for 
                the others, call SetTextColor and SetBkColor on the provided HDC.
                */
                lplvcd->clrText = RGB(150, 75, 150);
                lplvcd->clrTextBk = RGB(255,255,255);
    
                /*
                We changed the font, so we're returning CDRF_NEWFONT. This
                tells the control to recalculate the extent of the text.
                */
                return CDRF_NEWFONT;
                }
             }
    
          default:
             break;
       }
    
       return 0;
    }
    

    Macht wohl die Schrift farbig ...

    Etwas experimentieren und Du zeichnest die Icons und Schrift und die Linie darunter selbst ...

    hoffe das hilft Dir und macht nicht zu viel Arbeit ...
    jedenfalls besser als ewig Styles zu probieren 🙂

    mfg
    RB



  • Danke für den Tipp, bei Zeiten werd ich mich mal reinlesen.
    Mit ImageListMerge() hab ichs jetzt erstmal hingekriegt, meine Icons mit einem breiteren zu verschmelzen, blöder Bauerntrick aber es klappt.


Anmelden zum Antworten