G
Guest
From my understanding, the C# listview class is a wrapper around the win32
listview and all win32 functionality is available through the wndproc method.
I want to modify the C# listview class (change a row's default height and
text color) and the easiest way do this is through custom drawing (I think).
I know this is possible through onpaint but that may be overkill for what I
want to do. I have overriden the listview wndproc and handled the proper
messages. However, I can't get my changes to show up in the listview. The
listview is in detail view. Is their something special I have to do to
enable custom drawing painting? Is their a win32 style I have to enable? I
am receiving the the custom draw messages in CDDS_ITEMPREPAINT and
CDDS_SUBITEM | CDDS_ITEMPREPAINT but my color and height changes don't show
up i the listview UI. Here is my wndproc. All help is appreciated.
protected override void WndProc(ref Message m)
{
int iRow, iCol;
bool bSelected;
NMHDR nmhdr;
NMLVCUSTOMDRAW nmLvDraw;
switch((uint)m.Msg)
{
case OCM_WM_NOTFY:
case WM_NOTIFY:
nmhdr = (NMHDR) m.GetLParam(typeof(NMHDR));
switch(nmhdr.code)
{
case NM_CUSTOMDRAW:
base.WndProc(ref m);
nmLvDraw = (NMLVCUSTOMDRAW) m.GetLParam(typeof(NMLVCUSTOMDRAW));
switch(nmLvDraw.nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
m.Result = (IntPtr) CDRF_NOTIFYITEMDRAW; break;
case CDDS_ITEMPREPAINT:
//below color and pixel
changes won't take
nmLvDraw.clrText = RGB(255, 0, 0);
nmLvDraw.clrTextBk = RGB(0, 255, 0);
nmLvDraw.nmcd.rc.bottom =
0x20;
// m.Result = (IntPtr) CDRF_NEWFONT;
m.Result = (IntPtr) CDRF_NOTIFYSUBITEMDRAW;
// m.Result = (IntPtr) CDRF_DODEFAULT;
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
//these changes don't take
either
nmLvDraw.clrText = RGB(255, 0, 0);
nmLvDraw.clrTextBk = RGB(0, 255, 0);
nmLvDraw.nmcd.rc.bottom =
0x20;
m.Result = (IntPtr) CDRF_NEWFONT;
break;
}
return;
}
break;
}
base.WndProc(ref m);
}
listview and all win32 functionality is available through the wndproc method.
I want to modify the C# listview class (change a row's default height and
text color) and the easiest way do this is through custom drawing (I think).
I know this is possible through onpaint but that may be overkill for what I
want to do. I have overriden the listview wndproc and handled the proper
messages. However, I can't get my changes to show up in the listview. The
listview is in detail view. Is their something special I have to do to
enable custom drawing painting? Is their a win32 style I have to enable? I
am receiving the the custom draw messages in CDDS_ITEMPREPAINT and
CDDS_SUBITEM | CDDS_ITEMPREPAINT but my color and height changes don't show
up i the listview UI. Here is my wndproc. All help is appreciated.
protected override void WndProc(ref Message m)
{
int iRow, iCol;
bool bSelected;
NMHDR nmhdr;
NMLVCUSTOMDRAW nmLvDraw;
switch((uint)m.Msg)
{
case OCM_WM_NOTFY:
case WM_NOTIFY:
nmhdr = (NMHDR) m.GetLParam(typeof(NMHDR));
switch(nmhdr.code)
{
case NM_CUSTOMDRAW:
base.WndProc(ref m);
nmLvDraw = (NMLVCUSTOMDRAW) m.GetLParam(typeof(NMLVCUSTOMDRAW));
switch(nmLvDraw.nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
m.Result = (IntPtr) CDRF_NOTIFYITEMDRAW; break;
case CDDS_ITEMPREPAINT:
//below color and pixel
changes won't take
nmLvDraw.clrText = RGB(255, 0, 0);
nmLvDraw.clrTextBk = RGB(0, 255, 0);
nmLvDraw.nmcd.rc.bottom =
0x20;
// m.Result = (IntPtr) CDRF_NEWFONT;
m.Result = (IntPtr) CDRF_NOTIFYSUBITEMDRAW;
// m.Result = (IntPtr) CDRF_DODEFAULT;
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
//these changes don't take
either
nmLvDraw.clrText = RGB(255, 0, 0);
nmLvDraw.clrTextBk = RGB(0, 255, 0);
nmLvDraw.nmcd.rc.bottom =
0x20;
m.Result = (IntPtr) CDRF_NEWFONT;
break;
}
return;
}
break;
}
base.WndProc(ref m);
}