ArcObjects Library Reference (Framework)  

IWindowPosition Interface

Provides access to members that query or modify a window's position, size and state.

Product Availability

Available with ArcGIS Desktop.

Members

Description
Read/write property Height The height of the window.
Read/write property Left The distance between the internal left edge of the window and screen.
Method Move Moves and optionally resizes the windows in a single function.
Read/write property State The state of the window.
Read/write property Top The distance between the internal top edge of the window and screen.
Read/write property Width The width of the window.

CoClasses that implement IWindowPosition

CoClasses and Classes Description
Application (esriArcCatalog) ESRI ArcCatalog Application.
Application (esriArcGlobe) ESRI ArcGlobe Application.
Application (esriArcMap) ESRI ArcMap Application
Application (esriArcScene) The 3D Modeling Application.
CommandBar CommandBar object.
DockableWindow DockableWindow object.
ModelessFrame Object that implements a ModelessFrame.

Remarks

The IWindowPosition interface has methods to move and resize a window. Any window object can implement this interface. All the ArcGIS application windows implement this interface.

Commandbars also support IWindowPostion. Use the State property to determine whether a toolbar is floating on the desktop.

[C#]

You can do a type cast from the application object to IWindowPosition.

IWindowPosition windowPos = app as IWindowPosition

The following code reports whether the Standard Toolbar is docked on the application or floating on the desktop.

//app is a reference of IApplication
ICommandBars documentBars = app.Document.CommandBars;
UID barID = new UIDClass();
barID.Value= "{5DEB1DB8-C2A9-11D1-B9A2-080009EE4E51}";
ICommandItem bar = documentBars.Find(barID, false, false);
IWindowPosition windowPos = (IWindowPosition)bar;
if (windowPos.State == esriWindowState.esriWSFloating)
    System.Windows.Forms.MessageBox.Show("Standard toolbar is floating");
else
    System.Windows.Forms.MessageBox.Show("Standard toolbar is docked");
[Visual Basic .NET]

You can do a type cast from the application object to IWindowPosition.

  Dim windowPos As IWindowPosition
  windowPos = CType(app, IWindowPosition)

The following code reports whether the Standard Toolbar is docked on the application or floating on the desktop.

  Dim documentBars As ICommandBars = app.Document.CommandBars 'app is a reference to IApplication
  Dim barID As UID = New UIDClass 
  barID.Value = "{5DEB1DB8-C2A9-11D1-B9A2-080009EE4E51}"
  Dim bar As ICommandItem = documentBars.Find(barID)
  Dim windowPos As IWindowPosition = CType(bar, IWindowPosition)
  If windowPos.State = esriWindowState.esriWSFloating Then
    MsgBox("Standard toolbar is floating.")
  Else
    MsgBox("Standard toolbar is docked.")
  End If

.NET Snippets

Resize Dockable Window | Move Dockable Window | Minimize Application Window | Report Dockable Window Position | Move Application Window to Center |