Application Object

The Application object represents the MapViewer program. All navigation through the MapViewer object model begins with the Application object. The Application object is a single instance of MapViewer and it is the root of all objects in MapViewer. External programs typically create an instance of the Application object during initialization. In VB this is done using the CreateObject function as in:

 

Set mvApp = CreateObject(" MapViewer.Application")

 

The CreateObject function activates a new instance of MapViewer, and returns a reference to the Application object to your script. If MapViewer is already running and you do not want to start a new instance of MapViewer, use the VB GetObject function instead of CreateObject:

Dim mvApp As Object

Set mvApp = GetObject(," MapViewer.Application")

 

The GetObject function obtains the Application object from the currently running instance of MapViewer. If MapViewer is not already running, the function will fail. Call the Application object’s Quit method to close MapViewer from a script.

 

When MapViewer is started by a script, its main window is initially hidden. To make the MapViewer window visible, you must set the Application object’s Visible property to True:

Set mvApp = GetObject(," MapViewer.Application")

mvApp.Visible = True

 

Other methods and properties of the Application object let you move and resize the MapViewer window, adjust the main window state (maximized, minimized, hidden), change the window caption, and modify preference settings.

 

The Application object provides two important collections that allow access to the next level of objects in the hierarchy. Use the Documents property to obtain a reference to the Documents collection object, and use the Windows property to obtain a reference to the Windows collection object. The Documents and Windows collection objects provide access to the other objects in the object hierarchy. You can access the currently active document and window objects with the Application object’s ActiveDocument and ActiveWindow properties.

 

Properties

ActiveDocument

ActiveWindow

Application

ApplicationFolder

BackupFiles

Caption

DefaultFilePath

Documents

FullFileName

Height

Left

ModuleFolder

Name*

PageUnits

Parent

ScreenUpdating

ShowStatusBar

ShowToolbars

Top

Version

Visible

Width

Windows

WindowState

 

Methods

Quit

 

*default property

 

Example

The following script demonstrates how the Application object is used.

 

Sub Main

'Declare mvApp as an object

 Dim mvApp As Object

 

'Creates an instance of the MapViewer Application object

'and assigns it to the variable named "mvApp"

 Set mvApp = CreateObject("MapViewer.Application")

 

'Makes the application main window visible

 mvApp.Visible = True

End Sub