18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH ACTIVEX<br />

Creating a popup menu for the PageLayoutControl<br />

In addition to adding control commands to the ToolbarControl to work with the<br />

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

Control commands. You will add a popup menu to your application that works<br />

with the PageLayoutControl. The popup menu will display whenever the right<br />

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

1. Add the following code to the general declarations area of the form:<br />

Option Explicit<br />

Private m_pToolbarMenu As IToolbarMenu ' The popup menu<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 Sub Form_Load()<br />

' Add Map navigation commands…<br />

' Create a new ToolbarMenu.<br />

Set m_pToolbarMenu = New ToolbarMenu<br />

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

Set m_pToolbarMenu.CommandPool = ToolbarControl1.CommandPool<br />

' Add commands to the ToolbarMenu.<br />

sProgID = "esriControlTools.ControlsPageZoomInFixedCommand"<br />

m_pToolbarMenu.AddItem sProgID, , , False, esriCommandStyleIconAndText<br />

sProgID = "esriControlTools.ControlsPageZoomOutFixedCommand"<br />

m_pToolbarMenu.AddItem sProgID, , , False, esriCommandStyleIconAndText<br />

sProgID = "esriControlTools.ControlsPageZoomWholePageCommand"<br />

m_pToolbarMenu.AddItem sProgID, , , False, esriCommandStyleIconAndText<br />

sProgID = "esriControlTools.ControlsPageZoomPageToLastExtentBackCommand"<br />

m_pToolbarMenu.AddItem sProgID, , , True, esriCommandStyleIconAndText<br />

sProgID = "esriControlTools.ControlsPageZoomPageToLastExtentForwardCommand"<br />

m_pToolbarMenu.AddItem sProgID, , , False, esriCommandStyleIconAndText<br />

' Set the hook to the PageLayoutControl.<br />

m_pToolbarMenu.SetHook PageLayoutControl1<br />

' Load a preauthored…<br />

End Sub<br />

3. Add the following code to the PageLayoutControl1_OnMouseDown event.<br />

Private Sub PageLayoutControl1_OnMouseDown(ByVal button As Long, ByVal<br />

shift As Long, ByVal x As Long, ByVal y As Long, ByVal pageX As<br />

Double, ByVal pageY As Double)<br />

' Popup the ToolbarMenu.<br />

If button = vbRightButton Then<br />

m_pToolbarMenu.PopupMenu x, y, PageLayoutControl1.hWnd<br />

End If<br />

End Sub<br />

290 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!