IResultData::DeleteItem 和 IResultData::DeleteAllRsltItems 返回 E_UNEXPECTED

发布于 2024-10-04 23:42:19 字数 521 浏览 0 评论 0原文

基于 ATL 的 Visual C++ MMC 管理单元存在问题。我们有一个仅显示在范围窗格中的范围项。选择此项目后,它会使用一组结果项目填充结果窗格。

当用户选择“删除所有项目”弹出菜单命令时,我们的管理单元代码将被调用 - 首先它会执行一些工作,然后继续清除结果视图。我们想要以下行为:用户单击该菜单项,调用我们的自定义代码来执行有用的工作,然后所有项目从结果窗格中消失,范围项目保持选中状态。

我尝试了两种不同的方法来删除所有结果项。

变体 1 - 它调用 IResultData::DeleteAllRsltItems() ,返回 E_UNEXPECTED 并且项目不会被删除 - 它们只是留在那里。

VAriation 2 - 它为之前插入结果窗格中的每个项目调用 IResultData::DeleteItem()。同样,每次调用都会返回 E_UNEXPECTED 并且项目不会被删除。

如何从 MMC 视图中正确删除所有结果项?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假情假意假温柔 2024-10-11 23:42:19

我们在 OnShow 处理程序中执行此操作。所有子项目都像这样删除:

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

然后重新添加:

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 );

这可以删除结果项目。我假设您的代码中存在另一个导致 E_UNEXPECTED 的问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文