?? enginecontrols.frm
字號:
VERSION 5.00
Object = "{370A8DDA-7915-42DC-B4A1-77662C82B046}#1.0#0"; "TOCControl.ocx"
Object = "{B7D43581-3CBC-11D6-AA09-00104BB6FC1C}#1.0#0"; "ToolbarControl.ocx"
Object = "{C552EA90-6FBB-11D5-A9C1-00104BB6FC1C}#1.0#0"; "MapControl.ocx"
Object = "{BA01FAC9-2AB7-4CC9-9732-938340408ACE}#1.0#0"; "PageLayoutControl.ocx"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7890
ClientLeft = 60
ClientTop = 345
ClientWidth = 9660
LinkTopic = "Form1"
ScaleHeight = 7890
ScaleWidth = 9660
StartUpPosition = 3 'Windows Default
Begin VB.CheckBox chkCustomize
Caption = "Customize"
Height = 255
Left = 8520
TabIndex = 4
Top = 120
Width = 1095
End
Begin esriTOCControl.TOCControl TOCControl1
Height = 5055
Left = 120
OleObjectBlob = "EngineControls.frx":0000
TabIndex = 1
Top = 480
Width = 2775
End
Begin esriPageLayoutControl.PageLayoutControl PageLayoutControl1
Height = 7335
Left = 2880
OleObjectBlob = "EngineControls.frx":005D
TabIndex = 3
Top = 480
Width = 6735
End
Begin esriMapControl.MapControl MapControl1
Height = 2295
Left = 120
OleObjectBlob = "EngineControls.frx":0AFE
TabIndex = 2
Top = 5520
Width = 2775
End
Begin esriToolbarControl.ToolbarControl ToolbarControl1
Height = 390
Left = 120
OleObjectBlob = "EngineControls.frx":11B3
TabIndex = 0
Top = 120
Width = 8295
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Copyright 1995-2004 ESRI
' All rights reserved under the copyright laws of the United States.
' You may freely redistribute and use this sample code, with or without modification.
' Disclaimer: THE SAMPLE CODE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
' WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
' FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESRI OR
' CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
' OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
' SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
' INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY
' THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ARISING IN ANY
' WAY OUT OF THE USE OF THIS SAMPLE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF
' SUCH DAMAGE.
' For additional information contact: Environmental Systems Research Institute, Inc.
' Attn: Contracts Dept.
' 380 New York Street
' Redlands, California, U.S.A. 92373
' Email: contracts@esri.com
Option Explicit
Private m_pAoInitialize As IAoInitialize 'The initialization object
Private m_pToolbarMenu As IToolbarMenu 'The popup menu
Private m_pEnvelope As IEnvelope 'The envelope drawn on the MapControl
Private m_pFillSymbol As ISimpleFillSymbol 'The symbol used to draw the envelope on the MapControl
Private WithEvents m_pTransformEvents As DisplayTransformation 'The PageLayoutControl's focus map events
Attribute m_pTransformEvents.VB_VarHelpID = -1
Private WithEvents m_pCustomizeDialogEvents As CustomizeDialog 'The customize dialog events
Attribute m_pCustomizeDialogEvents.VB_VarHelpID = -1
Private m_pCustomizeDialog As ICustomizeDialog 'The customize dialog used by the ToolbarControl
Private Sub chkCustomize_Click()
'Show or hide the customize dialog
If chkCustomize.Value = 0 Then
m_pCustomizeDialog.CloseDialog
Else
m_pCustomizeDialog.StartDialog ToolbarControl1.hWnd
End If
End Sub
Private Sub Form_Load()
'Create a new AoInitialize object
Set m_pAoInitialize = New AoInitialize
If m_pAoInitialize Is Nothing Then
MsgBox "Unable to initialize. This application cannot run!"
Unload Form1
Exit Sub
End If
'Determine if the product is available
If m_pAoInitialize.IsProductCodeAvailable(esriLicenseProductCodeEngine) = esriLicenseAvailable Then
If m_pAoInitialize.Initialize(esriLicenseProductCodeEngine) <> esriLicenseCheckedOut Then
MsgBox "The initialization failed. This application cannot run!"
Unload Form1
Exit Sub
End If
Else
MsgBox "The ArcGIS Engine product is unavailable. This application cannot run!"
Unload Form1
Exit Sub
End If
'Create the customize dialog for the ToolbarControl
CreateCustomizeDialog
'Create symbol used on the MapConrol
CreateOverviewSymbol
'Set label editing to manual
TOCControl1.LabelEdit = esriTOCControlManual
Dim sProgID As String
'Add generic commands
sProgID = "esriControlTools.ControlsOpenDocCommand"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
'Add PageLayout navigation commands
sProgID = "esriControlTools.ControlsPageZoomInTool"
ToolbarControl1.AddItem sProgID, , , True, , esriCommandStyleIconOnly
sProgID = "esriControlTools.ControlsPageZoomOutTool"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
sProgID = "esriControlTools.ControlsPagePanTool"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
sProgID = "esriControlTools.ControlsPageZoomWholePageCommand"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
sProgID = "esriControlTools.ControlsPageZoomPageToLastExtentBackCommand"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
sProgID = "esriControlTools.ControlsPageZoomPageToLastExtentForwardCommand"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
'Add Map naviagtion commands
sProgID = "esriControlTools.ControlsMapZoomInTool"
ToolbarControl1.AddItem sProgID, , , True, , esriCommandStyleIconOnly
sProgID = "esriControlTools.ControlsMapZoomOutTool"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
sProgID = "esriControlTools.ControlsMapPanTool"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
sProgID = "esriControlTools.ControlsMapFullExtentCommand"
ToolbarControl1.AddItem sProgID, , , False, , esriCommandStyleIconOnly
'Add custom date tool
sProgID = "EngineScenarioCommands.AddDateTool"
ToolbarControl1.AddItem sProgID, , , True, , esriCommandStyleIconAndText
'Create a new ToolbarMenu
Set m_pToolbarMenu = New ToolbarMenu
'Share the ToolbarControl's command pool
Set m_pToolbarMenu.CommandPool = ToolbarControl1.CommandPool
'Add commands to the ToolbarMenu
sProgID = "esriControlTools.ControlsPageZoomInFixedCommand"
m_pToolbarMenu.AddItem sProgID, , , False, esriCommandStyleIconAndText
sProgID = "esriControlTools.ControlsPageZoomOutFixedCommand"
m_pToolbarMenu.AddItem sProgID, , , False, esriCommandStyleIconAndText
sProgID = "esriControlTools.ControlsPageZoomWholePageCommand"
m_pToolbarMenu.AddItem sProgID, , , False, esriCommandStyleIconAndText
sProgID = "esriControlTools.ControlsPageZoomPageToLastExtentBackCommand"
m_pToolbarMenu.AddItem sProgID, , , True, esriCommandStyleIconAndText
sProgID = "esriControlTools.ControlsPageZoomPageToLastExtentForwardCommand"
m_pToolbarMenu.AddItem sProgID, , , False, esriCommandStyleIconAndText
'Set the hook to the PageLayoutControl
m_pToolbarMenu.SetHook PageLayoutControl1
'Check and load a pre-authored map document into the PageLayoutControl using realative paths
Dim sFileName As String
sFileName = "..\..\..\..\..\..\Data\ArcGIS_Engine_Developer_Guide\Gulf of St. Lawrence.mxd"
If PageLayoutControl1.CheckMxFile(sFileName) Then
PageLayoutControl1.LoadMxFile sFileName
End If
'Set buddy controls
TOCControl1.SetBuddyControl PageLayoutControl1
ToolbarControl1.SetBuddyControl PageLayoutControl1
'Suppress drawing while resizing
MapControl1.SuppressResizeDrawing False, Form1.hWnd
PageLayoutControl1.SuppressResizeDrawing False, Form1.hWnd
End Sub
Private Sub Form_Resize()
Dim dWidth As Double, dheight As Double, dMargin As Double
'Set the margin size
dMargin = TOCControl1.Left
'Resize the PageLayoutControl
dheight = Form1.ScaleHeight - PageLayoutControl1.Top - dMargin
If dheight > 0 Then PageLayoutControl1.Height = dheight
dWidth = Form1.ScaleWidth - TOCControl1.Width - (dMargin * 2)
If dWidth > 0 Then PageLayoutControl1.Width = dWidth
'Resize the MapControl
dheight = Form1.ScaleHeight - MapControl1.Top - dMargin
If dheight > 0 Then MapControl1.Height = dheight
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Shut down the AoInitilaize object
m_pAoInitialize.Shutdown
End Sub
Private Sub m_pCustomizeDialogEvents_OnCloseDialog()
ToolbarControl1.Customize = False
chkCustomize.Value = 0
End Sub
Private Sub m_pCustomizeDialogEvents_OnStartDialog()
ToolbarControl1.Customize = True
End Sub
Private Sub m_pTransformEvents_VisibleBoundsUpdated(ByVal sender As esriDisplay.IDisplayTransformation, ByVal sizeChanged As Boolean)
'Set the extent to the new visible extent
Set m_pEnvelope = sender.VisibleBounds
'Refresh the MapControl's foreground phase
MapControl1.Refresh
End Sub
Private Sub MapControl1_OnAfterDraw(ByVal display As Variant, ByVal viewDrawPhase As Long)
If m_pEnvelope Is Nothing Then Exit Sub
'If the foreground phase has drawn
Dim pViewDrawPhase As esriViewDrawPhase
pViewDrawPhase = viewDrawPhase
If pViewDrawPhase = esriViewForeground Then
'Draw the shape on the MapControl
MapControl1.DrawShape m_pEnvelope, m_pFillSymbol
End If
End Sub
Private Sub PageLayoutControl1_OnMouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long, ByVal pageX As Double, ByVal pageY As Double)
'Popup the ToolbarMenu
If button = vbRightButton Then
m_pToolbarMenu.PopupMenu x, y, PageLayoutControl1.hWnd
End If
End Sub
Private Sub PageLayoutControl1_OnPageLayoutReplaced(ByVal newPageLayout As Variant)
'Get the IActiveView of the focus map in the PageLayoutControl
Dim pActiveView As IActiveView
Set pActiveView = PageLayoutControl1.ActiveView.FocusMap
'Trap the ITranformEvents of the PageLayoutCntrol's focus map
Set m_pTransformEvents = pActiveView.ScreenDisplay.DisplayTransformation
'Get the extent of the focus map
Set m_pEnvelope = pActiveView.Extent
'Load the same pre-authored map document into the MapControl
MapControl1.LoadMxFile PageLayoutControl1.DocumentFilename
'Set the extent of the MapControl to the full extent of the data
MapControl1.Extent = MapControl1.FullExtent
End Sub
Private Sub TOCControl1_OnEndLabelEdit(ByVal x As Long, ByVal y As Long, ByVal newLabel As String, pcanEdit As Boolean)
'If the new label is an empty string then prevent the edit
If Trim(newLabel) = "" Then pcanEdit = False
End Sub
Private Sub CreateOverviewSymbol()
'Get the IRGBColor interface
Dim pColor As IRgbColor
Set pColor = New RgbColor
'Set the color properties
pColor.RGB = RGB(255, 0, 0)
'Get the ILine symbol interface
Dim pOutline As ILineSymbol
Set pOutline = New SimpleLineSymbol
'Set the line symbol properties
pOutline.Width = 1.5
pOutline.Color = pColor
'Get the IFillSymbol interface
Set m_pFillSymbol = New SimpleFillSymbol
'Set the fill symbol properties
m_pFillSymbol.Outline = pOutline
m_pFillSymbol.Style = esriSFSHollow
End Sub
Private Sub CreateCustomizeDialog()
Set m_pCustomizeDialog = New CustomizeDialog
Set m_pCustomizeDialogEvents = m_pCustomizeDialog
'Set the title
m_pCustomizeDialog.DialogTitle = "Customize ToolbarControl Items"
'Show the 'Add from File' button
m_pCustomizeDialog.ShowAddFromFile = True
'Set the ToolbarControl that new items will be added to
m_pCustomizeDialog.SetDoubleClickDestination ToolbarControl1
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -