void CMyListCtrl::OnGetdispinfoMyList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
if (pDispInfo->item.mask & LVIF_PARAM)
TRACE0("this line is never approached\n");
if (pDispInfo->item.mask & LVIF_STATE)
TRACE0("this line is never approached\n");
if (pDispInfo->item.mask & LVIF_TEXT)
{
CacheItem Item;
RetrieveItem(Item, iItem);
switch (pDispInfo->item.iSubItem)
{
case 0:
lstrcpy(pDispInfo->item.pszText, Item.m_MemberName);
break;
default:
break;
}
}
if (pDispInfo->item.mask & LVIF_IMAGE)
pDispInfo->item.iImage = 0;
*pResult = 0;
}
Does anyone know why this happens?
TIA,
Irit Lavidor.
IIF you are in Report View, part of the answer to your question lies in the
line of code immedialtely following the case 0: statement. As the flag
descriptions from the online help reveals, if LVIF_TEXT flag in the mask is
set in a control display callback message handler, the pszText should
receive the text to be displayed for the associated column (the first one
for your example)... and that is exactly what happens in the following
code:
lstrcpy(pDispInfo->item.pszText, Item.m_MemberName);
p.s. -- one must observe the restriction of not copying in more data that
the allocated buffer will hold --- see the description for the
pDispInfo->item.cchTextMax field.
If you set the lParam to point to a valid structure, for instance, when the
item was inserted into the control (see code segment below), then the
pDispInfo->item.lParam value in the display callback message handler will be
that value that was specified. BUT the pDispInfo->item.mask in the callback
handler will not indicate that the lParam field is valid.
LVITEM pItem;
pItem.mask = LVIF_TEXT | LVIF_PARAM;
pItem.pszText = LPSTR_TEXTCALLBACK;
pItem.iSubItem = 0;
pItem.iImage = 0; // always and forever in Report view for this app...
pItem.iItem = 0; // always insert at the head or top
pItem.lParam = (long)mySomethingPointer;
c_myListControl.InsertItem(&pItem);
I think your question is why this happens - in the display callback message
handler, the control is requesting that the pDispInfo->item.pszText field be
filled in - it is not a call to set the data, rather it is requesting data -
ergo the LVIF_PARAM flag is not set in the mask field, because it is not
requesting the lParam field to be set. The lParam field is valid however,
if and only if the field was set to valid value in the control's
InsertItem() member function call...
best regards,
roy fine
----------------------------------------------------------------------------
-------------------------------------------------------------------
irit lavidor wrote in message
<639a01c06e91$ff1b0cd0$34862ecf@cpmsftngxa05>...
-----Original Message-----
Irit Lavidor,
*pResult = 0;
}
.
you are exactly right about the behavior of the "Virtual" list control --- i
completely missed the most important part of your post;
" Hello I'm using a virtual list control"
My apologies for the pedantic rant. please excuse me for a while while i go
hide in shame...
all the best to you in the new year,
regards,
rlf
"Irit" <ir...@backweb.com> wrote in message
news:32e901c070be$a6f47670$46862ecf@cpmsftngxa06...
-----Original Message-----
Irit,
-----Original Message-----
Irit Lavidor,
*pResult = 0;
}
..
.