Discussion:
Custom drawn listview
(too old to reply)
DR
2007-09-01 22:50:23 UTC
Permalink
I wrote the following code to draw items in different colors depending on
their item data. In the debug build everything works fine. In release build
it causes access violations. If I comment out the lines with
lpNMCustomDraw->clrText the access violation goes away. Any ideas? Here is
the code:

-------------------------

LRESULT OnCustomDraw(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
LPNMLVCUSTOMDRAW lpNMCustomDraw = (LPNMLVCUSTOMDRAW) pnmh;

if ((lpNMCustomDraw->nmcd.dwDrawStage & CDDS_ITEMPREPAINT))
{
LPSTR sz = (LPSTR)lpNMCustomDraw->nmcd.lItemlParam;
if (sz)
{
if (sz[0] == '\\')
{
lpNMCustomDraw->clrText = RGB(0x77,0x77,0x77);
}
else if (sz[0] == '<')
{
lpNMCustomDraw->clrText = RGB(0xff,0,0xff);
}
else
{
lpNMCustomDraw->clrText = RGB(0,0xaa,0);
}
}
}
bHandled = true;
return CDRF_NOTIFYITEMDRAW;
}
shiren xie
2011-09-01 14:39:18 UTC
Permalink
want to replay
Post by DR
I wrote the following code to draw items in different colors depending on
their item data. In the debug build everything works fine. In release build
it causes access violations. If I comment out the lines with
lpNMCustomDraw->clrText the access violation goes away. Any ideas? Here is
-------------------------
LRESULT OnCustomDraw(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
LPNMLVCUSTOMDRAW lpNMCustomDraw = (LPNMLVCUSTOMDRAW) pnmh;
if ((lpNMCustomDraw->nmcd.dwDrawStage & CDDS_ITEMPREPAINT))
{
LPSTR sz = (LPSTR)lpNMCustomDraw->nmcd.lItemlParam;
if (sz)
{
if (sz[0] == '\\')
{
lpNMCustomDraw->clrText = RGB(0x77,0x77,0x77);
}
else if (sz[0] == '<')
{
lpNMCustomDraw->clrText = RGB(0xff,0,0xff);
}
else
{
lpNMCustomDraw->clrText = RGB(0,0xaa,0);
}
}
}
bHandled = true;
return CDRF_NOTIFYITEMDRAW;
}
shiren xie
2011-09-01 14:42:06 UTC
Permalink
learn hard
Post by DR
I wrote the following code to draw items in different colors depending on
their item data. In the debug build everything works fine. In release build
it causes access violations. If I comment out the lines with
lpNMCustomDraw->clrText the access violation goes away. Any ideas? Here is
-------------------------
LRESULT OnCustomDraw(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
LPNMLVCUSTOMDRAW lpNMCustomDraw = (LPNMLVCUSTOMDRAW) pnmh;
if ((lpNMCustomDraw->nmcd.dwDrawStage & CDDS_ITEMPREPAINT))
{
LPSTR sz = (LPSTR)lpNMCustomDraw->nmcd.lItemlParam;
if (sz)
{
if (sz[0] == '\\')
{
lpNMCustomDraw->clrText = RGB(0x77,0x77,0x77);
}
else if (sz[0] == '<')
{
lpNMCustomDraw->clrText = RGB(0xff,0,0xff);
}
else
{
lpNMCustomDraw->clrText = RGB(0,0xaa,0);
}
}
}
bHandled = true;
return CDRF_NOTIFYITEMDRAW;
}
Post by shiren xie
want to replay
Loading...