ArcObjects Library Reference

Create PopUp ToolbarPalette Snippet

Stub code for creating a popup palette.

[C#]

/// <summary>
/// A member variable for that is the ToolbarPalette to create.
/// </summary>
/// <remarks>This snippet assumes a ToolbarControl has a MapControl, PageLayoutControl 
/// GlobeControl or SceneControl buddy set.</remarks>
public ESRI.ArcGIS.Controls.IToolbarPalette m_ToolbarPalette;

/// <summary>
/// Create the ToolbarPalette.
/// </summary>
/// <param name="toolbarControl"></param>
/// <remarks>
/// Call to create a ToolbarPalette. For example, if a ToolbarControl
/// named AxToolbarControl1 exists use the following code:
/// CreateToolbarPalette(AxToolbarControl1.Object)
///</remarks>
public void CreateToolbarPalette(ESRI.ArcGIS.Controls.IToolbarControl toolbarControl)
{
  // Create a new ToolbarPalette
  m_ToolbarPalette = new ESRI.ArcGIS.Controls.ToolbarPaletteClass();

  // Share the ToolbarControl's command pool
  m_ToolbarPalette.CommandPool = toolbarControl.CommandPool;

  // Set the hook
  m_ToolbarPalette.SetHook(toolbarControl.Buddy);

  // Add commands items to the ToolbarPalette. 
  // Add additional commands based on the mapping control being used
  // For a listing of the ArcGIS Engine Controls CLSID or ProgID see: ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ESRI.EDNv9.2/NET_Engine/shared/reference/guids_ctrls_cmds.htm
  m_ToolbarPalette.AddItem("esriControls.ControlsSelectTool", -1, -1);
  m_ToolbarPalette.AddItem("esriControls.ControlsInkHighlightTool", -1, -1);
  m_ToolbarPalette.AddItem("esriControls.ControlsInkPenTool", -1, -1);
}

/// <summary>
/// Open the Context Menu that has the ToolbarPalette.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="hWnd"></param>
/// <remarks>
/// Call to popup the ToolbarPalette on the display of the ToolbarControl's buddy. 
/// For example, if AxToolbarControl1 is buddied to AxMapControl1 use the following 
/// code from one of the MapControl's mouse events:
/// PopupToolbarPalette(e.x, e.y, AxMapControl1.hWnd)
/// </remarks>
public void PopupToolbarPalette(System.Int32 x, System.Int32 y, System.Int32 hWnd)
{
  m_ToolbarPalette.PopupPalette(x, y, hWnd);
}
[Visual Basic .NET]

''' <summary>
''' A member variable for that is the ToolbarPalette to create.
''' </summary>
''' <remarks>This snippet assumes a ToolbarControl has a MapControl, PageLayoutControl 
''' GlobeControl or SceneControl buddy set.</remarks>
Private m_ToolbarPalette As ESRI.ArcGIS.Controls.IToolbarPalette

''' <summary>
''' Create the ToolbarPalette.
''' </summary>
''' <param name="toolbarControl"></param>
''' <remarks>
''' Call to create a ToolbarPalette. For example, if a ToolbarControl
''' named AxToolbarControl1 exists use the following code:
''' CreateToolbarPalette(AxToolbarControl1.Object)
'''</remarks>
Private Sub CreateToolbarPalette(ByVal toolbarControl As ESRI.ArcGIS.Controls.IToolbarControl)

  ' Create a new ToolbarPalette
  m_ToolbarPalette = New ESRI.ArcGIS.Controls.ToolbarPaletteClass()

  ' Share the ToolbarControl's command pool
  m_ToolbarPalette.CommandPool = toolbarControl.CommandPool

  ' Set the hook
  m_ToolbarPalette.SetHook(toolbarControl.Buddy)

  ' Add commands items to the ToolbarPalette. 
  ' Add additional commands based on the mapping control being used
  ' For a listing of the ArcGIS Engine Controls CLSID or ProgID see: ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ESRI.EDNv9.2/NET_Engine/shared/reference/guids_ctrls_cmds.htm
  m_ToolbarPalette.AddItem("esriControls.ControlsSelectTool", -1, -1)
  m_ToolbarPalette.AddItem("esriControls.ControlsInkHighlightTool", -1, -1)
  m_ToolbarPalette.AddItem("esriControls.ControlsInkPenTool", -1, -1)

End Sub

''' <summary>
''' Open the Context Menu that has the ToolbarPalette.
''' </summary>
''' <param name="x"></param>
''' <param name="y"></param>
''' <param name="hWnd"></param>
''' <remarks>
''' Call to popup the ToolbarPalette on the display of the ToolbarControl's buddy. 
''' For example, if AxToolbarControl1 is buddied to AxMapControl1 use the following 
''' code from one of the MapControl's mouse events:
''' PopupToolbarPalette(e.x, e.y, AxMapControl1.hWnd)
''' </remarks>
Private Sub PopupToolbarPalette(ByVal x As System.Int32, ByVal y As System.Int32, ByVal hWnd As System.Int32)

  m_ToolbarPalette.PopupPalette(x, y, hWnd)

End Sub


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Controls
  • ESRI.ArcGIS.System