Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

virtual list control - LVN_GETDISPINFO

313 views
Skip to first unread message

irit lavidor

unread,
Dec 25, 2000, 11:44:49 AM12/25/00
to
Hello,
I'm using a virtual list control. The LVN_GETDISPINFO message handler handles
requests for text and image, but not for state and param:

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.

roy l fine

unread,
Dec 27, 2000, 4:50:34 PM12/27/00
to
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>...

Irit

unread,
Dec 28, 2000, 6:09:31 AM12/28/00
to
Thank you Roy for you answer,
I will take into consideration your advice about the size of the text buffer.
The part about InsertItem() is not really relevant to the case of a virtual list
control. In a virtual list control (a CListCtrl with the LVS_OWNERDATA style) you
do not insert the items, only respond to the LVN_GETDISPINFO notification that is
sent to you by the framework. This allows you to maintain a fairly big list of
items, while keeping in memory information only about the visible ones.
Irit.


-----Original Message-----
Irit Lavidor,

*pResult = 0;
}


.

roy fine

unread,
Dec 31, 2000, 2:21:55 AM12/31/00
to
Irit,

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...

Irit

unread,
Dec 31, 2000, 8:13:41 AM12/31/00
to

Roy,
Happy new year to you too, and thanks anyway since you were the only one to
address my question.


-----Original Message-----
Irit,


-----Original Message-----
Irit Lavidor,

*pResult = 0;
}


..

.

0 new messages