From: Kevin on
I have a ControlNotify method on a DataWindow. What I want to do is use
change the colour of items in a ListView depending on a value. The
method code is shown below and compiles without any problem.

When the program runs it never gets in to the code to handle the
colouring, oEvent:NotifyCode is never NM_CUSTOMDRAW. This is on a
DataWindow, but it does not work on a dialog either.

Can anyone tell me what I am missing? I have search the newsgroups and
found links to examples which no longer exists. The articles don't tell
me what I may be missing.

Thanks in advance.

Kevin

method ControlNotify( oEvent ) class MainWindow
//
// Control notify event handler
//
local p_NMCD as _winNMLVCustomDraw
local dwDrawStage as dword
local dwIndex as dword
local oLV_Item as ListViewItem
//local oFont as Font

if oEvent:NotifyCode == NM_CUSTOMDRAW
p_NMCD := ptr( _cast, oEvent:lParam )
dwDrawStage := p_NMCD.nmcd.dwDrawStage

do case
case dwDrawStage == CDDS_PREPAINT
self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW,
CDRF_NOTIFYPOSTPAINT )

case _and( dwDrawStage, CDDS_ITEMPREPAINT ) > 0
dwIndex := p_NMCD.nmcd.dwItemSpec
oLV_Item := self:oDClvStructure:GetItemAttributes( dwIndex + 1 )

if IsNil( oLV_Item )
if self:lDragActive
if _and( p_NMCD.nmcd.uItemState, CDIS_SELECTED ) == CDIS_SELECTED
// White on dark blue / highlight
p_NMCD.clrText := dword(RGB(255, 255, 255))
p_NMCD.clrTextBk := dword(RGB( 0, 0, 128))

else
// black on white
p_NMCD.clrText := dword(RGB( 0, 0, 0 ))
p_NMCD.clrTextBk := dword(RGB( 255, 255, 255 ))
endif

elseif _and( p_NMCD.nmcd.uItemState, CDIS_SELECTED ) ==
CDIS_SELECTED
// white on dark blue / highlight color
p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
p_NMCD.clrTextBk := dword(RGB( 0, 0, 128 ))

else
// black on white
p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
p_NMCD.clrTextBk := dword(RGB( 255, 255, 255 ))
endif

else
// (p_NMCD.iSubItem) % 8 will give you the
// 0 base column #
// (i.e. 0 means column 1 on the screen)
if (p_NMCD.iSubItem ) % 8 == 1 .and. ;
oLV_Item:GetValue( #F_NAME ) == "PUR_DATE"
//oFont := Font{, 10, "Arial" }
//oFont:Bold := true
//SelectObject( p_NMCD.nmcd.hdc, oFont:Handle() )
// White on dark blue
p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
p_NMCD.clrTextBk := dword(RGB( 0, 0, 255 ))
else
// black on white
p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
p_NMCD.clrTextBk := dword(RGB( 0, 0, 0 ))

endif

endif

// Return this again for all subitems
self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW,
CDRF_NOTIFYPOSTPAINT )

otherwise
self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW,
CDRF_NOTIFYPOSTPAINT )

endcase

SetWindowLong( self:Handle(), DWL_MSGRESULT, self:EventReturnValue )

endif

return self:EventReturnValue

From: Malcolm Gray on
On 24/05/2010 16:28, Kevin wrote:
>
>
> I have a ControlNotify method on a DataWindow. What I want to do is use
> change the colour of items in a ListView depending on a value. The
> method code is shown below and compiles without any problem.
>
> When the program runs it never gets in to the code to handle the
> colouring, oEvent:NotifyCode is never NM_CUSTOMDRAW. This is on a
> DataWindow, but it does not work on a dialog either.

OK - well our draw code looks very similar.
What version of VO are you using?
(i seem to remember in this area some casting problems so
getting -12 vs getting 0xFFFFFFF4)
From: John Martens on
Kevin,

Make it:
IF DWORD(oEvent:NotifyCode) = NM_CUSTOMDRAW

John


Op 24-5-2010 17:28, Kevin schreef:
> I have a ControlNotify method on a DataWindow. What I want to do is use
> change the colour of items in a ListView depending on a value. The
> method code is shown below and compiles without any problem.
>
> When the program runs it never gets in to the code to handle the
> colouring, oEvent:NotifyCode is never NM_CUSTOMDRAW. This is on a
> DataWindow, but it does not work on a dialog either.
>
> Can anyone tell me what I am missing? I have search the newsgroups and
> found links to examples which no longer exists. The articles don't tell
> me what I may be missing.
>
> Thanks in advance.
>
> Kevin
>
> method ControlNotify( oEvent ) class MainWindow
> //
> // Control notify event handler
> //
> local p_NMCD as _winNMLVCustomDraw
> local dwDrawStage as dword
> local dwIndex as dword
> local oLV_Item as ListViewItem
> //local oFont as Font
>
> if oEvent:NotifyCode == NM_CUSTOMDRAW
> p_NMCD := ptr( _cast, oEvent:lParam )
> dwDrawStage := p_NMCD.nmcd.dwDrawStage
>
> do case
> case dwDrawStage == CDDS_PREPAINT
> self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW, CDRF_NOTIFYPOSTPAINT )
>
> case _and( dwDrawStage, CDDS_ITEMPREPAINT ) > 0
> dwIndex := p_NMCD.nmcd.dwItemSpec
> oLV_Item := self:oDClvStructure:GetItemAttributes( dwIndex + 1 )
>
> if IsNil( oLV_Item )
> if self:lDragActive
> if _and( p_NMCD.nmcd.uItemState, CDIS_SELECTED ) == CDIS_SELECTED
> // White on dark blue / highlight
> p_NMCD.clrText := dword(RGB(255, 255, 255))
> p_NMCD.clrTextBk := dword(RGB( 0, 0, 128))
>
> else
> // black on white
> p_NMCD.clrText := dword(RGB( 0, 0, 0 ))
> p_NMCD.clrTextBk := dword(RGB( 255, 255, 255 ))
> endif
>
> elseif _and( p_NMCD.nmcd.uItemState, CDIS_SELECTED ) == CDIS_SELECTED
> // white on dark blue / highlight color
> p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
> p_NMCD.clrTextBk := dword(RGB( 0, 0, 128 ))
>
> else
> // black on white
> p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
> p_NMCD.clrTextBk := dword(RGB( 255, 255, 255 ))
> endif
>
> else
> // (p_NMCD.iSubItem) % 8 will give you the
> // 0 base column #
> // (i.e. 0 means column 1 on the screen)
> if (p_NMCD.iSubItem ) % 8 == 1 .and. ;
> oLV_Item:GetValue( #F_NAME ) == "PUR_DATE"
> //oFont := Font{, 10, "Arial" }
> //oFont:Bold := true
> //SelectObject( p_NMCD.nmcd.hdc, oFont:Handle() )
> // White on dark blue
> p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
> p_NMCD.clrTextBk := dword(RGB( 0, 0, 255 ))
> else
> // black on white
> p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
> p_NMCD.clrTextBk := dword(RGB( 0, 0, 0 ))
>
> endif
>
> endif
>
> // Return this again for all subitems
> self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW, CDRF_NOTIFYPOSTPAINT )
>
> otherwise
> self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW, CDRF_NOTIFYPOSTPAINT )
>
> endcase
>
> SetWindowLong( self:Handle(), DWL_MSGRESULT, self:EventReturnValue )
>
> endif
>
> return self:EventReturnValue
>
From: Kevin on
Malcolm,

I am using VO2.8 and intended putting that it my original post. Casting
was something I was thinking I had heard of but could not remember
exactly what it was. John's answer gave me the solution. Just need to
figure out some of the other logic to get exactly what I want.

Thanks.

Kevin

"Malcolm Gray" <malcolm-news2008(a)jobstream.com> wrote in message
news:pqlqc7-0g3.ln1(a)malcolmdesk.malph.dyndns.org.malph.dyndns.org:

> On 24/05/2010 16:28, Kevin wrote:
> >
> >
> > I have a ControlNotify method on a DataWindow. What I want to do is use
> > change the colour of items in a ListView depending on a value. The
> > method code is shown below and compiles without any problem.
> >
> > When the program runs it never gets in to the code to handle the
> > colouring, oEvent:NotifyCode is never NM_CUSTOMDRAW. This is on a
> > DataWindow, but it does not work on a dialog either.
>
> OK - well our draw code looks very similar.
> What version of VO are you using?
> (i seem to remember in this area some casting problems so
> getting -12 vs getting 0xFFFFFFF4)

From: Kevin on
John,

Thanks that worked.

Do you know how to identify the actual control involved? I am new to
coding at this level.

Kevin


"John Martens" <adsl672100(a)tiscali.nl> wrote in message
news:4bfaaacf$0$30707$5fc3050(a)news.tiscali.nl:

> Kevin,
>
> Make it:
> IF DWORD(oEvent:NotifyCode) = NM_CUSTOMDRAW
>
> John
>
>
> Op 24-5-2010 17:28, Kevin schreef:
> > I have a ControlNotify method on a DataWindow. What I want to do is use
> > change the colour of items in a ListView depending on a value. The
> > method code is shown below and compiles without any problem.
> >
> > When the program runs it never gets in to the code to handle the
> > colouring, oEvent:NotifyCode is never NM_CUSTOMDRAW. This is on a
> > DataWindow, but it does not work on a dialog either.
> >
> > Can anyone tell me what I am missing? I have search the newsgroups and
> > found links to examples which no longer exists. The articles don't tell
> > me what I may be missing.
> >
> > Thanks in advance.
> >
> > Kevin
> >
> > method ControlNotify( oEvent ) class MainWindow
> > //
> > // Control notify event handler
> > //
> > local p_NMCD as _winNMLVCustomDraw
> > local dwDrawStage as dword
> > local dwIndex as dword
> > local oLV_Item as ListViewItem
> > //local oFont as Font
> >
> > if oEvent:NotifyCode == NM_CUSTOMDRAW
> > p_NMCD := ptr( _cast, oEvent:lParam )
> > dwDrawStage := p_NMCD.nmcd.dwDrawStage
> >
> > do case
> > case dwDrawStage == CDDS_PREPAINT
> > self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW, CDRF_NOTIFYPOSTPAINT )
> >
> > case _and( dwDrawStage, CDDS_ITEMPREPAINT ) > 0
> > dwIndex := p_NMCD.nmcd.dwItemSpec
> > oLV_Item := self:oDClvStructure:GetItemAttributes( dwIndex + 1 )
> >
> > if IsNil( oLV_Item )
> > if self:lDragActive
> > if _and( p_NMCD.nmcd.uItemState, CDIS_SELECTED ) == CDIS_SELECTED
> > // White on dark blue / highlight
> > p_NMCD.clrText := dword(RGB(255, 255, 255))
> > p_NMCD.clrTextBk := dword(RGB( 0, 0, 128))
> >
> > else
> > // black on white
> > p_NMCD.clrText := dword(RGB( 0, 0, 0 ))
> > p_NMCD.clrTextBk := dword(RGB( 255, 255, 255 ))
> > endif
> >
> > elseif _and( p_NMCD.nmcd.uItemState, CDIS_SELECTED ) == CDIS_SELECTED
> > // white on dark blue / highlight color
> > p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
> > p_NMCD.clrTextBk := dword(RGB( 0, 0, 128 ))
> >
> > else
> > // black on white
> > p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
> > p_NMCD.clrTextBk := dword(RGB( 255, 255, 255 ))
> > endif
> >
> > else
> > // (p_NMCD.iSubItem) % 8 will give you the
> > // 0 base column #
> > // (i.e. 0 means column 1 on the screen)
> > if (p_NMCD.iSubItem ) % 8 == 1 .and. ;
> > oLV_Item:GetValue( #F_NAME ) == "PUR_DATE"
> > //oFont := Font{, 10, "Arial" }
> > //oFont:Bold := true
> > //SelectObject( p_NMCD.nmcd.hdc, oFont:Handle() )
> > // White on dark blue
> > p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
> > p_NMCD.clrTextBk := dword(RGB( 0, 0, 255 ))
> > else
> > // black on white
> > p_NMCD.clrText := dword(RGB( 255, 255, 255 ))
> > p_NMCD.clrTextBk := dword(RGB( 0, 0, 0 ))
> >
> > endif
> >
> > endif
> >
> > // Return this again for all subitems
> > self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW, CDRF_NOTIFYPOSTPAINT )
> >
> > otherwise
> > self:EventReturnValue := _or( CDRF_NOTIFYITEMDRAW, CDRF_NOTIFYPOSTPAINT )
> >
> > endcase
> >
> > SetWindowLong( self:Handle(), DWL_MSGRESULT, self:EventReturnValue )
> >
> > endif
> >
> > return self:EventReturnValue
> >