18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING APPLICATIONS WITH WINDOWS CONTROLS<br />

Creating a popup menu for the PageLayoutControl<br />

As well as adding <strong>ArcGIS</strong> <strong>Engine</strong> commands to the ToolbarControl to work with<br />

the buddy control, as in the previous step, you can also create popup menus from<br />

the <strong>ArcGIS</strong> <strong>Engine</strong> commands. You will add a popup menu that works with the<br />

PageLayoutControl to your application. The popup menu will display whenever<br />

the right mouse button is used on the display area of the PageLayoutControl.<br />

1. Add the following member variable to the class:<br />

public class Form1 : System.Windows.Forms.Form<br />

{<br />

private ESRI.<strong>ArcGIS</strong>.ToolbarControl.AxToolbarControl<br />

axToolbarControl1;<br />

private ESRI.<strong>ArcGIS</strong>.TOCControl.AxTOCControl axTOCControl1;<br />

private ESRI.<strong>ArcGIS</strong>.MapControl.AxMapControl axMapControl1;<br />

private ESRI.<strong>ArcGIS</strong>.PageLayoutControl.AxPageLayoutControl<br />

axPageLayoutControl1;<br />

private IToolbarMenu m_ToolbarMenu = new ToolbarMenuClass(); // The<br />

popup menu<br />

…<br />

2. Add the following code to the Form_Load event after the code, adding the<br />

commands to the ToolbarControl but before the load document code.<br />

private void Form1_Load(object sender, System.EventArgs e)<br />

{<br />

// Add Map navigation commands…<br />

// Share the ToolbarControl’s command pool.<br />

m_ToolbarMenu.CommandPool = axToolbarControl1.CommandPool;<br />

// Add commands to the ToolbarMenu.<br />

progID = "esriControlToolsPageLayout.ControlsPageZoomInFixedCommand";<br />

m_ToolbarMenu.AddItem(progID, -1, -1, false,<br />

esriCommandStyles.esriCommandStyleIconAndText);<br />

progID = "esriControlToolsPageLayout.ControlsPageZoomOutFixedCommand";<br />

Chapter 6 • <strong>Developer</strong> scenarios • 341

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!