Creating Scalable Forms Summary: This technote illustrates how to create a form that scales depending on the screen resolution which is currently in use. This is useful for developers who wish to keep the form at a constant size in relation to the form's actual developed resolution when displaying the form on systems with different resolutions. While you can do this in Superbase 4 Version 1.3x, I strongly recommend using the Superbase 2.0 Form Designer since it allows you to save your completed form as an SBL program. If you prefer to stick to Superbase 4 1.3x, you have to create the form from scratch using the DML programming language for the technique outlined in this technote to work. Also, the instructions in this technote aren't meant for a programming novice. The instructions require you to get your hands into the actual code of your form. Creating a scalable form Once you have created your form in Form Designer, select Save as from the File menu and then Program. I recommend that you also save the form as a Form so that you have something to fall back on if you decide not to go this route. For this example, use the program name, TestForm.SBP Select Load from the Program menu to load the program file. Choose Edit from the Program menu and the code for your form appears. This program code is not totally stand alone in some cases. One of these cases include: Static images put onto the form in the Form Designer are now referenced by the name of the respective image along with its path. If you do decide to use a static image, you have to either include the path with your form program or remove it altogether. Make the following modifications to the main() subroutine of the form: SUB main() OrigWidth%% = 640' The screen width that this form was created under OrigHeight%% = 480' The screen height that this form was created under PixelWidth%% = FN sys(6) ' Screen width in pixels PixelHeight%% = FN sys(7) ' Screen height in pixels WidthRatio#% = PixelWidth%% / OrigWidth%%' Width ratio HeightRatio#% = PixelHeight%% / OrigHeight%%' Height ratio CALL TestForm(WidthRatio#%, HeightRatio#%)' Replace TestForm with your form END SUB The only things you may have to modify in this routine, other than the form name, is the OrigWidth%% and OrigHeight%%. With these two variables set as they are, the example assumes that the form was developed on a 640 x 480 display. Change these variables if the form was developed on a display size other than 640 x 480. Note: If you are using the standard display sizes such as 640 x 480, 800 x 600, and 1024 x 768, HeightRatio#% and WidthRatio#% will be the same due to the fact that these display sizes are in perfect aspect ratio with each other regardless of the selected display size. Now you need to modify the form routine itself. 1. First, you need to modify the SUB line so that it reflects the CALL statement in the main() routine. In order to do this, change the line SUB TestForm() to SUB TestForm(WidthRatio#%, HeightRatio#%) where TestForm is the name of your program. 2. For every ADD FORM line, you need to modify the x coordinate, y coordinate, width, and height measurements to reflect the resizing ra tio. An example of this is as follows: Original code: ADD FORM 1, 125, 125, 6250, 3625 Modified code: ADD FORM 1, 125 * WidthRatio#%, 125 * HeightRatio#%, 6250 * WidthRatio#%, 3625 * HeightRatio#% 3. For every SET FORM TEXT line, you also have to modify the code to reflect the resizing ratio. I recommend that you use scaleable fonts such as TrueType fonts on your form. Otherwise, the fonts are dis torted when resized. Original code: SET FORM TEXT "Arial,10,1,34,0" Modified code: SET FORM TEXT "~Arial," + STR$ ( INT (10 * HeightRatio#%),"999") + ",1,34,0~" Notice that the code is not rounding the font size upwards (10 is the font size in both code lines). Because the font may go out of the allowed text bounds, I choose to not round the numbers upwards. To use this rounding feature, replace STR$ ( INT (10 * HeightRatio#%),"999") with STR$ ( INT (10 * FIX (HeightRatio#%,1) ),"999"). Note: When you are creating a form on higher resolution for viewing on a lower resolution, remember that the text may become too small to read if you use a small font on the higher resolution screen. Make sure to take this into account when creating a form at high resolution. 4. If you have detail blocks on your form, find the ADD FORM REP- LICATE lines and modify them as follows: Original code: ADD FORM REPLICATE "children",6,1,200,200,0,0,0,1,0 USING link field.MANY = linkfield.ONE ORDER childname.MANY DESCENDING Modified code: ADD FORM REPLICATE "children",6,1, INT (200 * HeightRatio#%), INT (200 * WidthRatio#%),0,0,0,1,0 USING linkfield.MANY = linkfield ONE ORDER childname.MANY DESCENDING When you run the modified program in the developed resolution, the form should look the same. Save the modified program, preferably to another program name, and exit out of Superbase. Switch the resolution of your display through the Windows Setup in the Program Manager if your system can handle different resolutions. If you run your program in a different resolution, the form should now be at the original size even though the resolution is different. Program: Superbase Versions: 2.0 Date: April 20, 1993