I have added the MS Common Controls ActiveX controls Version 6.0. I am using the MS ListView Control Version 6.0. VC++ 6.0 has added all the neccesary non-editable classes for the control and its objects.
These controls use ListItem Classes, which are IDispatch-able, for each item in the List.
I have mapped the control's OnClick event for ListItems.
Everything seems to go fine, I can get the ListItem in the OnClick call, but for some reason, the event seems to clear the ListItem out of ListView.
Subsequent clicks to the last clicked items results in nasty pointer errors, "the address at hex value cannot be 'read.'" A Debug reveals that the error is in the MSCOMCTRL32.OCX, of course.
It seems that the ListItem object is being destructed or something.
What am I missing? I have this feeling I should be passing the LPDISPATCH onto something, but to what, by what method call?
I shouldn't have to re-add the ListItem to the ListView, should I?
This is the code for the OnItemClick:
There doesn't seem to be anything to horrible there, nothing that would destroy my ListItem.Code:void CHlfavsDlg::OnItemClickListviewFavs(LPDISPATCH Item) { VARIANT tag_data; CListItem l_item(Item); // CListItem construct can take a LPDISPATCH tag_data = l_item.GetTag(); if( tag_data.vt = VT_BSTR ) // I am storing a string in the tag data { m_ip = tag_data.bstrVal; // This variable is set properly. } }
Any suggestions?