Re: Call back function for a list control
Hi Tom,
Thanks for the response.The link is more informative and I did
understand some concepts.
Do we specifically declare a callback function after adding a handler
to in the LVITEM Structure?
But nowhere we are specifying the callback function
Its the ON_NOTIFY message ,Right ?Is this the call back function ?Pls
confirm
Pls go through my steps of writing a callback function
The structure would be like this .......
Step1 :This I will did in OnIniatialUpdate of CFromView
LVITEM* NewItem = new LVITEM;
NewItem->lParam = (LPARAM) pLogItem; // Store the pointer to the data
NewItem->pszText = LPSTR_TEXTCALLBACK; // using callbacks to get the
text
NewItem->mask = LVIF_IMAGE | LVIF_PARAM; // lParam and pszText fields
active
NewItem->iItem = 0; // position to insert new item
NewItem->iSubItem = 0;
Step2:
ON_NOTIFY(LVN_GETDISPINFO, IDC_MYLISTCTRL, OnGetdispinfoList)
void CMyListCtrl::OnGetdispinfoList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO *pDispInfo = (LV_DISPINFO *) pNMHDR;
LV_ITEM *pItem = &(pDispInfo)->item;
if (pDispInfo->item.mask & LVIF_TEXT){
CMyListCtrl *pListCtrl = (CMyListCtrl *) pItem->lParam;
if(pItem->lParam != 0){
pListCtrl ->GetListText(*pItem);
}
}
Pls correct me if am going wrong
Thanks
Kavitha
Tom Serface wrote:
You may want to consider using a CListCtrl instead. Take a look at this
link:
http://www.codeproject.com/listctrl/virtuallist.asp
To do this with a ListBox you would use the LBN_SELCHANGED message. You
don't really need to subclass to do this sort of thing. You could just
derive your own control from the CListBox.
Tom
<kavitha_tongadi@hotmail.com> wrote in message
news:1149085760.298493.140250@i40g2000cwc.googlegroups.com...
hI guys,
I know that this is a good newsgroup where newsbies like me can learn a
lot from experienced professionals in this newsgroup but no response
for my question yet.
Is that this question has not been asked or is this a old question ?
Can some one answer this please.
thanks
Kavitha
kavitha_tongadi@hotmail.com wrote:
Hi everyone,
I am a newbie to this group.
I have good exposure in VC++ but never used Callback mechanism.
I want to use callback function for a subclassed ListBoxcontrol when
the user selects an item and how can this be achived through links and
examples?
Thanks in advance
Kavitha