COMP.CPP

///////////////////////////////////////////////////////////////////////////// 
// comp.cpp : IComponent Interface to communicate with MMC for the
// results pane. This implementation uses the
// default list view.
//
// This is a part of the MMC SDK.
// Copyright (C) 1997 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// MMC SDK Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// MMC Library product.
//

#include "stdafx.h"
#include "disk.h"
#include "globals.h"
#include "comp.h"

/////////////////////////////////////////////////////////////////////////////
// CComponent - This class at this point is the basic interface to handle
// anything to do with the results pane. At this point it is
// mostly a stub place holder and serves no real purpose. It will
// get filled in and used in later steps.

CComponent::CComponent()
{
m_pConsole = NULL;
m_cRefs = 0; // Not used in Step1
}

CComponent::~CComponent()
{
}

/////////////////////////////////////////////////////////////////////////////
// IComponent implementation
//

//---------------------------------------------------------------------------
// IComponent::Initialize is called when a snap-in is being created and
// has items in the result pane to enumerate. The pointer to IConsole that
// is passed in is used to make QueryInterface calls to the console for
// interfaces such as IResultData.
//
STDMETHODIMP
CComponent::Initialize
(
LPCONSOLE lpConsole // [in] Pointer to IConsole's IUnknown interface
)
{
HRESULT hr = S_OK;

_ASSERT( NULL != lpConsole );

//
// Save away all the interfaces we'll need
//

// Not realy going to use it in this step!
m_pConsole = lpConsole;
m_pConsole->AddRef();

return hr;

} // end Initialize()


//---------------------------------------------------------------------------
// Notifies the snap-in of actions taken by the user
//
STDMETHODIMP
CComponent::Notify
(
LPDATAOBJECT pDataObject, // [in] Points to data object
MMC_NOTIFY_TYPE event, // [in] Identifies action taken by user
long arg, // [in] Depends on the notification type
long param // [in] Depends on the notification type
)
{
// Don't need to handle any messages at this point
return S_OK;

} // end Notify()


//---------------------------------------------------------------------------
// Releases all references to the console.
// Only the console should call this method.
//
STDMETHODIMP
CComponent::Destroy
(
long cookie // Reserved, not in use at this time
)
{
// Release the interfaces that we QI'ed
if (m_pConsole != NULL)
{
m_pConsole->Release();
m_pConsole = NULL;
}
return S_OK;

} // end Destroy()


//---------------------------------------------------------------------------
// Returns a data object that can be used to retrieve context information
// for the specified cookie.
//
STDMETHODIMP
CComponent::QueryDataObject
(
long cookie, // [in] Specifies the unique identifier
DATA_OBJECT_TYPES context, // [in] Type of data object
LPDATAOBJECT *ppDataObject // [out] Points to address of returned data
)
{
// Make sure we don't get here, we don't need it in this step
_ASSERT(FALSE);

return S_FALSE;

} // end QueryDataObject()


//---------------------------------------------------------------------------
// This is really the only function of any use in this class for Step1.
// It is used when the results pane is displaying tree data such as nodes
// that show up in the scope pane.
//
STDMETHODIMP
CComponent::GetDisplayInfo
(
LPRESULTDATAITEM pResultItem // [in,out] Type of info required
)
{
static WCHAR* s_szSize = L"ABC";

_ASSERT( NULL != pResultItem );

if (pResultItem)
{
// Only responding for scope items for now.
if ( TRUE == pResultItem->bScopeItem )
{
if (pResultItem->mask & RDI_STR) // Looking for a string
{
if (0 == pResultItem->nCol )
pResultItem->str = (LPOLESTR)L"Geometry";
else if (1 == pResultItem->nCol )
pResultItem->str = (LPOLESTR)L"Child Folder";
else
pResultItem->str = (LPOLESTR)L"Else";
}

if (pResultItem->mask & RDI_IMAGE)
{
pResultItem->nImage = 0;
}
}
else
{
_ASSERT(FALSE);
}
}

return S_OK;

} // end GetDisplayInfo()


//---------------------------------------------------------------------------
// Determines what the result pane view should be
//
STDMETHODIMP
CComponent::GetResultViewType
(
long cookie, // [in] Specifies the unique identifier
BSTR *ppViewType, // [out] Points to address of the returned view type
long *pViewOptions // [out] Pointer to the MMC_VIEW_OPTIONS enumeration
)
{
//
// Ask for default listview.
//
*pViewOptions = MMC_VIEW_OPTIONS_NONE;
return S_FALSE;

} // end GetResultViewType()


//---------------------------------------------------------------------------
// Not used in Step1
//
HRESULT
CComponent::CompareObjects
(
LPDATAOBJECT lpDataObjectA, // [in] First data object to compare
LPDATAOBJECT lpDataObjectB // [in] Second data object to compare
)
{
return S_FALSE;

} // end CompareObjects()