开发者

IResultData::DeleteItem and IResultData::DeleteAllRsltItems return E_UNEXPECTED

开发者 https://www.devze.com 2023-01-27 16:12 出处:网络
We have a problem with an ATL-based Visual C++ MMC snapin. We have a scope item that is only showed in the scope pane. When this item is selected it populates the result pane with a set of result item

We have a problem with an ATL-based Visual C++ MMC snapin. We have a scope item that is only showed in the scope pane. When this item is selected it populates the result pane with a set of result items.

When the user selects "delete all items" popup menu command our snapin code is invoked - first it does some work, then proceeds to clearing the result view. We want 开发者_如何学编程the following behavior: the user clicks that menu item, our custom code is called to do useful work, then all items disappear from the result pane, the scope item remains selected.

I tried two variations of what to do to remove all result items.

Variation 1 - it calls IResultData::DeleteAllRsltItems() which returns E_UNEXPECTED and items are not removed - they just stay there.

VAriation 2 - it calls IResultData::DeleteItem() for each item previosuly inserted into result pane. Again each call returns E_UNEXPECTED and items are not removed.

How do I properly remove all result items from the MMC view?


We do this in the OnShow handler. All child items are removed like this:

CComPtr<IResultData> pResultData;
result = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
assert( SUCCEEDED(result) );   
pResultData->DeleteAllRsltItems();

Then re-added:

RESULTDATAITEM rdi;
ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
rdi.mask        = RDI_STR | RDI_IMAGE | RDI_PARAM;        
rdi.nImage      = m_resultChildren[i]->GetBitmapIndex();
rdi.str         = reinterpret_cast< wchar_t* >(MMC_CALLBACK);
rdi.nCol        = 0;
rdi.lParam      = (LPARAM)m_resultChildren[i].get();    
HRESULT result = pResultData->InsertItem( &rdi );

This works to remove the result items. I assume that you have another problem in the code that is causing the E_UNEXPECTED.

0

精彩评论

暂无评论...
验证码 换一张
取 消