共用方式為


Snap-In Object Macros

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Snap-In Object Macros.

These macros provide support for snap-in extensions.

BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP Marks the beginning of the snap-in extension data class map for a Snap-In object.
BEGIN_SNAPINTOOLBARID_MAP Marks the beginning of the toolbar map for a Snap-In object.
END_EXTENSION_SNAPIN_NODEINFO_MAP Marks the end of the snap-in extension data class map for a Snap-In object.
END_SNAPINTOOLBARID_MAP Marks the end of the toolbar map for a Snap-In object.
EXTENSION_SNAPIN_DATACLASS Creates a data member for the data class of the snap-in extension.
EXTENSION_SNAPIN_NODEINFO_ENTRY Enters a snap-in extension data class into the snap-in extension data class map of the Snap-In object.
SNAPINMENUID Declares the ID of the context menu used by the Snap-In object.
SNAPINTOOLBARID_ENTRY Enters a toolbar into the toolbar map of the Snap-In object.

BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP

Marks the beginning of the snap-in extension data class map.

BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP
(classname)

Parameters

classname
[in] The name of the snap-in extension data class.

Remarks

Start your snap-in extension map with the BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP macro, add entries for each of your snap-in extension data types with the EXTENSION_SNAPIN_NODEINFO_ENTRY macro, and complete the map with the END_EXTENSION_SNAPIN_NODEINFO_MAP macro.

Example

class CMyExtSnapinExtData : 
   public CSnapInItemImpl<CMyExtSnapinExtData>,
   public CMySnapinBase
{
public:
   CMyExtSnapinExtData() {}
};

class CMyExtSnapin : 
   public CComObjectRoot,
   public CSnapInObjectRoot<1, CMyExtSnapin>,
   public IComponentDataImpl<CMyExtSnapin, CMyExtSnapin>
{
public:
   CMyExtSnapin() {}

   BEGIN_COM_MAP(CMyExtSnapin)
   END_COM_MAP()

   EXTENSION_SNAPIN_DATACLASS(CMyExtSnapinExtData)

   BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP(CMyExtSnapin)
      EXTENSION_SNAPIN_NODEINFO_ENTRY(CMyExtSnapinExtData)
   END_EXTENSION_SNAPIN_NODEINFO_MAP()
};

BEGIN_SNAPINTOOLBARID_MAP

Declares the beginning of the toolbar ID map for the Snap-In object.

BEGIN_SNAPINTOOLBARID_MAP
(_class)

Parameters

_class
[in] Specifies the Snap-In object class.

Example

class CMySnapinData : 
   public CSnapInItemImpl<CMySnapinData>,
   public CMySnapinBase
{
public:
   CMySnapinData() {}

   BEGIN_SNAPINTOOLBARID_MAP(CMySnapinData)
      // IDR_MYSNAPINTOOLBAR is the resource ID of a toolbar resource.
      SNAPINTOOLBARID_ENTRY(IDR_MYSNAPINTOOLBAR)
   END_SNAPINTOOLBARID_MAP()
};

END_EXTENSION_SNAPIN_NODEINFO_MAP

Marks the end of the snap-in extension data class map.

END_EXTENSION_SNAPIN_NODEINFO_MAP
()

Remarks

Start your snap-in extension map with the BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP macro, add entries for each of your extension snap-in data types with the EXTENSION_SNAPIN_NODEINFO_ENTRY macro, and complete the map with the END_EXTENSION_SNAPIN_NODEINFO_MAP macro.

Example

See the example for BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP.

END_SNAPINTOOLBARID_MAP

Declares the end of the toolbar ID map for the Snap-In object.

END_SNAPINTOOLBARID_MAP(Â
    _class Â)

Parameters

_class
[in] Specifies the Snap-In object class.

Example

See the example for BEGIN_SNAPINTOOLBARID_MAP.

EXTENSION_SNAPIN_DATACLASS

Adds a data member to the snap-in extension data class for an ISnapInItemImpl-derived class.

EXTENSION_SNAPIN_DATACLASS(Â
    dataClass Â)

Parameters

dataClass
[in] The data class of the snap-in extension.

Remarks

This class should also be entered into a snap-in extension data class map. Start your snap-in extension data class map with the BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP macro, add entries for each of your snap-in extension data types with the EXTENSION_SNAPIN_NODEINFO_ENTRY macro, and complete the map with the END_EXTENSION_SNAPIN_NODEINFO_MAP macro.

Example

class CMyExtSnapinExtData : 
   public CSnapInItemImpl<CMyExtSnapinExtData>,
   public CMySnapinBase
{
public:
   CMyExtSnapinExtData() {}
};

class CMyExtSnapin : 
   public CComObjectRoot,
   public CSnapInObjectRoot<1, CMyExtSnapin>,
   public IComponentDataImpl<CMyExtSnapin, CMyExtSnapin>
{
public:
   CMyExtSnapin() {}

   BEGIN_COM_MAP(CMyExtSnapin)
   END_COM_MAP()

   EXTENSION_SNAPIN_DATACLASS(CMyExtSnapinExtData)

   BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP(CMyExtSnapin)
      EXTENSION_SNAPIN_NODEINFO_ENTRY(CMyExtSnapinExtData)
   END_EXTENSION_SNAPIN_NODEINFO_MAP()
};

EXTENSION_SNAPIN_NODEINFO_ENTRY

Adds a snap-in extension data class to the snap-in extension data class map.

EXTENSION_SNAPIN_NODEINFO_ENTRY(Â
    dataClass Â)

Parameters

dataClass
[in] The data class of the snap-in extension.

Remarks

Start your snap-in extension data class map with the BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP macro, add entries for each of your snap-in extension data types with the EXTENSION_SNAPIN_NODEINFO_ENTRY macro, and complete the map with the END_EXTENSION_SNAPIN_NODEINFO_MAP macro.

Example

See the example for BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP.

SNAPINMENUID

Use this macro to declare the context menu resource of the Snap-In object.

SNAPINMENUID(Â
    id Â)

Parameters

id
[in] Identifies the context menu of the Snap-In object.

SNAPINTOOLBARID_ENTRY

Use this macro to enter a toolbar ID into the Snap-In object's toolbar ID map.

SNAPINTOOLBARID_ENTRY(Â
    id Â)

Parameters

id
[in] Identifies the toolbar control.

Remarks

The BEGIN_SNAPINTOOLBARID_MAP macro marks the beginning of the toolbar ID map; the END_SNAPINTOOLBARID_MAP macro marks the end.

Example

See the example for BEGIN_SNAPINTOOLBARID_MAP.

See Also

Macros