Clarion uses dialog units as screen position measurement unit when designing windows. This is fixed and cannot be changed at design time, but it can be changed at runtime. For window design we can use PROP:Pixels and to change to pixels it is a simple matter of setting PROP:Pixels to true for the window object, like:
WindowLabel {PROP:Pixels} = True
Or:
0 {PROP:Pixels} = True
Since 0 (zero) always refers to the structure of the current target object. To set the window back to using dialog units, simply set PROP:Pixels to false:
0 {PROP:Pixels} = False
It may not be immediately obvious, but you can also use a few other measurement units when dealing with windows at runtime. There are 3 more measurement units that can be used: PROP:Thous, PROP:mm and PROP:Points. If you set the properties to false Clarion goes back to dialog units. Normally we would only think of using PROP:Thous, PROP:mm and PROP:Points on reports, but they work equally well on windows!
The smallest unit you can use with PROP:Thous is 1 which equals 0.0254mm. Point is 1/72" equal to about 0.353mm. With millimeters, the smallest unit is 2 (or at least it used to be) or 100 times bigger than the smallest unit with PROP:Thous, which makes it pretty much useless for any precision placements. If I need to set sizes in metric units I convert to 1/1000" It may not always be perfect but for most things I think it is close enough.
If you have a control on a report, for example a fixed width textbox and you want the user of your software to be able to format the contents on a window so that it will look exactly as it will print, you can get the measurement from the report and use it to set the size of the textbox on a window. Let’s say that the textbox on the report is 6" wide or 6000/1000" With that you can use this code on your window:
0{PROP:Thous} = True
?MyTextBox {Prop:Width} = 6000
0{PROP:Thous} = False
Your textbox will now appear 6" wide and if you also make sure that the textbox on the report and on the window are using the same font, font size and font style, the text should be printed exactly as it is formatted in the textbox on the window.
When dealing with pixel sizes, our Icetips Utilties have a number of methods in the ITWindowsClass to get and set the position of controls in pixels. For example the class has both SetPixelPosition and GetPixelPosition. Those two methods have the same parameters as the SetPosition and GetPosition statements in Clarion making it very easy to use pixels to place controls.
Our Icetips Utilities mentioned here is a collection of classes and templates for Clarion developers. They are part of our Gold Subscription plan.
Arnor Baldvinsson
Comments are not allowed from anonymous visitors.