Home | OS/2 Software | Rexx | Toolbars and a VisPro Sizing Trick

Toolbars and a VisPro Sizing Trick

Contributed by: Wayne Swanson

When placing control objects like a toolbar etc in a VisPro program it can get to be difficult to locate them when the user resizes. VisPro resizes all the objects in the window but they are all proportionally larger or smaller depending on what size the window is being set at (larger or smaller).

Suppose you have a row of buttons set up as a toolbar with bitmaps on them and you want to keep them at 30x30 pixels in size. When the window is resized they may be 40x40 instead of the size you want and if you resize them manually... how do you know where the top of the window is (If you want it attached just under the menu). The "getsize" call to your window includes the titlebar and menu so how do we get down to the window portion of the window accurately?

One way to do it is to add a free-form window control to the program that fills the usable part of the form. You could use any control I suppose but the free-form window is a good choice because it can kill a couple of birds with the same stone. In other words, it will do something else useful if you need it besides just being a sizing template.

  • When the window is resized the free-form control will always be the exact size of the interior of the form window. You can locate the top of the window area of the form with a "getsize" call to the free-form control and a tiny bit of math. Now you are able to place your buttons with accuracy.
  • With the free-form window filling the interior of the form window you can also use some of the extended power of the free-form window to help in other ways like tracking the mouse for example.

In the following snippet we'll get the size of the free-form window (ControlID = 1050) and subtract 30 (our button height) to set the toolbar buttons (ControlID's 1001-1010) at the top of the form window. Using the numbers of the button control ID's we can obtain a multiplier that will allow us to place our buttons in sequence and incremented by the 30 pixel spacing we need.

Here are your prerequisites when using this snippet:

  • Be sure that the free-form object fills the complete area allowed in the "Layout view" to it's exact dimensions
  • Drag the free-form object to the very bottom of the list in your form "List view"
  • The free-form window itself should be set invisible on it's own settings "Style" page. (the "Visible" checkbox is "off")
  • You will also need to be sure to select the "sizeable" selection on the forms "Style" page in the form "Settings view"
  • Modify this snippet to your needs and place it in your form "When Sized" event

 


 

/* Get free-form window control size                                  */

/* "sizery" is equal to the interior height of the window             */

Parse Value VpItem(window,1050,'ITEMSIZE') With sizerx sizery

/* Place buttons using their own ID's to increment the x starting     */

/* point and the free-form windows sizery-30 for the y starting point */
Do index = 1001 To 1010

Call VpItem window,index,'SETITEMPOS', (index-1001)*30, sizery-30, 30, 30
End