UEPosUEPos version 1.2, 3/7/2008
© 2003-2008 Pallium, all rights reserved worldwide.
Written by Bryan K. Ressler, Pallium Consulting Services
What Is UEPos?
UEPos is a small utility program that can move and resize document windows in the excellent UltraEdit text editor.
By configuring some UltraEdit "Tools", you can invoke UEPos to move and size windows with keyboard shortcuts. In turn, by using UltraEdit's "RunTool" macro command, you can move and size windows from within macros.
You can get UEPos from the downloads page.
To install UEPos, simply unzip the distribution ZIP file into the same directory where UltraEdit is installed. By default, this is C:\Program Files\UltraEdit. Then follow the directions below to create some UltraEdit Tool definitions that run UEPos to position your windows.
The easiest way to use UEPos is to create one or more Tool definitions that run UEPos to position and size UltraEdit document windows into predefined locations. To define an UltraEdit Tool that runs UEPos, do this:
The Predefined Positions
The figure below shows what the first three predefined positions would be for a large UltraEdit window (perhaps 1600 pixels wide).
Specifically, the predefined positions start at the left edge of UltraEdit's document area, are 515 pixels wide, and are the full height of the document area. Position 2 is exactly adjacent to position 1, etc., until the first window position where the window would be completely off the right edge of the screen. At that point, the windows start appearing overlapped with Position 1, but offset by 1/5 of the window width.
The window width and height can be easily controlled with extra parameters on the UEPos command line. For instance, to use the standard positioning scheme, but with 600-pixel wide windows, you'd use
uepos -pos 1 -width 600
The height can be controlled similarly with the -height option.
You can ignore the predefined window positions completely and have UEPos put windows exactly where you want them. To get UEPos to do this, use all four of the options -left, -top, -width, and -height. For instance, to put the active document at (100, 150) and make it 300 pixels wide and 400 pixels tall, you'd use this command line:
uepos -left 100 -top 150 -width 300 -height 400
Here's part of UEPos usage output. To get this, you can open a command window, change directory to the location of UEPos.exe, and run UEPos with no options on the command line.
Usage: UEPos [options] Options: -pos <n> Position to standard position (n is 1 or more) -left <l> Position window to left coordinate <l> -top <t> Position window to top coordinate <t> -width <w> Set window width to <w> -height <h> Set window height to <h> -leftextra <le> Add additional <le> to window left -rightextra <re> Add additional <re> to window right -topextra <te> Add additional <te> to window top -bottomextra <be> Add additional <be> to window bottom -nosafety Don't adjust windows to ensure visibility
The -pos option tells UEPos which predefined position you want. The argument is an integer of 1 or more. If the -pos option is present, -left and -top are ignored. The exact dimensions of the window depend on whether -width and/or -height are specified. If neither are given, the window will be 515 pixels wide, and the full height of the UltraEdit document area.
The -left option tells UEPos to position the active window at the given horizontal offset from the left edge of UltraEdit's document area. The argument is an integer which may be negative. This option is often used in conjunction with the -top option to control the exact position of a window. This option is ignored if the -pos option is present.
The -top option tells UEPos to position the active window at the given vertical offset from the top edge of UltraEdit's document area. The argument is an integer which may be negative. This option is often used in conjunction with the -left option to control the exact position of a window. This option is ignored if the -pos option is present.
The -width option tells UEPos to size the active window to the given width in pixels. The argument is a positive integer. If a -width option is not given, UEPos defaults to 515 pixels. The -width option can be used in conjunction with the -pos option to provide "predefined" window position, but with a different width than the default.
The -height option tells UEPos to size the active window to the given height in pixels. The argument is a positive integer. If a -height option is not given, UEPos defaults to the full height of the UltraEdit document area. The -height option can be used in conjunction with the -pos option to provide "predefined" window positioning, but with a specific height instead of the default.
The -leftextra option adds a constant to the left coordinate of the final window position. This can be used to "tweak" windows so that the text area is maximized by overlapping the windows in the standard positions. For instance if you use a standard theme in Windows XP, the options:
-leftextra -4 -topextra -8 -bottomextra 6can be used to push the top, left, and bottom edges of a window out from a preset position such that an extra line of text may be visible, depending on your font and size choice.
The -rightextra option adds a constant to the right coordinate of the final window position. This can be used to "tweak" windows so that the text area is maximized by overlapping the windows in the standard positions. See the example in -leftextra above.
The -topextra option adds a constant to the top coordinate of the final window position. This can be used to "tweak" windows so that the text area is maximized by overlapping the windows in the standard positions. See the example in -leftextra above.
The -bottomextra option adds a constant to the bottom coordinate of the final window position. This can be used to "tweak" windows so that the text area is maximized by overlapping the windows in the standard positions. See the example in -leftextra above.
The -nosafety flag allows you to use UEPos to position windows absolutely anywhere you'd like, including locations that are not visible at all (that is, completely outside the UltraEdit document area). Normally UEPos adjusts the final window position such that at least 4 pixels of the window's title bar are visible. The -nosafety flag turns off this default behavior. Be careful with this option, because once a window is moved to an invisible location, there's no way to manually move it back. (Note that you can always activate the window by choosing it from the UltraEdit Window menu, then use 'uepos -pos 1' to slam the window back into UltraEdit's document area.)
How Does UEPos Work?
(This technical description is only for the curious. Others may safely ignore. )
UEPos locates the UltraEdit-32 frame (outer) window by name. It looks for a window named "UltraEdit-32 - " or "UltraEdit - " in the top level window list. Yes, it can be fooled by windows that are not actually UltraEdit's but the extra " - " at the end reduces this risk. Also, if there are no documents open, UltraEdit's frame window title lacks the trailing dash, so UEPos simply does nothing if UltraEdit doesn't have an active document.
Once the UltraEdit-32 frame window is found, UEPos searches the frame window's children for a child window of the window class "MDIClient", which is the parent of MDI document windows in the Microsoft Windows operating system.
Once the MDIClient window is located, it is sent a message to report its "active child" window. That's the document window that UEPos manipulates.
Finally UEPos uses the command line options to calculate a new screen rectangle for the window, validates it, then applies it to the window with the Windows API call SetWindowPos.
© 2003 Bryan K. Ressler, all rights reserved worldwide.
If you find any errors in this document please email me.