Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Par2: Resizing windows depending on resolution 1998-02-04 -- Simon Burrows Firstly, I must state that this was implemented on version 2003. It
should work with the Clarion 4 legacy templates but I cannot comment on
versions prior to 2003.
This has always been a bit of a bind with most Clarion programmers. How
do you write a standard package so that selected windows are always
maximised regardless of the screen resolution of the end user's system
and their contents are resized in proportion to the window size. Now
for those people reading this thinking 'oh no, this is going to mean API
calls and all sorts of things that I don't understand', then calm down
and read on. This actually involves setting up 2 global variables and 5
lines of standard Clarion code. Ok so this is how you do it.
Make sure that when you write apps, they are for the lowest common
denominator available i.e. 640X480
1. Firstly create two global variables which are Glo:Height and
Glo:Width both Longs which will store the size of the screens.
2. Now (and this is a must), you need to have an application frame
that is set to be maximised on open.
3. In the Application frame embed 'After Opening the Window' enter
the following:-
Glo:Height = AppFrame{Prop:Height} - 16
Glo:Width = AppFrame{Prop:Width} - 4
This is the clever (OK then 'rather obvious') bit that makes this work.
Effectively, Clarion have done all the API calls internally and have
produces an initial window which is fully sized to use the maximum
window size available. All we are now going to do is see what the
height and width of this window is and resize all our mdi child windows
accordingly.
For those of you who are wondering why we are taking 4 off the width and
16 off the height, this is to remove the height of the menu bar at the
top and the left and right window lines.
4. Now, for each procedure that you want to automatically resize,
bearing in mind that not all Windows benefit from being maximised,
ensure that the Window Frame type is set to Resize (rather that double
or single). Now go into the procedures extensions (the bottom button on
the procedure property screen) and go into the 'Allow controls to be
resized with window' extension (if it is not on the list of installed
extensions, you will need to add it), and ensure that the Resize
strategy is set to 'Resize'
5. Finally in the procedures Embedded code 'After opening the Window'
enter the following code.
WindowName{Prop:Height} = Glo:Height
WindowName{Prop:Width} = Glo:Width
WinResize.Resize
(where WindowName is the name of the Window that you are working
on)
Now a lot of people will be saying 'what's this WinResize.Resize?' Even
back in version 2003 OOPS was starting to creep, unnoticed by most of
us, into the Clarion language and this was an early example of a Class
Method being implemented. I am not going into the why and wherefore of
OOPs in Clarion here but just believe me when I say that it works.
6. Compile and run your application and see what happens!
7. Repeat stages 4 and 5 for all Windows that you want to resize!
Today is November 21, 2024, 3:54 am This article has been viewed 35196 times.
|
|