HOWTO: Get the Position and Size of a Window

HOWTO: Get the Position and Size of a Window

Document ID: IR04007
The information in this article applies to:
  • AutoPlay Media Studio 4.0

SUMMARY

This article describes how to determine the position and size of a window using AutoPlay Media Studio 4.0.

DISCUSSION

AutoPlay Media Studio has a built-in action that can be used to move and resize a window called Window.Move. However, it does not have actions that can be used to determine the screen co-ordinates of a window. This information could be useful if you want to use Window.Move to move a window, but want to be able to restore it to its original size or position later. Another use of such functionality would be that you could store your AutoPlay application's coordinates in the Registry when the application closes and then read them in and restore the size and position when the application starts again.

To address this lack of functionality, Indigo Rose has produced a DLL called IRGetWindowPos.dll that allows you to access this functionality from AutoPlay Media Studio. IRGetWindowPos.dll exposes four functions:

long GetTop(HWND hWnd)
long GetLeft(HWND hWnd)
long GetHeight(HWND hWnd)
long GetWidth(HWND hWnd)

These four functions allow you to get the left (x), top (y), height and width of the window for which a handle is passed in. To use these functions on your AutoPlay application window, pass in %MenuHWnd% as the hWnd argument. Otherwise you can use the Window category of actions to find other windows (and their handles) that are displayed on the system.

IRGetWindowPos.dll and a sample project that uses it can be downloaded from Indigo Rose. Click here to download GetWindowPos.zip. The sample project shows how to get the window size and position on demand as well as how to make a window maintain its size and position between sessions.

MORE INFORMATION

For more information, please read the following topics in the AutoPlay Media Stuio 4.0 help file:

  • Command Reference | Actions | File | Call DLL Function
  • Command Reference | Actions | Window | Move

KEYWORDS: window position, Window.Move, IRGetWindowPos.dll


Last reviewed: October 3, 2002
Copyright © 2002 Indigo Rose Corporation. All rights reserved.