http://www.codeguru.com/atl/MMCSnapInTutorial.html Developing MMC Snap-Ins using ATL - Leon Finker (2001/05/23) This article teaches you how to create an MMC Snap-In and implement some basic features using ATL. Great starting point for MMC Snap-In development.
你去看看masterz() 说的那个地方,那里应该很详细的。 在你的父节点的Notify函数里:HRESULT CFlowEventsData::Notify( MMC_NOTIFY_TYPE event, long arg, long param, IComponentData* pComponentData, IComponent* pComponent, DATA_OBJECT_TYPES type) { // Add code to handle the different notifications. // Handle MMCN_SHOW and MMCN_EXPAND to enumerate children items. // In response to MMCN_SHOW you have to enumerate both the scope // and result pane items. // For MMCN_EXPAND you only need to enumerate the scope items // Use IConsoleNameSpace::InsertItem to insert scope pane items // Use IResultData::InsertItem to insert result pane item. HRESULT hr = E_NOTIMPL; _ASSERTE(pComponentData != NULL || pComponent != NULL); CComPtr<IConsole> spConsole; CComQIPtr<IHeaderCtrl, &IID_IHeaderCtrl> spHeader; if (pComponentData != NULL) spConsole = ((CFlowEvents*)pComponentData)->m_spConsole; else { spConsole = ((CFlowEventsComponent*)pComponent)->m_spConsole; spHeader = spConsole; } switch (event) { case MMCN_SHOW: { CComQIPtr<IResultData, &IID_IResultData> spResultData(spConsole); // TODO : Enumerate the result pane items m_bSelected = V2BOOL(arg); hr = OnShow(spConsole, V2BOOL(arg)); break; } case MMCN_EXPAND: { CComQIPtr<IConsoleNameSpace, &IID_IConsoleNameSpace> spConsoleNameSpace(spConsole); // TODO : Enumerate scope pane items LoadEvent(); //这个函数里插入你要的子节点 hr = S_OK; break; } .......void LoadEvent() { ASSERT(pEvents != NULL); CComQIPtr<IConsoleNameSpace2, &IID_IConsoleNameSpace2> spConsoleNameSpace(m_spConsole); CFlowEventData *pFlowEventData = new CFlowEventData; //这个类是子节点的类 ASSERT(pFlowEventData != NULL); VSEvents::IVEventPtr pEvent = pEvents->Item[index]; SCOPEDATAITEM sdi; HRESULT hr; //Set visible attributes to our nodes pFlowEventData->m_spConsole = m_spConsole; m_ChildrenArray.Add(pFlowEventData); ZeroMemory(&sdi,sizeof(SCOPEDATAITEM)); sdi.mask = SDI_STR | // Displayname is valid SDI_PARAM | // lParam is valid SDI_IMAGE | // nImage is valid SDI_OPENIMAGE | // nOpenImage is valid SDI_PARENT | SDI_CHILDREN; pFlowEventData->GetScopePaneInfo(&sdi); sdi.relativeID = m_scopeDataItem.ID; sdi.displayname = MMC_CALLBACK; sdi.cChildren = 1; hr = spConsoleNameSpace->InsertItem(&sdi); if( hr == S_OK ) memcpy(&pFlowEventData->m_scopeDataItem, &sdi, sizeof(SCOPEDATAITEM));}
2。A new project
3. ATL COM AppWizard
4. 好了以后,New一个ATLObject
5. 选择MMC Snapin,next
6。输入你的节点名字,比如叫Sonyg
7。在另一个Tab里(MMC Snapin)里选择你要扩展的节点(也可以不选)
Interface里有6个属性:(这个不太好说清楚,真的)
IComponentData 是指左边的Tree
IComponent 是指右边的Panel
ISnapInAbout 就是关于……对话框
IExtendContexMenu 是指你需要扩展你的节点上的菜单
IExtendPropertySheet是指你需要扩展你的节点上的属性页
IExtendControlBar是指你需要扩展你的节点上的工具条
Developing MMC Snap-Ins using ATL - Leon Finker (2001/05/23)
This article teaches you how to create an MMC Snap-In and implement some basic features using ATL. Great starting point for MMC Snap-In development.
在你的父节点的Notify函数里:HRESULT CFlowEventsData::Notify( MMC_NOTIFY_TYPE event,
long arg,
long param,
IComponentData* pComponentData,
IComponent* pComponent,
DATA_OBJECT_TYPES type)
{
// Add code to handle the different notifications.
// Handle MMCN_SHOW and MMCN_EXPAND to enumerate children items.
// In response to MMCN_SHOW you have to enumerate both the scope
// and result pane items.
// For MMCN_EXPAND you only need to enumerate the scope items
// Use IConsoleNameSpace::InsertItem to insert scope pane items
// Use IResultData::InsertItem to insert result pane item.
HRESULT hr = E_NOTIMPL; _ASSERTE(pComponentData != NULL || pComponent != NULL); CComPtr<IConsole> spConsole;
CComQIPtr<IHeaderCtrl, &IID_IHeaderCtrl> spHeader;
if (pComponentData != NULL)
spConsole = ((CFlowEvents*)pComponentData)->m_spConsole;
else
{
spConsole = ((CFlowEventsComponent*)pComponent)->m_spConsole;
spHeader = spConsole;
} switch (event)
{
case MMCN_SHOW:
{
CComQIPtr<IResultData, &IID_IResultData> spResultData(spConsole);
// TODO : Enumerate the result pane items
m_bSelected = V2BOOL(arg);
hr = OnShow(spConsole, V2BOOL(arg));
break;
}
case MMCN_EXPAND:
{
CComQIPtr<IConsoleNameSpace, &IID_IConsoleNameSpace> spConsoleNameSpace(spConsole);
// TODO : Enumerate scope pane items
LoadEvent(); //这个函数里插入你要的子节点
hr = S_OK;
break;
} .......void LoadEvent()
{
ASSERT(pEvents != NULL);
CComQIPtr<IConsoleNameSpace2, &IID_IConsoleNameSpace2> spConsoleNameSpace(m_spConsole); CFlowEventData *pFlowEventData = new CFlowEventData; //这个类是子节点的类
ASSERT(pFlowEventData != NULL);
VSEvents::IVEventPtr pEvent = pEvents->Item[index];
SCOPEDATAITEM sdi; HRESULT hr; //Set visible attributes to our nodes
pFlowEventData->m_spConsole = m_spConsole; m_ChildrenArray.Add(pFlowEventData); ZeroMemory(&sdi,sizeof(SCOPEDATAITEM));
sdi.mask = SDI_STR | // Displayname is valid
SDI_PARAM | // lParam is valid
SDI_IMAGE | // nImage is valid
SDI_OPENIMAGE | // nOpenImage is valid
SDI_PARENT |
SDI_CHILDREN;
pFlowEventData->GetScopePaneInfo(&sdi);
sdi.relativeID = m_scopeDataItem.ID;
sdi.displayname = MMC_CALLBACK;
sdi.cChildren = 1;
hr = spConsoleNameSpace->InsertItem(&sdi);
if( hr == S_OK )
memcpy(&pFlowEventData->m_scopeDataItem, &sdi, sizeof(SCOPEDATAITEM));}