Vista has introduced a new API to display a text in the list view control when it doesn't have any items. As the MSDN library states, I should process the LVN_GETEMPTYMARKUP
notification.
In the inherited ListView
control the WndProc
method is overriden:
protected override void WndProc(ref Message m) {
try {
if(m.Msg == 78 /* WM_NOTIFY */) {
var nmhdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR));
if(nmhdr.code == -187 /* LVN_GETEMPTYMARKUP */) {
var nmlvemptymarkup =
(NMLVEMPTYMARKUP)Marshal.PtrToStructure(m.LParam, typeof(NMLVEMPTYMARKUP));
nmlvemptymarkup.szMarkup = "The ListView is empty.";
m.Result = (IntPtr)1;
}
}
} finally {
base.WndProc(ref m);
}
}
However, it doesn't work (although it doesn't throw any exception). Actually I never get nmhdr.code
equals to -187. Any ideas?