Brian Dunning's FileMaker Custom Functions

WindowAlignCalc ( SEE ARGUMENTS BELOW IN DESCRIPTION )

Calculates window coordinates from a desired window size for easy placement relative to common FM application objects, including an active field for dynamic window orientation to the users cursor in a field.

  Average rating: 4.5 (31 votes) Log in to vote

Jonathan Mickelson   Jonathan Mickelson - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
WindowAlignCalc ( "ActiveField" ; "TR" ; 200 ; 300 ; "TL" )
  Sample output:
200
300
305
517

(See Description for what each line represents)

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

NOTE!!! THIS FUNCTION IS CURRENTLY ONLY WORKS CORRECTLY FOR VERSION 9 AND BACKWARD. IT WILL WORK IN FM10 BUT WILL PROBABLY BE SHIFTED +/- 20-60 PIXELS BECAUSE OF THE
HORIZONTAL VS VERTICAL STATUS AREA, AND OS WINDOW EDGE DIFFERENCES.

SIMPLE CENTERING WILL STILL WORK PRETTY WELL WITHOUT ANY MODIFICATION.

Syntax
~~~~~~~~~~~~~~~
WindowAlignCalc ( refObjName ; refObjOrient.TMB_LCR ; newWinHeight ; newWinWidth ; newWinOrient.TMB_LCR )

Description
~~~~~~~~~~~~~~~
This function simplifies the calculation of window coordinates and sizes for simple window placement relative to common FM application objects. The "piece de resistance" being the ability to orient a new window easily upon ANY (*) 'active field' on a layout regardless of screen/window/field size or location. This is very powerful for pop-up calendars or help dialogs that need to that orient perfectly and dynamically upon a clicked field, based upon the orientations you define as parameters.

There are two layers to the calculation, between these two sets of calculations you can precicely place a window in countless configurations:
- The first is the "Reference Object" and the orientation which defines how you want the new window oriented in relationship to the referenced object.
- The second is the size and orientation of the "New Window" relative to the starting point defined by the "Reference Object" portion of the calculation.

(*) NOTE: If multiple copies of the same field exist on the layout results may be unpredictable. Usually the upper left field will be used by FM.

Output Format
~~~~~~~~~~~~~~~
A return delimited value list** of 4 values (in the order used by the Window Script step's input fields).
The output format and order of values is as follows (in pixels):

New Window Height
New Window Width
New Window distance from Top
New Window distance from Left

The best way to use this result would be to use:
"Middle Values ( WindowAlignCalc ( ******* ) 1 ; 1 )" or " 2 ; 1 )" or "3 ; 1 )" or "4 ; 1 )"
The Above Calculation will grab the appropriate value of the result which should then be placed into the appropriate input field of a New Window script step.

** NOTE: Output is returned as a return delimited value list because value functions don't strip a negative (-) from a value like Word functions do

Parameters
~~~~~~~~~~~~~~~
refObjName - The name of the object whose dimentions should be used to orient the new window relative to. This value is used by the "refObjOrient.TMB_LCR" parameter to determine where the start point for the new window should be calculated from.

The expected values are: screen - The Screen
desktop - The Desktop
window - The Active/Topmost Window (Default)
content - The Active Window's content area, does not include the Status area if open.
activeField - The field the user's cursor is currently clicked into on the active winow's layout.

refObjOrient.TMB_LCR - Two text characters each representing a vertical and a horizontal alignment orientation. They may be given in any order, as each character is unique. The default behavior for both is the middle/center options. For example, some common combinations of values would be "TL" for Top Left, "MC" for Middle Center.

The expected characters should be as follows:
Vertical : T = Top Horizonatal: L = Left C = Center R = Right
M = Middle (Default) (Default)
B = Bottom

newWinHeight - The desired fixed height, in pixels, of the new window being calculated. A value preceded by either a "-" or "+" will assign a window height relative to the original window's height, adjusted by the value given. For Example: a -50 value will result in a window's height the same as the original window minus 50 pixels.

newWinWidth - the desired fixed width, in pixels, of the new window being calculated. A value preceded by either a "-" or "+" will assign a window width relative to the original window's width, adjusted by the value given. For Example: a -50 value will result in a window's width the same as the original window minus 50 pixels.

newWinOrient.TMB_LCR - Two text characters each representing a vertical and a horizontal alignment orientation for the New Window relative to the start point already defined by the "refObj" parameters. Thus if the "refObj" returned a starting position of 100 Top and 100 Left, this parameter determines where the new window appears relative to that starting point. They may be given in any order, as each character is unique. The default behavior for both is the middle/center options. For example, some common combinations of values would be "TL" for Top Left, "MC" for Middle Center.

The expected characters should be as follows:
Vertical : T = Top Horizonatal: L = Left C = Center R = Right
M = Middle (Default) (Default)
B = Bottom

SPECIAL NOTES: Referencing the Screen Top will behave exactly the same as Desktop Top because because FMP doesn't allow negative vertical values and 0,0 is the desktop start dimension and behaves the same as -22, 0. Screen is still a referenceable object because Screen Middle/Centered dialogs end to look more naturally in the centerred on screen than Desktop Middle/Center ones.

Author - Jonathan Mickelson

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: