ArcObjects Library Reference  (Carto)    

IActiveView.Activate Method

Gives this view control of the specified window.

[Visual Basic 6.0]
Sub Activate(
    ByVal hWnd As OLE_HANDLE _
)
[Visual Basic .NET]
Public Sub Activate ( _
    ByVal hWnd As Integer _
)
[C#]
public void Activate (
    int hWnd
);
[Java]
public void activate (
    int hWnd
)
throws
    IOException,
    AutomationException
[C++]
HRESULT Activate(
  OLE_HANDLE hWnd
);
[C++]

Parameters

hWnd

  hWnd is a parameter of type OLE_HANDLE

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

Called to establish the current object as the active view.  For example, view commands deactivate (IActiveView::Deactivate) the current view (IMxDocument::ActiveView) before calling Activate on their own associated view. 

When working with the IActiveView interface on a MapDocument object, you should always first call IActiveView::Activate() in order to properly initialize the display of the PageLayout or Map object. The MxDocument and MapServer objects and the MapControl and PageLayoutControl all initialize display objects automatically after opening an MXD, but MapDocument does not do this, so you should call Activate() before working with any other members of IActiveView.   If your application has a user interface, you should call Activate() with the hWnd of the application's client area.  If your application runs in the background and has no windows, you can always get a valid hWnd from the GDI GetDesktopWindow() function, part of the Win32 API.

[Visual Basic 6.0]

For an application with a user interface:

Get the hWnd of the application's client area:

  Dim hWnd As Long
hWnd = Picture1.hWnd

activate the view:

  pActiveView.Activate hWnd

 

For an application without a user interface:

Declare this Win32 API function at the head of the code:

  Private Declare Function GetDesktopWindow Lib "user32" () As Long

activate the view:

  pActiveView.Activate GetDesktopWindow()

See Also

IActiveView Interface

 


Feedback Send feedback on this page