ArcObjects Library Reference  

CulturalResources

About the Configure a command for a specific locale Sample

[C#]

CulturalResources.cs

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.Reflection;

using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.ADF;
using ESRI.ArcGIS;


namespace Controls
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;
        private TableLayoutPanel tableLayoutPanel1;
        private Label lblCulture;
        private AxLicenseControl axLicenseControl1;
        private AxPageLayoutControl axPageLayoutControl1;
        private AxTOCControl axTOCControl1;
        private AxToolbarControl axToolbarControl1;
        ToolbarMenu m_pToolbarMenu = new ToolbarMenuClass();

        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.lblCulture = new System.Windows.Forms.Label();
            this.axLicenseControl1 = new ESRI.ArcGIS.Controls.AxLicenseControl();
            this.axPageLayoutControl1 = new ESRI.ArcGIS.Controls.AxPageLayoutControl();
            this.axTOCControl1 = new ESRI.ArcGIS.Controls.AxTOCControl();
            this.axToolbarControl1 = new ESRI.ArcGIS.Controls.AxToolbarControl();
            this.tableLayoutPanel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axPageLayoutControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).BeginInit();
            this.SuspendLayout();
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.ColumnCount = 2;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25.05695F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 74.94305F));
            this.tableLayoutPanel1.Controls.Add(this.lblCulture, 0, 2);
            this.tableLayoutPanel1.Controls.Add(this.axLicenseControl1, 1, 2);
            this.tableLayoutPanel1.Controls.Add(this.axPageLayoutControl1, 1, 1);
            this.tableLayoutPanel1.Controls.Add(this.axTOCControl1, 0, 1);
            this.tableLayoutPanel1.Controls.Add(this.axToolbarControl1, 0, 0);
            this.tableLayoutPanel1.Location = new System.Drawing.Point(2, 2);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 3;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.598214F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 90.40179F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 45F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(878, 514);
            this.tableLayoutPanel1.TabIndex = 6;
            // 
            // lblCulture
            // 
            this.lblCulture.AutoSize = true;
            this.lblCulture.Location = new System.Drawing.Point(3, 468);
            this.lblCulture.Name = "lblCulture";
            this.lblCulture.Size = new System.Drawing.Size(46, 17);
            this.lblCulture.TabIndex = 0;
            this.lblCulture.Text = "label1";
            // 
            // axLicenseControl1
            // 
            this.axLicenseControl1.Enabled = true;
            this.axLicenseControl1.Location = new System.Drawing.Point(223, 471);
            this.axLicenseControl1.Name = "axLicenseControl1";
            this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState")));
            this.axLicenseControl1.Size = new System.Drawing.Size(32, 32);
            this.axLicenseControl1.TabIndex = 1;
            // 
            // axPageLayoutControl1
            // 
            this.axPageLayoutControl1.Location = new System.Drawing.Point(223, 48);
            this.axPageLayoutControl1.Name = "axPageLayoutControl1";
            this.axPageLayoutControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axPageLayoutControl1.OcxState")));
            this.axPageLayoutControl1.Size = new System.Drawing.Size(652, 417);
            this.axPageLayoutControl1.TabIndex = 2;
            // 
            // axTOCControl1
            // 
            this.axTOCControl1.Location = new System.Drawing.Point(3, 48);
            this.axTOCControl1.Name = "axTOCControl1";
            this.axTOCControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axTOCControl1.OcxState")));
            this.axTOCControl1.Size = new System.Drawing.Size(214, 417);
            this.axTOCControl1.TabIndex = 3;
            // 
            // axToolbarControl1
            // 
            this.tableLayoutPanel1.SetColumnSpan(this.axToolbarControl1, 2);
            this.axToolbarControl1.Location = new System.Drawing.Point(3, 3);
            this.axToolbarControl1.Name = "axToolbarControl1";
            this.axToolbarControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axToolbarControl1.OcxState")));
            this.axToolbarControl1.Size = new System.Drawing.Size(872, 28);
            this.axToolbarControl1.TabIndex = 4;
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
            this.ClientSize = new System.Drawing.Size(892, 528);
            this.Controls.Add(this.tableLayoutPanel1);
            this.MaximumSize = new System.Drawing.Size(900, 568);
            this.MinimumSize = new System.Drawing.Size(900, 568);
            this.Name = "Form1";
            this.Text = "CulturalResources";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axPageLayoutControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).EndInit();
            this.ResumeLayout(false);

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            
            
            if (!RuntimeManager.Bind(ProductCode.Engine))
            {
                if (!RuntimeManager.Bind(ProductCode.Desktop))
                {
                    MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
                    return;
                }
            }
            Application.Run(new Form1());
        }

        private void Form1_Load(object sender, System.EventArgs e)
        {

            System.Globalization.CultureInfo pCulture;

            //Set the Thread UI Culture manually by uncommenting one of the three cultures 
            //that you wish to set below.

            pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR");
            //pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
            //pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es-ES");
            
            //Set the UI Culture
            System.Threading.Thread.CurrentThread.CurrentUICulture = pCulture;

            //Confirm that the Thread UI Culture is set.
            lblCulture.Text = "Current Thread UI Culture = " + System.Threading.Thread.CurrentThread.CurrentUICulture.DisplayName;
           
            //Add command to open an mxd document
            string sProgID;

            sProgID = "esriControls.ControlsOpenDocCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Add Map navigation commands
            sProgID = "esriControls.ControlsMapZoomInTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsMapZoomOutTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsMapPanTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsMapFullExtentCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Add PageLayout navigation commands
            sProgID = "esriControls.ControlsPageZoomInTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPageZoomOutTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPagePanTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPageZoomWholePageCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPageZoomPageToLastExtentBackCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPageZoomPageToLastExtentForwardCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsSelectTool";

            //Add Culture Tool
            axToolbarControl1.AddItem("VBCSharpCultureSample.CultureTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText);

            //Add Culture Command
            axToolbarControl1.AddItem("VBCSharpCultureSample.CultureCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);

            //Add Culture Menu
            axToolbarControl1.AddItem("VBCSharpCultureSample.CultureMenu", -1, -1, false, 0, esriCommandStyles.esriCommandStyleTextOnly);

            
            //Add the MenuDef to the ToolbarMenu
            string progID = "VBCSharpCultureSample.CultureMenu";
            m_pToolbarMenu.AddItem(progID, -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);

            //Set the Toolbarmenu's hook
            m_pToolbarMenu.SetHook(axToolbarControl1);

            //Set Buddy Controls
            axTOCControl1.SetBuddyControl(axPageLayoutControl1);
            axToolbarControl1.SetBuddyControl(axPageLayoutControl1);
        }

        private void axPageLayoutControl1_OnMouseUp(object sender, IPageLayoutControlEvents_OnMouseUpEvent e)
        {
            //Display the Popup Menu so that it appears to the right of the mouse click 

            if (e.button == 2) 
            {
                //Cast to the IToolbarMenu2 interface of the m_pToolbarMenu
                IToolbarMenu2 m_pToolbarMenu2 = (IToolbarMenu2)m_pToolbarMenu;
 
                //Align the Menu so that it appears to the right of the user mouse click
                m_pToolbarMenu2.AlignLeft = true;

                //Popup the menu
                m_pToolbarMenu.PopupMenu(e.x, e.y, axPageLayoutControl1.hWnd);
            }
        }

    }
}
[Visual Basic .NET]

CulturalResources.vb

Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS


Public Class CulturalResources
    Inherits System.Windows.Forms.Form
    Friend WithEvents lblCulture2 As System.Windows.Forms.Label
    Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
    Friend WithEvents AxToolbarControl1 As ESRI.ArcGIS.Controls.AxToolbarControl
    Friend WithEvents AxTOCControl1 As ESRI.ArcGIS.Controls.AxTOCControl
    Friend WithEvents AxPageLayoutControl1 As ESRI.ArcGIS.Controls.AxPageLayoutControl
    Friend WithEvents AxLicenseControl1 As ESRI.ArcGIS.Controls.AxLicenseControl
    Private m_pToolbarMenu As ToolbarMenu


#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        'Release COM objects
        ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown()

        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(CulturalResources))
        Me.lblCulture2 = New System.Windows.Forms.Label
        Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel
        Me.AxToolbarControl1 = New ESRI.ArcGIS.Controls.AxToolbarControl
        Me.AxTOCControl1 = New ESRI.ArcGIS.Controls.AxTOCControl
        Me.AxPageLayoutControl1 = New ESRI.ArcGIS.Controls.AxPageLayoutControl
        Me.AxLicenseControl1 = New ESRI.ArcGIS.Controls.AxLicenseControl
        Me.TableLayoutPanel1.SuspendLayout()
        CType(Me.AxToolbarControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.AxTOCControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.AxPageLayoutControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.AxLicenseControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'lblCulture2
        '
        Me.lblCulture2.AutoSize = True
        Me.lblCulture2.Location = New System.Drawing.Point(3, 479)
        Me.lblCulture2.Name = "lblCulture2"
        Me.lblCulture2.Size = New System.Drawing.Size(53, 17)
        Me.lblCulture2.TabIndex = 10
        Me.lblCulture2.Text = "Culture"
        '
        'TableLayoutPanel1
        '
        Me.TableLayoutPanel1.ColumnCount = 2
        Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 21.18451!))
        Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 78.81549!))
        Me.TableLayoutPanel1.Controls.Add(Me.lblCulture2, 0, 2)
        Me.TableLayoutPanel1.Controls.Add(Me.AxToolbarControl1, 0, 0)
        Me.TableLayoutPanel1.Controls.Add(Me.AxTOCControl1, 0, 1)
        Me.TableLayoutPanel1.Controls.Add(Me.AxPageLayoutControl1, 1, 1)
        Me.TableLayoutPanel1.Controls.Add(Me.AxLicenseControl1, 1, 2)
        Me.TableLayoutPanel1.Location = New System.Drawing.Point(2, 3)
        Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
        Me.TableLayoutPanel1.RowCount = 3
        Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 7.30689!))
        Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 92.69311!))
        Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 33.0!))
        Me.TableLayoutPanel1.Size = New System.Drawing.Size(878, 513)
        Me.TableLayoutPanel1.TabIndex = 11
        '
        'AxToolbarControl1
        '
        Me.TableLayoutPanel1.SetColumnSpan(Me.AxToolbarControl1, 2)
        Me.AxToolbarControl1.Location = New System.Drawing.Point(3, 3)
        Me.AxToolbarControl1.Name = "AxToolbarControl1"
        Me.AxToolbarControl1.OcxState = CType(resources.GetObject("AxToolbarControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxToolbarControl1.Size = New System.Drawing.Size(870, 28)
        Me.AxToolbarControl1.TabIndex = 11
        '
        'AxTOCControl1
        '
        Me.AxTOCControl1.Location = New System.Drawing.Point(3, 38)
        Me.AxTOCControl1.Name = "AxTOCControl1"
        Me.AxTOCControl1.OcxState = CType(resources.GetObject("AxTOCControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxTOCControl1.Size = New System.Drawing.Size(177, 436)
        Me.AxTOCControl1.TabIndex = 12
        '
        'AxPageLayoutControl1
        '
        Me.AxPageLayoutControl1.Location = New System.Drawing.Point(188, 38)
        Me.AxPageLayoutControl1.Name = "AxPageLayoutControl1"
        Me.AxPageLayoutControl1.OcxState = CType(resources.GetObject("AxPageLayoutControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxPageLayoutControl1.Size = New System.Drawing.Size(686, 436)
        Me.AxPageLayoutControl1.TabIndex = 13
        '
        'AxLicenseControl1
        '
        Me.AxLicenseControl1.Enabled = True
        Me.AxLicenseControl1.Location = New System.Drawing.Point(188, 482)
        Me.AxLicenseControl1.Name = "AxLicenseControl1"
        Me.AxLicenseControl1.OcxState = CType(resources.GetObject("AxLicenseControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxLicenseControl1.Size = New System.Drawing.Size(32, 32)
        Me.AxLicenseControl1.TabIndex = 14
        '
        'CulturalResources
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
        Me.ClientSize = New System.Drawing.Size(892, 528)
        Me.Controls.Add(Me.TableLayoutPanel1)
        Me.MaximumSize = New System.Drawing.Size(900, 568)
        Me.MinimumSize = New System.Drawing.Size(900, 568)
        Me.Name = "CulturalResources"
        Me.Text = "Form1"
        Me.TableLayoutPanel1.ResumeLayout(False)
        Me.TableLayoutPanel1.PerformLayout()
        CType(Me.AxToolbarControl1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.AxTOCControl1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.AxPageLayoutControl1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.AxLicenseControl1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    <STAThread()> _
    Shared Sub Main()

        'Load runtime 
        If Not RuntimeManager.Bind(ProductCode.Engine) Then
            If Not RuntimeManager.Bind(ProductCode.Desktop) Then
                MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.")
                System.Environment.Exit(1) ' Force exit or other indication in the application
            End If
        End If

        Application.Run(New CulturalResources())
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim pCulture As System.Globalization.CultureInfo

        'Set the Thread UI Culture manually by uncommenting one of the three cultures 
        'that you wish to set below.

        pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR")
        'pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
        'pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es-ES")

        'Set the Thread UI Culture
        System.Threading.Thread.CurrentThread.CurrentUICulture = pCulture

        'Confirm that the Thread UI Culture is set.
        lblCulture2.Text = "Current Thread UI Culture = " + System.Threading.Thread.CurrentThread.CurrentUICulture.DisplayName

        Dim sProgID As String

        'Add command to open an mxd document
        sProgID = "esriControls.ControlsOpenDocCommand"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)

        'Add Map navigation commands
        sProgID = "esriControls.ControlsMapZoomInTool"
        AxToolbarControl1.AddItem(sProgID, -1, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsMapZoomOutTool"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsMapPanTool"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsMapFullExtentCommand"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)

        'Add PageLayout navigation commands
        sProgID = "esriControls.ControlsPageZoomInTool"
        AxToolbarControl1.AddItem(sProgID, -1, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsPageZoomOutTool"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsPagePanTool"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsPageZoomWholePageCommand"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsPageZoomPageToLastExtentBackCommand"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsPageZoomPageToLastExtentForwardCommand"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        sProgID = "esriControls.ControlsSelectTool"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)

        'Add Culture Tool
        sProgID = "VBDotNETCultureSample.CultureTool"
        AxToolbarControl1.AddItem(sProgID, -1, -1, True, 0, esriCommandStyles.esriCommandStyleIconAndText)

        'Add Culture Command
        sProgID = "VBDotNETCultureSample.CultureCommand"
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconAndText)

        'Add Culture Menu to Toolbar and Popup
        sProgID = "VBDotNETCultureSample.CultureMenu"

        'Add the Menu to a new ToolbarMenu to be used as the popup
        m_pToolbarMenu = New ToolbarMenu
        m_pToolbarMenu.AddItem(sProgID)
        m_pToolbarMenu.SetHook(AxToolbarControl1)

        'Add the Culture Menu to the ToolbarControl
        AxToolbarControl1.AddItem(sProgID, -1, -1, False, 0, esriCommandStyles.esriCommandStyleTextOnly)

        'Set Buddy Controls
        AxTOCControl1.SetBuddyControl(AxPageLayoutControl1)
        AxToolbarControl1.SetBuddyControl(AxPageLayoutControl1)

    End Sub


    Private Sub AxPageLayoutControl1_OnMouseDown(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent)

        'Display the Popup Menu so that it appears to the right of the click

        If e.button = 2 Then

            'Cast to the IToolbarMenu2 interface of the m_pToolbarMenu
            Dim m_pToolbarMenu2 As IToolbarMenu2
            m_pToolbarMenu2 = CType(m_pToolbarMenu, IToolbarMenu)

            'Align the Menu so that it appears to the right of the user mouse click
            m_pToolbarMenu2.AlignLeft = True

            'Popup the menu
            m_pToolbarMenu.PopupMenu(e.x, e.y, AxPageLayoutControl1.hWnd)
        End If

    End Sub

End Class