Neuron
Pallium Consulting Services

Home
Downloads
Reference
Contact

Personal

UEPos

UEPos 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.

Downloading

You can get UEPos from the downloads page.

Installation

UEPos is distributed as a ZIP archive. To open the archive, you'll need a utility like WinZip or WinRAR.

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.

Use

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:

config
  1. Choose Tool Configuration... from the Advanced menu.
  2. In the Tool Configuration dialog (shown at right), type "uepos -pos 1" into the Command Line field as shown in the figure. This will cause UEPos to move and size the document window to it's predefined position 1.
  3. Leave the Working Directory field blank.
  4. Type a descriptive name into the Menu Item Name field. This text will appear in the Advanced menu to represent this command.
  5. Be sure to uncheck the Save Active File command...it will only annoy you to have to save the file just to position the window. Don't worry—UEPos cannot cause you to loose work.
  6. Click the Insert button to add this command to the list.
  7. Typically you would create additional Tools, to move to preset position 2, etc. Those will be configured exactly as above, except with a different number at the end of the UEPos command line, such as "uepos -pos 2" for position 2. In the image to the right, I have defined Tools for positions 1 through 7.
  8. When you're done configuring Tools to run UEPos, click the OK button to save the changes.
  9. In order to test the UEPos is working, create a new document by choosing New from the File menu.
  10. Pull down the Advanced menu. You'll see your newly defined Tools at the end of the Advanced menu. Choose your new Position 1 Tool from the menu.
  11. You'll see the new document window immediately moved and sized to the left of UltraEdit's document area, at a predefined width of 515 pixels. This indicates that UEPos is installed and operating correctly.

The Predefined Positions

The figure below shows what the first three predefined positions would be for a large UltraEdit window (perhaps 1600 pixels wide).

positions

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.

Absolute Positioning

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

UEPos Options

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

-pos <n>

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.

-left <l>

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.

-top <t>

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.

-width <w>

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.

-height <h>

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.

-leftextra <le>

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 6
can 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.

-rightextra <re>

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.

-topextra <te>

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.

-bottomextra <be>

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.

-nosafety

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.)

Version History

  • 1.0 - 6/23/2003: Initial public release.
  • 1.1 - 2/12/2004: Bug fix update.
    FIXED: A bug would often cause the height of the document to be set to zero.
    FIXED: UEPos was ignoring the minimized/maximized/restored state of the windows. Now minimized or maximized windows are set to the restored state when they are resized/repositioned.
    Thanks go out to Todd Martin for helping identify the bugs fixed in this release.
  • 1.2 - 3/6/2008: Bug fix update.
    FIXED: UEPos became incompatible with UltraEdit 14 due to a change in the window title naming convention used by UltraEdit. Thanks to Todd Martin for identifying the problem.

How Does UEPos Work?

(This technical description is only for the curious. Others may safely ignore. smiley)

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.