#ifndef __[!UpperShortName]_H_
#define __[!UpperShortName]_H_
#include "resource.h"
#include <atlsnap.h>
[!if=(IExtendPropertySheet, "TRUE)]
class [!ClassName]Page : public CPropertyPageImpl<[!ClassName]Page>
{
public :
[!ClassName]Page(TCHAR* pTitle = NULL) : CPropertyPageImpl<[!ClassName]Page> (pTitle)
{
}
enum { IDD = [!IDD_PROPPAGE] };
BEGIN_MSG_MAP([!ClassName]Page)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
CHAIN_MSG_MAP(CPropertyPageImpl<[!ClassName]Page>)
END_MSG_MAP()
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
::SendMessage(GetParent(), PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
return 1;
}
};
[!endif]
class [!ClassName]Data : public CSnapInDataObjectImpl<[!ClassName]Data>,
public ISnapInDataInterfaceImpl<[!ClassName]Data>,
public CComObjectRoot
{
static const GUID* m_NODETYPE;
static const TCHAR* m_SZNODETYPE;
static const TCHAR* m_SZDISPLAY_NAME;
static const CLSID* m_SNAPIN_CLASSID;
public:
static CComPtr<IControlbar> m_spControlBar;
public:
BEGIN_COM_MAP([!ClassName]Data)
COM_INTERFACE_ENTRY(IDataObject)
COM_INTERFACE_ENTRY(ISnapInDataInterface)
END_COM_MAP()
[!if=(IExtendContextMenu, "TRUE)]
BEGIN_SNAPINCOMMAND_MAP([!ClassName]Data)
END_SNAPINCOMMAND_MAP()
[!else]
[!if=(IExtendControlBar, "TRUE)]
BEGIN_SNAPINCOMMAND_MAP([!ClassName]Data)
END_SNAPINCOMMAND_MAP
[!endif]
[!endif]
[!if=(IExtendContextMenu, "TRUE)]
SNAPINMENUID([!IDR_MENU])
[!endif]
[!if=(IExtendControlBar, "TRUE)]
BEGIN_SNAPINTOOLBARID_MAP([!ClassName]Data)
[!if(VC)]
SNAPINTOOLBARID_ENTRY([!IDR_TOOLBAR])
[!else]
#error Please create a toolbar resource with the id [!IDR_TOOLBAR]
SNAPINTOOLBARID_ENTRY([!IDR_TOOLBAR])
[!endif]
END_SNAPINTOOLBARID_MAP()
[!endif]
[!ClassName]Data()
{
}
~[!ClassName]Data()
{
}
[!if=(IExtendPropertySheet, "TRUE)]
STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
long handle, IUnknown* pUnk)
{
[!ClassName]Page* pPage = new [!ClassName]Page(_T("[!ShortName]"));
lpProvider->AddPage(pPage->Create());
return S_OK;
}
STDMETHOD(QueryPagesFor)(void)
{
return S_OK;
}
[!endif]
void* GetNodeType()
{
return (void*)m_NODETYPE;
}
void* GetSZNodeType()
{
return (void*)m_SZNODETYPE;
}
void* GetDisplayName()
{
return (void*)m_SZDISPLAY_NAME;
}
void* GetSnapInCLSID()
{
return (void*)m_SNAPIN_CLASSID;
}
void PopulateChildren()
{
}
};
class [!ClassName]Component : public CComObjectRootEx<CComSingleThreadModel>,
public IComponentImpl<[!ClassName]Component>,
[!if=(IExtendPropertySheet, "TRUE)]
public IExtendPropertySheetImpl<[!ClassName]Component>,
[!endif]
[!if=(IExtendContextMenu, "TRUE)]
public IExtendContextMenuImpl<[!ClassName]Component>,
[!endif]
[!if=(IExtendControlBar, "TRUE)]
public IExtendControlbarImpl<[!ClassName]Component>,
[!endif]
public IPersistStream
{
public:
BEGIN_COM_MAP([!ClassName]Component)
COM_INTERFACE_ENTRY(IComponent)
[!if=(IExtendPropertySheet, "TRUE)]
COM_INTERFACE_ENTRY(IExtendPropertySheet)
[!endif]
[!if=(IExtendContextMenu, "TRUE)]
COM_INTERFACE_ENTRY(IExtendContextMenu)
[!endif]
[!if=(IExtendControlBar, "TRUE)]
COM_INTERFACE_ENTRY(IExtendControlbar)
[!endif]
COM_INTERFACE_ENTRY(IPersistStream)
END_COM_MAP()
public:
[!ClassName]Component()
{
}
STDMETHOD(GetClassID)(CLSID *pClassID)
{
ATLTRACENOTIMPL("CSnapInComponent::GetClassID");
}
STDMETHOD(IsDirty)()
{
ATLTRACENOTIMPL("CSnapInComponent::IsDirty");
}
STDMETHOD(Load)(IStream *pStm)
{
ATLTRACENOTIMPL("CSnapInComponent::Load");
}
STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty)
{
ATLTRACENOTIMPL("CSnapInComponent::Save");
}
STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize)
{
ATLTRACENOTIMPL("CSnapInComponent::GetSizeMax");
}
};
class [!ClassName]ComponentData : public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<[!ClassName]ComponentData, &CLSID_[!CoClassName]>,
public IComponentDataImpl<[!ClassName]ComponentData, [!ClassName]Component>,
[!if=(IExtendPropertySheet, "TRUE)]
public IExtendPropertySheetImpl<[!ClassName]Component>,
[!endif]
[!if=(IExtendContextMenu, "TRUE)]
public IExtendContextMenuImpl<[!ClassName]Component>,
[!endif]
[!if=(IExtendControlBar, "TRUE)]
public IExtendControlbarImpl<[!ClassName]Component>,
[!endif]
public IPersistStream
{
public:
[!ClassName]ComponentData ()
{
CComObject <[!ClassName]Data> *pData;
CComObject <[!ClassName]Data>::CreateInstance(&pData);
lstrcpy(pData->m_pszDisplayName, OLESTR("[!ClassName]"));
pData->InitParentList(NULL);
pData->QueryInterface(IID_IUnknown, (void**)&m_spNode);
}
BEGIN_COM_MAP([!ClassName]ComponentData)
COM_INTERFACE_ENTRY(IComponentData)
[!if=(IExtendPropertySheet, "TRUE)]
COM_INTERFACE_ENTRY(IExtendPropertySheet)
[!endif]
[!if=(IExtendContextMenu, "TRUE)]
COM_INTERFACE_ENTRY(IExtendContextMenu)
[!endif]
[!if=(IExtendControlBar, "TRUE)]
COM_INTERFACE_ENTRY(IExtendControlbar)
[!endif]
COM_INTERFACE_ENTRY(IPersistStream)
END_COM_MAP()
DECLARE_REGISTRY_RESOURCEID([!IDR_REGISTRYID])
DECLARE_NOT_AGGREGATABLE([!ClassName]ComponentData)
STDMETHOD(GetClassID)(CLSID *pClassID)
{
ATLTRACENOTIMPL("CSnapInObject::GetClassID");
}
STDMETHOD(IsDirty)()
{
ATLTRACENOTIMPL("CSnapInObject::IsDirty");
}
STDMETHOD(Load)(IStream *pStm)
{
ATLTRACENOTIMPL("CSnapInObject::Load");
}
STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty)
{
ATLTRACENOTIMPL("CSnapInObject::Save");
}
STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize)
{
ATLTRACENOTIMPL("CSnapInObject::GetSizeMax");
}
STDMETHOD(Initialize)(LPUNKNOWN pUnknown)
{
HRESULT hr = IComponentDataImpl<[!ClassName]ComponentData, [!ClassName]Component >::Initialize(pUnknown);
if (FAILED(hr))
return hr;
CComPtr<IImageList> spImageList;
if (m_spConsole->QueryScopeImageList(&spImageList) != S_OK)
{
ATLTRACE(_T("IConsole::QueryScopeImageList failed\n"));
return E_UNEXPECTED;
}
// Load bitmaps associated with the scope pane
// and add them to the image list
// Loads the default bitmaps generated by the wizard
// Change as needed
HBITMAP hBitmap16 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE([!IDB_SNAPIN16]));
if (hBitmap16 == NULL)
return S_OK;
HBITMAP hBitmap32 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE([!IDB_SNAPIN32]));
if (hBitmap32 == NULL)
return S_OK;
if (spImageList->ImageListSetStrip((long*)hBitmap16,
(long*)hBitmap32, 0, RGB(0, 128, 128)) != S_OK)
{
ATLTRACE(_T("IImageList::ImageListSetStrip failed\n"));
return E_UNEXPECTED;
}
return S_OK;
}
};
#endif