by Jack Wheeler
| You have a wonderful application with award-winning forms. You have painstakingly aligned your numerous forms in an esthetically pleasing fashion. Now you read the Sunday papers and your see that 17-inch monitors are only $179 and you RUN down to the store to purchase one. Suddenly all your forms are seen at 1024x768 resolution instead of 640x480. What do you do with your wonderful forms NOW? |
The first section shows a technique I developed to manually modify old forms to create new forms in different sizes. In the second section I get smart and show you how to design forms from scratch that can resize themselves. Many thanks to Sewlyn Rabins for his patience and detailed help concerning this topic!
I found a little secret that helped me design forms in several sizes. When you put a frame around any selection of fields and buttons and then group the frame and all the enclosed objects, Alpha considers the group to be one object. If you make the outside frame grow and shrink, all the objects enclosed by the frame will grow and shrink along with the frame!
Here is an example:

Figure 1. Here I have a form in 1024x768 resolution. I placed a frame around all the objects in the form.

Figure 2. Next I grouped the frame and all the inside objects.
Now I just shrink the outside frame by about 1/3, and whaddyaknow:
Figure 3. Now this took all of 12 seconds so far. I next will select all the buttons and choose a smaller text font, and then I also have to resize the bitmap at the top of the form. Maybe another 12 seconds?

Figure 4. I finish the job by resizing the form boundaries to fit snugly around the new, smaller frame.
Here's how it works on another form:

Figure 5. A form with many fields.

Figure 6. "Honey, I shrank the fields!"
| Editor's note: Jack is actually doing a little more work than he has to. There is no need to create a frame around all the objects in the form. If all the objects are grouped together, then the group as a whole can be resized. The frame that Jack creates is just another object, and in Alpha Five, the frame does not have any special properties. Although it may physically surround the other objects on the form, it does not logically enclose them. This distinction is important for the next section. |
If Alpha does indeed see grouped objects as one object, can they be modified using Xbasic? I thought that I could simply take the frame, change the width or height of the frame with xbasic and all the contents would change proportionally. Then I could get the window size and grow or stretch the form and fields based on a mathematical equation using pixels. You could see how easy this could be if it worked. I could not get it to work, can you? [Editor's note: As mentioned in the insert above, it won't work because the frame has no "contents." Only the form has contents, as Jack will shortly discover.]
Thanks to Selwyn Rabins of Alpha Software I was shown how to access the objects on a form. The built-in methods that Alpha Five uses to access form objects are the children(), child(n number) and class() methods:
An important point to remember is you cannot change the form size in Xbasic. Once you have set the size of the form it remains with those dimensions until you physically change it in the design window. I created all my form sizes at 1024x768, or 10.65" wide and 6.75" in height. Then I move the objects in the form so that they will initially fit on a small screen of 640 x 480. If the screen is larger, then I can spread out the objects on the form. If the screen is only 640 x 480, the obejcts will stay close together. It is important when designing the form to place one object at the bottom of the form (6.75") and another at the extreme right (10.65") - I placed small lines.
| Editor's note: Jack's techniques do not work properly on my notebook monitor. I think that is because the LCD monitor is 12" and displays at 800x600. Jack assumes that a 15" monitor displays at 640x480 and that 800x600 will be proportionally larger. Tain't always so. Nevertheless, Jack's techniques are worth looking into. Perhaps someone else can solve the problem of LCD monitors. |

Figure 7. The form for a very small window. I am not sure this size monitor exists.

Figure 8. The same form fits a larger window when I set my monitor resolution to 1024x768.
On each form, I have a simple OnInit script of script_play("formsize"). The formsize script is a global script that moves the objects around and resizes them:
''XBasic dim number as n dim i as n dim f as p dim percntw as n dim percnth as n dim SizeH as n dim SizeW as n dim name as c sizeH=UI_info(3) sizeW=ui_info(2) on error goto new percntH = ((sizeH - 480) / 480)+1 percntW = ((sizeW - 640) / 640)+1 number = topparent.children() for i = 1 to number f = topparent.child(i) f.object.top = f.object.top * percnth f.object.height = f.object.height *percnth if f.class() = "text" .or. f.class() ="field" \ .or.f.class() = "Button" .or. f.class() = "Radio" \ .or.f.class()="twostbtn".or.f.class()="multistbtn" then f.font.size = f.font.size * percnth end if if f.class() = "Browse" then f.title.font.size = f.title.font.size * percnth end if f.object.left = f.object.left * percntw f.object.width = f.object.width * percntw new: next i
The formsize global script.
I have to warn you that this script may fail with some complex forms. Alpha Five did not properly read all the properties of User Objects, Browses, sub forms and Radio buttons. However as soon as Alpha Software was made aware of the bug they fixed it, and the fixes are already in beta build 240.
You can download a sample application that uses these techniques.
3/19/00
Don't forget, we need your feedback to make this site better!