Hi Claudio,
There´s no need to use the ownerdraw mode. The advantage of the customdraw mode over the ownerdraw mode is that you don´t have to draw *all* columns yourself. In your case the only column that must be painted manually seems to be the third column. Note: Zero based, that´s the second column !
To make the VO-DataLIstview class work:
1. Themes must be enabled !
2. In the CustomDraw() callback there are two places marked with
, where you must modify the current conditons.
METHOD CustomDraw ( lParam ) CLASS ListVIewData // VO Callback
LOCAL pNMCustomDraw AS _winNMLVCUSTOMDRAW
LOCAL dwDrawStage, dwCurrentTextCOlor AS DWORD
LOCAL iRetValue AS INT
LOCAL hDC, ptrSubItemValue AS PTR
LOCAL struRectText IS _winRECT
iRetValue := CDRF_DODEFAULT
pNMCustomDraw := PTR( _CAST , lParam )
dwDrawStage := pNMCustomDraw.nmcd.dwDrawStage
// --------------
DO CASE
CASE dwDrawStage == CDDS_PREPAINT
iRetValue := CDRF_NOTIFYITEMDRAW
CASE dwDrawStage == CDDS_ITEMPREPAINT
iRetValue := CDRF_NOTIFYSUBITEMDRAW
CASE dwDrawStage == _OR ( CDDS_ITEMPREPAINT | CDDS_SUBITEM )
// we want to draw only one specific column.
// All other columns are still drawn by the system !
// --------------------
// note: The subitem ( column) number is zero based !
// LOoking at your posted image it´s about the third column. But zero based, that´s the second column !
IF pNMCustomDraw.iSubItem == 2 // <-------
// -----------------
ptrSubItemValue := MemAlloc(255 )
ListView_GetItemText( SELF:Handle() , pNMCustomDraw.nmcd.dwItemSpec , pNMCustomDraw.iSubItem , ptrSubItemValue , 255 )
// --------------------
IF Val ( Psz2String ( ptrSubItemValue ) ) <= 765 // <----- the red color threshold !
hDC := pNMCustomDraw.nmcd.hDC
CopyRect ( @struRectText , @pNMCustomDraw.nmcd.rc )
// --------------
FillRect ( hDC , @struRectText , _oBkgBrush:Handle() )
dwCurrentTextCOlor := SetTextColor ( hDC , _oTxtCOlor:COlorref )
struRectText.right -= 6
DrawText ( hDC , ptrSubItemValue , -1 , @struRectText ,_OR ( DT_SINGLELINE , DT_RIGHT , DT_VCENTER ) )
SetTextColor ( hDC , dwCurrentTextCOlor )
// ----------------
iRetValue := CDRF_SKIPDEFAULT
ENDIF
MemFree ( ptrSubItemValue )
ENDIF
ENDCASE
RETURN iRetValue
METHOD Init(oOwner, xID, oPoint, oDimension, kStyle) CLASS ListVIewData
SUPER:Init(oOwner, xID, oPoint, oDimension, kStyle)
_oBkgBrush := Brush { Color { COLORRED } }
_oTxtColor := Color { COLORWHITE }
RETURN SELF
CLASS ListVIewData INHERIT DataListView
PROTECT _oBkgBrush AS Brush
PROTECT _oTxtColor AS COlor
btw. Doing the same with bBrowser is just a "ColorCondition" one liner ...
regards
Karl-Heinz