Clear Win
Clear Win
Fortran Edition
Table of Contents
1. Introduction ............................................................................................................ 1
Windows applications............................................................................................................................................................... 1
The ClearWin+ library ............................................................................................................................................................. 1
How to use this guide................................................................................................................................................................ 2
3. ClearWin+ tutorial................................................................................................... 7
6. Button controls..................................................................................................... 51
Contents-1
ClearWin+ User’s Guide Fortran
Contents-2
Table of Contents
Contents-3
ClearWin+ User’s Guide Fortran
Contents-4
IMPORTANT NOTICE
Salford Software Ltd gives no warranty that all errors have been eliminated from this
manual or from the software or programs to which it relates and neither the Company
nor any of its employees, contractors or agents nor the authors of this manual give any
warranty or representation as to the fitness of such software or any such program for
any particular purpose or use or shall be liable for direct, indirect or consequential
losses, damages, costs, expenses, claims or fee of any nature or kind resulting from any
deficiency defect or error in this manual or such software or programs.
Further, the user of such software and this manual is expected to satisfy himself/herself
that he/she is familiar with and has mastered each step described in this manual before
the user progresses further.
The information in this document is subject to change without notice.
17 February, 2000
All copyright and rights of reproduction are reserved. No part of this document may be
reproduced or used in any form or by any means including photocopying, recording, taping
or in any storage or retrieval system, nor by graphic, mechanical or electronic means without
the prior written consent of the Salford Software Ltd.
ii
PREFACE
This user’s guide discusses the binding from Salford Fortran compilers to the Microsoft
Windows Applications Programming Interface (API). It also describes the Salford
ClearWin+ library. ClearWin+ offers an easy-to-use interface to the Windows API.
ClearWin+ is used together with a Salford Win32 compiler in order to develop Windows
(Win32) applications that will run under Windows 95 and Windows NT. This guide
describes how to write Win32 applications.
Details of how to use ClearWin+ to develop Win16 applications will be found in the
ClearWin+ User’s Supplement. An electronic copy of this supplement can be found on the
Salford Tools CD. The supplement also includes details of functions that are considered to
be obsolete together with details of functions that can be ported from old DBOS programs
but which do not add any extra functionality those that are described in this guide.
Programmers who are familiar with the older functions and who prefer to use them should
refer to the supplement.
The guide does not try to describe or to document the Windows API, which is a subject too
extensive to be covered here. Full documentation of the Windows API is provided with the
Microsoft Windows Software Development Kit (SDK).
The Salford Tools CD contains example programs that illustrate some of the more common
operations that developers will need in order to produce Windows applications. It also
provides an HTML version of this manual that can be used to extract the sample code that
appears thoughout the text.
This guide is for version 6.0 of ClearWin+. It also includes details of the new branch-view
format (%bv). Enhancements to ClearWin+ that have been added after the preparation of
this guide are described in a README and .ENH enhancement files on the CD and also in
the BROWSE example program.
iii
The chapter headings in this guide are as follows:
page
1. Introduction ............................................................................. 1
2. Getting started ........................................................................ 5
3. ClearWin+ tutorial.................................................................... 7
4. Format windows .................................................................... 19
5. Input and output .................................................................... 37
6. Button controls ...................................................................... 51
7. Controls other than buttons ................................................... 61
8. Bitmaps, Cursors, Icons ........................................................ 75
9. Menus and accelerator keys.................................................. 81
10. Layout and positioning......................................................... 89
11. Displaying text..................................................................... 97
12. Edit box (%eb)................................................................... 107
13. Help .................................................................................. 119
14. Window attributes.............................................................. 121
15. Graphics............................................................................ 135
16. OpenGL ............................................................................ 161
17. SIMPLEPLOT ................................................................... 181
18. Using the printer ................................................................ 189
19. Hypertext windows ............................................................ 199
20. Standard call-back functions.............................................. 205
21. Format code reference ...................................................... 215
22. Compiling and linking......................................................... 293
23. ClearWin windows ............................................................. 299
24. Using the Windows API ..................................................... 305
25. Programming tips .............................................................. 311
26. Library overview ................................................................ 315
27. Library reference ............................................................... 329
28. Glossary............................................................................ 421
Appendix A. Functions ported from DBOS............................... 429
iv
1.
Introduction
Windows applications
ClearWin+ is a library of functions and subroutines that enables developers to
produce Windows applications very quickly. It can be used together with a Salford
Win32 compiler (FTN77, FTN95 or SCC) in order to produce Windows (Win32)
applications for Windows 95 and Windows NT.
Many developers will see the need to take advantage of the graphics user interface
(GUI) that is now available in Windows environments in order to produce applications
that are simple to use and professional in their appearance. At the same time there
will be very few developers who have the time and interest to work through the long
learning curve that is required in order to get to grips with the Windows API - a
Microsoft library that can be used to write Windows applications. Salford’s solution
to this dilemma is ClearWin+. ClearWin+ is designed to be used in a way that
closely emulates traditional programming techniques. The complexities of the
Windows API are avoided by using the ClearWin+ interface with the result that
Windows applications can be developed in a very small fraction of the time that
otherwise would be needed. The resulting programs are much shorter than equivalent
Windows programs produced in other ways.
1
ClearWin+ User’s Guide Fortran
the source code. ClearWin+ will automatically create a window (called a ClearWin
window) complete with scroll bars and manage it for the developer.
At an intermediate level, ClearWin+ can be used to provide a professional graphics
interface, without incurring the burden of directly using the full Windows API. In
particular, the F8=8>/ function can be used to produce one or more fully featured
GUI windows (called format windows) both quickly and easily. This function
dispenses with the need to provide detailed resource scripts for menus, dialog boxes,
etc.. It also largely eliminates the requirement for the user to provide complex call-
back functions in order to control the interface. The effect is that much of the
complexity of using the full API becomes transparent to the programmer. At this
level, Windows API functions are rarely needed.
Finally at the lowest level, it is possible for the developer to use ClearWin+ to write
programs that use Windows API functions. However, even those who are familiar
with the Windows API will probably find it quicker and easier to work at the
intermediate level using the ClearWin+ library.
ClearWin+ is supplied with a full Windows debugger. Detailed information on how
to use the debugger is given the user guides for each of the Salford compilers.
A convention has been adopted in this guide of using mixed case names for the
routines present in the Windows API (for example, CreateWindow, GetDC,
GetTextMetrics). Routines in the ClearWin+ library do not use mixed case names.
2
Chapter 1 Introduction
window also has added functionality which provides all of the standard GUI
facilities in an easily programmed form - enabling the programmer to bypass the
complexities of the Windows API. Chapter 3 provides a tutorial to get you started
with format windows whilst chapters 4 to 21 provide detailed information.
The guide includes a Glossary. Words that have a special meaning in the context of
Windows and ClearWin+ are often presented in italic font and included in the
Glossary.
Please note that Windows 95 has been used to create the illustrations in this user
guide. Other versions of Windows may produce a slightly different appearance.
3
ClearWin+ User’s Guide Fortran
4
2.
Getting started
Introduction
The Salford Tools CD includes a number of programs that illustrate the use of
ClearWin+. Particular attention should be given to the demonstration programs that
illustrate the use of the ClearWin+ function fX]X^/ and to the ‘Browse’ example.
The following instructions explain how to compile, link and execute a very simple
Windows application without using fX]X^/.
Consider a program to calculate the squares of a sequence of numbers and print them
out.
In Fortran this takes the form1:
F8=0??
8=C464A XSg
3> XSg,
?A8=C XSg B`dPaTS Xb XSgXSg
4=33>
4=3
Using your editor, type in the above program and save it as (say) test.for.
Open a DOS box and enter a command line of the form:
5C=&& C4BC ;8=:
This will produce an executable file called test.exe that can be run from the Program
Manager in the normal way or by entering:
1 Throughout this guide INTEGER values are assumed to be 32 bits long unless otherwise stated.
5
ClearWin+ User’s Guide Fortran
C4BC
at the DOS box command line.
Tip Under Windows 95 or Windows NT 4.0 (or later) you may wish to create a shortcut
icon on your desktop to run your program. To do this simply right click on an empty
part of the screen and select New and Shortcut. Then supply the full path name of
your executable program. If you change the program this will not destroy the
shortcut, which will continue to reference the latest version of your program
The above procedure will run your test program and display a window that presents
the output. This program illustrates how ClearWin+ can be used to convert a simple
DOS application without the need to attend to any Windows programming features. It
automatically generates what is called a ClearWin window that handles the input and
output in a Windows environment.
Further information about compiling and linking is given in Chapter 22 whilst
Chapter 23 gives detailed information about using ClearWin windows. The
intervening chapters deal with what are called format windows using fX]X^/.
Format windows provide a quick and easy method for developing fully featured
Windows applications.
6
3.
ClearWin+ tutorial
This tutorial shows you how to develop a simple Windows application using a Salford
Fortran compiler and ClearWin+. It takes you through a step-by-step process leading
to an interactive program that produces the factors of a user-supplied integer. This
“Number Factoriser” is one of the demonstration programs that is supplied with
ClearWin+. The full source code can be found in the file called factor.for.
The tutorial is based on a number of files called factor1.for, factor2.for, etc. that can
be found in the ClearWin+ demonstration directory installed on your hard disk.
These files present stages in the development of the full program. The files are listed
in the tutorial together with a detailed line-by-line explanation of the purpose and
effect of the code. The idea is that you should compile, link and run factor1.for and
then read the explanation for this file. Then proceed to factor2.for and so on.
Step 1
Begin by loading Windows and opening a DOS box.
Now use your text editor to list factor1.for.
Here is the text of factor1.for. Line numbers have been added so that each line can be
referenced in the explanation below1.
F8=0?? 2F?N82>A2
!
" ?A>6A0< UPRc^a
# 8<?;828C =>=4
$ 8=2;D34 +fX]S^fbX]b-
% 8=C464A P]b
1 Throughout this guide INTEGER values are assumed to be 32 bits long unless otherwise stated.
7
ClearWin+ User’s Guide Fortran
The illustrations throughout this manual have been produced using Windows 95. If
you are using another version of Windows then the output will differ slightly in its
appearance.
The quickest way to terminate the application is to press Alt-F4.
Now that you have seen the application running, have a look at the code. Before
looking at line 7, which is the key line in this program, let’s get some preliminaries
out of the way first.
Line 1 provides information for the linker that is called when you use /LINK on the
compiler command line. It causes the linker to produce a Windows executable. For a
Win32 application, the zero values on this line are redundant. (Some later compilers
allow you to omit these values.)
cwp_ico.rc is the name of what is called a resource script that can be found in the
same directory as factor1.for. This particular resource script
provides information about an icon that is embedded in the
application. In the program this “Window” icon is not used in the
application itself but is simply available as a icon that identifies
the application when it is installed in the Program Manager or its
equivalent.
WINAPP must be the first compiler directive in the file and must appear before the
main program.
Line 4 is recommended as a standard line for all programs and routines that use the
file windows.ins. This line is a compiler directive that ensures that all variables are
8
Chapter 3 ClearWin+ tutorial
given an explicit type. It is included because the names of many of the Windows
parameters are very long and consequently they are easy to misspell. Without this
directive, such bugs are very hard to find. The file factor.for is too short for this to
matter, but never-the-less we adopt the practice here as a matter of routine.
Line 5 is a call to include the file windows.ins. The diamond brackets indicate that the
file is located within the Salford compiler directory. This file contains type
declarations for many of the ClearWin+ and Windows API routines and parameters.
The only information of relevance to this particular main program is that fX]X^/
returns an 8=C464A result (in this guide, all integers are 32 bits long unless
otherwise stated). Note that, if you are only using fX]X^/ from the ClearWin+
library, then you will reduce the compilation time by replacing the 8=2;D34 line by
8=C464A fX]X^/
This brings us to line 7 and the heart of this and most ClearWin+ applications.
fX]X^/ is a ClearWin+ function that allows you to create a format window that
displays all manner of graphical user interface (GUI) objects such as menus, buttons,
pictures, formatted text, list boxes and icons. It also allows you to specify what action
is to be taken in response to the options that you present to the user. This means that
this one function can be used to avoid the complexities of writing a GUI application
based on calls to the standard API library combined with a detailed resource script and
complex call-back functions.
The first (and in this case only) argument of fX]X^/ is called a format string. In the
present case the format string starts with %ca and this is an example of what is called
a format code. The format code %ca stands for ‘caption’ and it supplies a title for the
format window. The title itself appears in square brackets after the format code.
There are many format codes available and all of them are represented by a % sign
and a two letter format code. Additional information is often supplied (as here) by
adding text enclosed in square brackets. This text is called a standard character
string. We shall see later that sometimes extra information is placed between the %
sign and the two letters. In other cases the format code is allowed to collect
information from additional arguments that are presented after the initial format
string argument of fX]X^/.
This brings us to the end of step 1 in our development process.
Step 2
Here is the text of factor2.for.
F8=0?? 2F?N82>A2
!
9
ClearWin+ User’s Guide Fortran
A flashing text cursor appears in the inner box and the user is able to enter any integer
in the range from 1 to 2147483647. As before Alt-F4 terminates the application.
The “&” character in line 8 is simply a device to allow the description of the format
window to continue in the next call to fX]X^/ (on line 9 in this case). Using this
device avoids long format strings with long lists of associated arguments.
Line 9 contains the format code %il. This specifies the integer limit for the input on
line 10. %il takes two (8=C464A) values that are provided as extra arguments to
fX]X^/. The lower limit is 1 and the upper limit (2147483647) is the largest possible
32 bit integer. The “&” character allows continuation in the next fX]X^/ call.
In line 9 the format string begins with some text that comes before the next format
code which is %rd. This text is simply copied to the window. The text includes the
space before %rd. Without the %il, the user would be able to enter negative or zero
values which would not make sense in this application.
The %rd format code is used for user integer input. It creates an edit box and displays
the value of the 8=C464A variable (in this case ]d\QTa) that is provided as the next
argument of fX]X^/. The initial value of ]d\QTa in line 7 has been chosen to be in
the permitted range. Users will find that they are only able to type in integers in this
range. Each time a single digit is typed, ]d\QTa is updated so that it always holds the
value that is visible on the screen.
Now we are ready for step 3.
10
Chapter 3 ClearWin+ tutorial
Step 3
Now that we have a window and the user is able to input an integer, the next stage is
to add a button to initiate the factorising process. factor3.for includes code for such a
button. Here is the text:
F8=0?? 2F?N82>A2
!
" ?A>6A0< UPRc^a"
# 8<?;828C =>=4
$ 8=2;D34 +fX]S^fbX]b-
% 4GC4A=0; UPRc^aXbTa
& 8=C464A P]b]d\QTa
' ]d\QTa,
( P]b,fX]X^/RPJ=d\QTa 5PRc^aXbTaL
P]b,fX]X^/X[ ! #&#'"%#&
P]b,fX]X^/=d\QTa c^ QT UPRc^aXbTS) aS]d\QTa
! P]b,fX]X^/cPOMQcJ5PRc^aXbTLUPRc^aXbTa
" 4=3
#
$ 8=C464A 5D=2C8>= UPRc^aXbTa
% UPRc^aXbTa,
& 4=3
Note that lines 6, 12 and 15 to 17 have been added to factor2.for. Also an “&”
character has been inserted after %rd on line 11. We need to look at line 12 in detail.
The other new lines simply declare an external function which for the moment merely
returns the value 1.
When you compile, link and run this program the output looks like this.
But at the moment nothing happens when you click on the button.
Line 12 of the program uses the format code %bt to provide the button. The text on
the button is given as a standard character string (in square brackets) The “&”
character in “Fac&torise” has the visual effect of producing an underscore on the next
letter (‘t’ in this case). The result is that ‘t’ on the keyboard can be used as an
11
ClearWin+ User’s Guide Fortran
alternative to clicking on the button when used in combination with the Alt key i.e.
Alt-T.
Note that two special characters, a grave accent (`) and a caret character (^), have
been included after the % sign. These are two out of a set of four characters called
format modifiers (the others are the tilde (~) and the question mark (?)). As it
happens, all four modifiers may be used with %bt, but the number of modifiers that a
format code can take and the effect each modifier has varies from one format code to
another.
In the present case of the button format %bt, the grave accent means that this button is
the default button. The default button has a slightly different appearance and is the
one that is selected when the Enter key is pressed.
The caret means that a call-back function (called UPRc^aXbTa in this case) is
provided as the next argument of fX]X^/. This is the function that is to be called
when the user clicks on the button. Call-back functions that are used with fX]X^/
must have no arguments and must return an integer value. It is advisable that this
function be declared 4GC4A=0;.
Finally we note that a tab (represented by %ta) has been placed before the %bt format
code. This has been used to separate the button from the text before it. Alternatively,
you could simply use spaces.
A call-back function must return one of the following values:
Step 4
The next thing we need is a child window in order to present the results of the
factorising process. factor4.for includes the code for such a window but we shall leave
out the code that calculates the results until the end. Here is the text of factor4.for:
F8=0?? 2F?N82>A2
!
" ?A>6A0< UPRc^a#
# 8<?;828C =>=4
12
Chapter 3 ClearWin+ tutorial
$ 8=2;D34 +fX]S^fbX]b-
% 4GC4A=0; UPRc^aXbTa
& 8=C464A P]b]d\QTa
' 270A02C4A$ bca
( 2><<>= ]d\QTabca
]d\QTa,
bca,
! P]b,fX]X^/RPJ=d\QTa 5PRc^aXbTaL
" P]b,fX]X^/X[ ! #&#'"%#&
# P]b,fX]X^/=d\QTa c^ QT UPRc^aXbTS) aS]d\QTa
$ P]b,fX]X^/cPOMQcJ5PRc^aXbTLUPRc^aXbTa
% P]b,fX]X^/!][^Q#!bcRQbca
& 4=3
'
( 8=C464A 5D=2C8>= UPRc^aXbTa
! 8=C464A ]d\QTa
! 270A02C4A$ bca
!! 2><<>= ]d\QTabca
!" FA8C4bca]d\QTa
!# 20;; fX]S^fNd_SPcT/bca
!$ UPRc^aXbTa,
!% 4=3
Lines 8, 9, 11, 16 and 19 to 26 have been added and as before an “&” character has
been placed at the end of the format string on line 15.
When the program is compiled the result looks like this:
At the current state of development, when you click on the “Factorise” button, the
number that has been entered is simply copied to the new child window.
The allocation of the variable ]d\QTa to a common block in lines 9, and 22, provides
a method for passing this variable to the UPRc^aXbTa function. You will recall that
call-back functions like UPRc^aXbTa do not have any arguments. Line 23 stores the
value of ]d\QTa as a character string in bca. bca is also held in common because it
is used for output on line 16:
13
ClearWin+ User’s Guide Fortran
P]b,fX]X^/!][^Q#!bcRQbca
On line 16, %2nl provides two line feeds so that the child window that follows is
placed below the existing controls.
The %ob format code is used to open a box at the current position. It automatically
marks the position of the top left-hand corner of a box that will be drawn when a
corresponding %cb (close box) is encountered. %cb automatically marks the position
of the bottom right-hand corner of the box. The box is simply provided as a border.
The enclosed area has no special attributes. In the present case the box is used to
enclose a string that is produced by the %st format. The string is located in bca and
the width of the associated area is 42 characters. However, the standard width of a
character in this context will be the maximum width of all the characters of the
proportionally spaced font.
Finally, line 24 has the effect of updating the string on the screen in order to reflect a
change in the contents of bca.
Step 5
Now we shall add a menu bar with an associated “About” dialog box in order to create
factor5.for. Here is the text, but to make it easier to understand, only those parts of
facror4.for that have changed are listed in full.
% 4GC4A=0; UPRc^aXbTaPQ^dc
! P]b,fX]X^/RPJ=d\QTa 5PRc^aXbTaL
" P]b,fX]X^/\]J5X[TJ4gXcLL4G8C
# P]b,fX]X^/\]J7T[_J0Q^dc =d\QTa 5PRc^aXbTaLLPQ^dc
$ P]b,fX]X^/X[ ! #&#'"%#&
( 4=3
!
! 8=C464A 5D=2C8>= UPRc^aXbTa
!' 4=3
!(
" 8=C464A 5D=2C8>= PQ^dc
" 8<?;828C =>=4
"! 8=2;D34 +fX]S^fbX]b-
"" 8=C464A P]b
"# P]b,fX]X^/RPJ0Q^dc =d\QTa 5PRc^aXbTaL
"$ P]b,fX]X^/U]JCX\Tb =Tf A^\P]LcbQUR]Cdc^aXP[!3
"% P]b,fX]X^/cb#][ 3
"& P]b,fX]X^/R]?a^VaP\ faXccT] c^ ST\^]bcaPcT!][
"' P]b,fX]X^/cbcRR]QU2[TPaFX] $3A61/!$$
"( P]b,fX]X^/cRbU!][R]Qh
14
Chapter 3 ClearWin+ tutorial
# P]b,fX]X^/!][R]BP[U^aS B^UcfPaT
# P]b,fX]X^/!][R](OQcJ>:L
#! PQ^dc,
#" 4=3
A new call-back function called PQ^dc has been added to line 6 and the code for this
function has been added to the end of factor4.for in lines 30 to 43. The new menu bar
has been included as lines 13 and 14 after the caption in line 12.
This is what the compiled program displays on the screen.
When you click on the “Help” menu and then on the “About Number Factoriser” item,
you get the dialog box below.
Now for the details of how this effect is created. First look at lines 13 and 14 for the
menu bar.
" P]b,fX]X^/\]J5X[TJ4gXcLL4G8C
# P]b,fX]X^/\]J7T[_J0Q^dc =d\QTa 5PRc^aXbTaLLPQ^dc
The menu format is provided by %mn. Square backets enclose a list of menu topics,
with each topic having an optional embedded list of associated menu items. There are
two menu topics here, “File” and “Help”. These provide for two drop down menus
each of which (in this example) has one item . The “&” character is used in the same
way as on a button in order to provide an accelerator key.
15
ClearWin+ User’s Guide Fortran
Each menu item requires a call-back function and these are provided as further
arguments to fX]X^/. The first one ('4G8C') refers to what is called a standard
ClearWin+ call-back function. When a standard call-back function is used, the code
for the function is supplied by ClearWin+ rather than by the programmer. In this
case the effect of calling the function is simply to close the application.
The second call-back function (PQ^dc) is supplied by the progammer. In this case the
PQ^dc function displays a dialog box that describes the application. When the user
clicks on the OK button, the dialog box closes but the application remains active. If
PQ^dc returned zero instead of a 2, the application would also close when the OK
button was used.
All we need to do now is look at the new call-back function for the “About” dialog.
Let’s concentrate on the format codes that we have not seen before in this tutorial.
%fn defines a new font for the text that follows. In this case the font is “Times New
Roman” and this font is used for the subsequent text up to the %sf format code on line
39. %sf stands for “standard font” and has the effect of resetting all text attributes
(font, size, colour, bold, italic, and underline) to the default settings.
%ts is used to set the text size. It takes one 3>D1;4 ?A428B8>= argument. The
value 2.0D0 on line 35 doubles the standard text size and then the standard size is
restored on line 36 with the value 1.0D0. Line 38 uses a text size of one and a half
times the standard and then the standard size is restored with %sf on line 39.
%bf on line 35 is used to provide bold faced font whilst %cn has the effect of centring
the line of text in the dialog box. In this example %cn is cancelled by the next
16
Chapter 3 ClearWin+ tutorial
newline format (%nl). On line 38, %tc changes the colour of the text to red. The
colour is provided by the call to the ClearWin+ function A61/. A61/ takes three
8=C464A arguments in the range 0 to 255. These provide the red, green and blue
intensities. Note that %ts comes before %tc and uses the 1.5D0 argument on line 38.
%tc is also used on line 39. In this case the argument (-1) restores the system text
colour. This is one of the screen colours that the user can set from the Control Panel
in the Program Manager.
Finally line 41 produces the OK button. As before the grave accent makes this the
default button, whilst the value 9 has the effect of widening the button to a 9 character
width. This button does not have a call-back function. As a result, when the user
clicks on the button, the format window closes. If there are a number of buttons like
this, then the value returned by fX]X^/ (P]b in this case) gives the number of the
button that was pressed.
Step 6
factor6.for contains the finished program. In this program the UPRc^aXbTa function
has been developed to do the calculations needed to factorise the number that is
supplied by the user. The details of this simple Fortran code are not of direct interest
to us in this tutorial but here is the code for those who want to read it.
8=C464A 5D=2C8>= UPRc^aXbTa
8=C464A ]d\QTa]Z
270A02C4A$ bcaeP[
2><<>= ]d\QTabca
FA8C4eP[X ]d\QTa
20;; caX\/eP[
bca,CWT UPRc^ab ^U eP[ );4=6eP[ PaT)
],]d\QTa
3> Z,!]
85]ZZ4@]C74=
FA8C4eP[X Z
20;; caX\/eP[
20;; P__T]SNbcaX]V/bca eP[
],]Z
85]6C 6>C>
4=385
4=3 3>
20;; fX]S^fNd_SPcT/bca
UPRc^aXbTa,
4=3
17
ClearWin+ User’s Guide Fortran
This brings us to the end of the tutorial. In this one demonstration program you have
been introduced to some of the important format codes that come with fX]X^/. More
importantly you have been able to experience the ease with which it is possible to
develop a GUI application with ClearWin+.
18
4.
Format windows
Introduction
This chapter presents an overview of the ClearWin+ function fX]X^/ that was
introduced in Chapter 3. Further details are given in the following chapters up to
Chapter 21 which provides a detailed reference.
fX]X^/ is used to lay out and control a window in order to include a wide variety of
controls, child windows, toolbars, etc.. Of course, this task could be carried out by
making direct use of the Windows API. Although the direct method does provide
maximum flexibility, it also requires large amounts of complex coding in order to
control the interface. In contrast, the fX]X^/ function requires a bare minimum of
code to achieve elaborate window interfaces.
Windows applications typically have a great deal of “low level” functionality. For
example, a window with several input controls will let the user move between fields
using the tab key or the mouse. Likewise, buttons change their appearance slightly
when they acquire focus. Fortunately you do not need to write code to program this
functionality into your application, as it is already supplied by ClearWin+.
The following example illustrates the power and flexibility of fX]X^/. In this
example fX]X^/ is used to produce a window that includes a menu bar with
associated standard call-back functions. The window contains a so-called edit box
that is used to display and edit a file. The menu and edit box is fully functional.
Three buttons are also shown on the right hand side of the window. These are used to
illustrate how buttons are added to the window. As the example stands, clicking on
any of these buttons has no effect since code for the corresponding processes has been
omitted.
F8=0??
8=2;D34 +fX]S^fbX]b-
19
ClearWin+ User’s Guide Fortran
270A02C4A !( UX[T]TfNUX[TWT[_NUX[T
8=C464A R^\_X[T[X]Zad]X
4GC4A=0; R^\_X[T[X]Zad]
WT[_NUX[T,\hWT[_W[_
X,fX]X^/RPJ4gP\_[TL
X,fX]X^/\]J5X[TJ>_T]LL´438CN58;4N>?4=
UX[T
X,fX]X^/³\]JJBPeTLL´438CN58;4NB0E4
]TfNUX[T
X,fX]X^/³\]JJBPeT 0bLL´438CN58;4NB0E4N0B
]TfNUX[T
X,fX]X^/³\]JJ4gXcLL4G8C
X,fX]X^/\]J4SXcJ2^_hLL´2>?H
X,fX]X^/³\]JJ2dcLL´2DC
X,fX]X^/³\]JJ?PbcTLL ?0BC4
X,fX]X^/\]J7T[_J2^]cT]cbLL´74;?N2>=C4=CB
WT[_NUX[T
X,fX]X^/³\]JJ7T[_ ^] WT[_LL74;?N>=N74;?
WT[_NUX[T
R 3TUX]T P "g TSXc Q^g TQ
X,fX]X^/ff_e
X,fX]X^/" TQJebRa^[[QPaWbRa^[[QPaL
R 3TUX]T Qdcc^]b cWPc PaT c^ QT SXb_P[hTS
X,fX]X^/!][ M&QcJ2^\_X[TLR^\_X[T
X,fX]X^/!][ M&QcJ;X]ZL [X]Z
X,fX]X^/!][ M&QcJAd]L ad]
4=3
R 2P[[QPRZ Ud]RcX^]b cWPc S^ ]^cWX]V
8=C464A 5D=2C8>= R^\_X[T
R^\_X[T,
4=3
8=C464A 5D=2C8>= [X]Z
[X]Z,
4=3
8=C464A 5D=2C8>= ad]
ad],
4=3
This is what the window looks like on the screen:
20
Chapter 4 Format windows
The reminder of this chapter and the following chapters up to and including Chapter
21 provide a detailed explanation of how to set out the parameters of fX]X^/.
Call-back functions
A ClearWin+ call-back function takes no arguments and returns an integer result. As
a result, such functions may be coded in C, C++, or Fortran.
When a call-back function returns, it indicates what is to happen next by its return
value. A negative or zero value signals an exit and closes the parent format window.
The corresponding call to fX]X^/ will return the absolute value of this quantity. A
return value of 1 will cause a full update of the format window so that any changes are
made visible. This should be used sparingly because if a call-back is used repeatedly,
then the whole display area may flicker due to the frequent screen updates. A more
efficient approach is to use a return value of 2. This will not cause the format window
to close nor will it update the window. In order to refresh any part of the display that
needs to be refreshed, a call to fX]S^fNd_SPcT/ will suffice. This will also improve
the response since only small sections of the display will be redrawn.
21
ClearWin+ User’s Guide Fortran
Tip Returning a negative value can be very convenient. Consider a window with a list
box and OK and CANCEL buttons. Typically it is required that a double click on a
list box item will select that item and close the window as if the OK button had been
pressed. To achieve this the list box call-back function should return -1, so that
fX]X^/ will return 1 as if the OK button had been pressed - thus saving a flag and
more complex program logic.
It is often convenient to use one call-back function for a variety of reasons. Whenever
a call-back function is invoked, ClearWin+ defines a string that specifies the reason
for the call. This string is obtained by calling
R[TPafX]NbcaX]V/’20;;102:NA40B>=´. Testing the string makes it easy to
determine the reason for the call. See page 342 for further details.
Window formats
The ClearWin+ function fX]X^/ has the following form:
8=C464A fX]X^/U^a\Pc
270A02C4A U^a\Pc
where the ellipses ... represents a list of arguments whose length depends on what
appears in the character variable U^a\Pc. The character string is called a format
string. The list must only contain arguments of type 8=C464A, 3>D1;4 ?A428B8>=,
270A02C4A or 4GC4A=0; functions.
At its very simplest, fX]X^/ may be used to display information:
F8=0??
8=2;D34 +fX]S^fbX]b-
3>D1;4 ?A428B8>= gh
g,
h,!$
22
Chapter 4 Format windows
%wf is an example of a format code. The %wf format code displays a floating point
value with six decimal places as the default. New lines are represented by %nl, and
tabs %ta operate on a grid of 8-character intervals or by setting tab stops with the %tl
format (see page 90). %2nl (for example) is used for two new lines and %3ta (for
example) is used for three tabs. Form-feed (%ff) has a special meaning in a format
window. It moves the current position to the left margin, beneath any existing
controls. The window is automatically constructed with a size to suit its contents.
%wd, %wx, %ws, %wc, %we, and %wg are alternatives to %wd & %wf with the
following usage:
Each of these output format codes can be modified in order to control the manner in
which the information is presented. Details are given on page 45.
By using the additional format codes described below and in the following chapters,
the resulting windows can prompt for and display a wide variety of information.
Each format code begins with the percent (%) character, followed by optional size
information of the form n or n.m where n and m are integer constants (e.g. %6.4wd).
n and/or m can be replaced by an asterisk “*” with the corresponding value(s) being
supplied as one or two 8=C464A arguments in the argument list. After the optional
size information, a two-letter code is used to define the format. This two letter code is
not case sensitive. Some format codes have mandatory size information. These sizes
are represented by uppercase N and M in the text.
23
ClearWin+ User’s Guide Fortran
Four special characters, known as format modifiers, are often inserted after the size
information and before the two-letter code. The first of these is the caret character (^)
which indicates that a call-back function is supplied in the argument list (after any
other arguments required by the format code). The tilde character (~) is used with
certain format codes to control the disabling (greying) of the control. The grave
accent character (`) is also used to modify the action of certain codes. These
characters may only be used with the codes that define them as detailed in Chapter 21.
The fourth character is the question mark (?) that is used with any format that defines
a control (as opposed to formats such as %ww that modify the appearance of the
window as a whole). The question mark signifies that a help string is supplied in the
format. This string is displayed at the bottom of the window or as a help “bubble”
whenever the user’s cursor lies over the corresponding control. The text is either
surrounded by square brackets, or a “@” character is placed in the format string to
indicate that the help string is supplied as an extra argument. The text string that is
supplied in either of these two forms is known as a standard character string.
Many format codes are supplied with a list of options. When used, these are placed in
a comma-separated list and set between square brackets after the two-letter format
code. For example
VaJQ[PRZaVQNR^[^dabL
If none of the options are used then the list, together with the square brackets, may be
omitted. However, if the option list is empty and a help string is required, then square
brackets must be inserted to represent the empty list. These brackets are followed by
the help string. For example:
! .TQJLJ4SXc Q^gL
Here is an example that uses a help string. It prompts the user for an integer (%rd)
and augments the window with an additional help string.
F8=0??
8=2;D34 +fX]S^fbX]b-
8=C464A ]NRW
]NRW,
X,fX]X^/=^ ^U RWX[SaT] .aS
J7^f \P]h RWX[SaT] WPeT h^d V^c.L]NRW
4=3
The following code would produce the same result:
270A02C4A' WT[_
WT[_,7^f \P]h RWX[SaT] WPeT h^d V^c.
]NRW,
X,fX]X^/=^ ^U RWX[SaT] .aS/]NRWWT[_
4=3
24
Chapter 4 Format windows
Help strings may include line feed characters (RWPa ) if necessary. The area to
contain the help text will be sized to fit the dimensions of the largest string. The help
text can be positioned at another location (e.g. inside a box) by using the %he format.
Alternatively, %bh provides for ‘bubble’ help and %th for ‘tooltip’ help (see page
119).
A toolbar requires a help string for each button (see the %tb example on page 56).
Calls to fX]X^/ may become quite complex. For this reason, a method is available to
continue a format over several calls to fX]X^/. If the last character in a format string
is an ampersand (&) character, this character is removed from the string and the
format information is joined seamlessly to the next call to fX]X^/.
For example:
X,fX]X^/4]cTa P] X]cTVTa cPaS][]
X,fX]X^/4]cTa P bTR^]S X]cTVTacPaS][\
X,fX]X^/R]OQcJ3^]TL
This creates a single window containing two integer edit boxes together with a button.
Note that, using this technique, it is possible to build a dialog box with a structure that
is controlled by your program logic. For example, if the user had already supplied a
file name you could omit a file open box, possibly replacing it with a suitable message.
If you choose to write some routines in Fortran and others in C++, then the
programming language that you use for the first call to fX]X^/ for a given format
window must be the same as that used in any continuation calls. However, it is
possible to create one format window using Fortran and another using C++.
Closing a window
ClearWin+ programs may create a number of windows, some of which might be open
at the same time. A ClearWin+ program terminates when both a) the END point of
the program (or its equivalent) is reached, and b) all windows created by the program
have been closed by the user.
25
ClearWin+ User’s Guide Fortran
Normally the user is provided with a number of ways to close a window. There is
usually a system menu with a ‘Close’ item (Alt+F4) at the top left of a window.
:
Selecting this item is equivalent to clicking on the box at the top right of a window.
The programmer can use %cc with a call-back function to trap this event.
The programmer can also add an ‘Exit’ item to a %mn menu. This item will either be
linked to a call-back function provided in the program or to the standard ‘4G8C’ call-
back.
Other exit routes can be provided via buttons (using for example %bt or %tt):
a) When you click on the button that has no call-back function attached, the parent
window will close. If there is only one window open, the effect is the same as if
the standard ‘4G8C´ call-back were attached to the button.
b) If there is no call-back function attached to a button and the associated window has
been created within a call-back function, then the window will close. The affect on
the window’s parent will depend on the value returned by the call-back (see page
22). A zero return will close the window’s parent. The same is true for any call-
back, not just those attached to buttons.
Another approach to window closure is to attach a control variable to a window.
When a window (or dialog) is created, by default it will be equivalent to a modal
dialog box. A modal dialog box is one that must be closed before other windows in
the same application can be accessed. Any code that follows the fX]X^/ calls for a
particular modal dialog box, will not be processed until the user closes the dialog.
If you want more than one window to be accessible (the equivalent of a modeless
dialog box) then you can use %lw (see page 122) to leave a window open and to attach
a control variable to the window. The presence of %lw causes any code that follows
the fX]X^/ calls for a particular window to be processed immediately. ClearWin+
sets the value of a %lw control variable to -1 (minus one). If the control variable is
subsequently set a non-negative value, the window will close when that variable is
updated (see below).
Notes
1. %lw is used together with %fr and %aw to create a multi-document interface.
2. %cv also provides a control variable for use with %aw but in this case the window
will be a child window and will not be left open.
Updating windows
Many of the format codes of the fX]X^/ function take pointers to data that may
change. For example, the bar control variable in the %br format will typically change
26
Chapter 4 Format windows
as some time consuming process proceeds. Likewise, consider the following partial
window definitions:
270A02C4A$ \hU^a\
\hU^a\,C4BC
X,fX]X^/RP/\hU^a\
The address of the variable \hU^a\ has been passed to fX]X^/, and if the contents of
the string \hU^a\ alter, it is desirable to update the window accordingly. In general,
if you alter data that is in use by a window, the window will be updated if it is
obscured and restored for any reason.
However, to obtain an immediate update, the subroutine
BD1A>DC8=4 fX]S^fNd_SPcT/ePaXPQ[T
should be called. The argument is the variable whose value has changed. In reality
the address of the variable is passed and this address must be the exact address
originally passed to fX]X^/. For example, in the above example, the address of the
first character in the string would be passed to fX]S^fNd_SPcT/ using
20;; fX]S^fNd_SPcT/\hU^a\
The update would not work if the address of the second character (i.e. \hU^a\!)!)
where passed, even though this address points to part of the caption. The
fX]S^fNd_SPcT/ function will update all controls, captions, etc. that depend on the
variable. It may also be used with a grey-control variable (see for example %bt, page
51), or the control variable associated with the %lw format. In the latter case, setting
the control variable to a non-negative value means that the window will close.
Note that, in general, fX]S^fNd_SPcT/ will only update those objects that depend on
the variable whose address is supplied. However, there is no guarantee that other
portions of the display will not become updated in the process.
It is desirable that fX]S^fNd_SPcT/ be called at a sensible rate. Perhaps no more
than once or twice per second for a given variable. Frequent updates may produce an
unpleasant flicker.
27
ClearWin+ User’s Guide Fortran
There are three ways in which the usage of fX]X^/ can be varied under program
control. First, you can use fX]X^/ statements within flow control constructs such as
DO and IF constructs. Here is a simple example.
F8=0??
8=C464A ]XfX]X^/
2><<>= ]
4GC4A=0; RQNUd]R
X,fX]X^/=d\QTa ^U [X]Tb) #aS]
X,fX]X^/!][R]MccJBW^fLRQNUd]R
4=3
R
8=C464A Ud]RcX^] RQNUd]R
8=C464A ]XYfX]X^/
2><<>= ]
3> Y, ]
X,fX]X^/;X]T fS][Y
4=33>
X,fX]X^/
RQNUd]R,
4=3
The first dialog box allows you to enter a number. Clicking on the button then
produces another dialog box with the given number of lines of output. Notice that the
format string within the DO loop is terminated by an ampersand (&) to allow the
description of the dialog box to continue on the next loop. The final call to fX]X^/
acts as a terminator. It contains only a format string with a single space character.
The same idea can be used with other flow control constructs containing calls to
fX]X^/
A second method for varying the use of fX]X^/ under program control involves
changes to the format string. The next example illustrates the idea.
F8=0??
8=C464A ]XfX]X^/
2><<>= ]
4GC4A=0; RQNUd]R
],
X,fX]X^/5^a\Pc ^a !) #aS]
X,fX]X^/!][R]MccJBW^fLRQNUd]R
4=3
R
8=C464A Ud]RcX^] RQNUd]R
8=C464A ]XYfX]X^/
2><<>= ]
270A02C4A U\c
28
Chapter 4 Format windows
29
ClearWin+ User’s Guide Fortran
4=3
R
8=C464A Ud]RcX^] RQNUd]R
8=2;D34 +fX]S^fbX]b-
8=C464A ]X
2><<>= ]
270A02C4A! U\c
3>D1;4 ?A428B8>= g
g,]
85]T` C74=
U\c,8]cTVTa fS
20;; PSSNfX]X^NX]cTVTa/]
4;B4
U\c,ATP[ fU
20;; PSSNfX]X^NU[^Pc/g
4=385
X,fX]X^/U\c
RQNUd]R,
4=3
This example is too simple to do justice to the concept but it is sufficient to point the
way.
1) Interactive I/O: %co, %dd, %df, %dl, %dr, %fl, %il, %rd, %rf,
%rs
2) Controls: %bc, %br, %bt, %bv, %bx, %el, %ga, %hx,
%ib, %ld, %ls, %lv, %ms, %rb, %sl, %tb, %tt,
%tv, %vx
3) Bitmaps, Cursors, Icons: %bi, %bm, %cu, %dc, %gi, %ic, %mi, %si
4) Menus and accelerator keys: %ac, %es, %mn, %pm, %sm
5) Layout and positioning: %ap, %bd, %cn, %dy, %ff, %gd, %gp, %nd,
%nl, %nr, %pv, %rj, %rp, %ta
6) Boxes: %cb, %ob
7) Displaying text: %bf, %eq, %fn, %gf, %ht, %it, %pd, %sd, %sf,
%st, %su, %tc, %ts, %tl, %ul
30
Chapter 4 Format windows
31
ClearWin+ User’s Guide Fortran
%cc Closure control format - provides a link to a call-back function by which 130
the user controls the action to be taken when a window is closed.
%ch Child window format - inserts a child window. 123
%cl Displays a colour palette. 73
%cn Centring format - forces everything which follows it, up to the next new 89
line or form-feed character, to be centred in the window.
%co Control option format - used to modify subsequent %rd, %rf, and %rs 40
boxes.
%cu Establishes a cursor for the next control in a format. 76
%cv Control variable format. 123
%cw Embeds a ClearWin window. 128
%dc Establishes a default cursor for the window. 76
%dd Increase/decrease button for an integer. 41
%de Disables some other window while the current window is active. 232
%df Increase/decrease button for a floating point value. 41
%dl Allows a call-back function to be called at regular intervals via a timer. 130
%dp Parameter box format. 263
%dr Drag and drop. 125
%dw Owner draw box format - provides owner draw boxes. 157
%dy Provides a vertical displacement by a non-integral number of character 235
depth units.
%eb Edit box format - presents a edit box in which a text file is displayed 107
and modified.
%el Inserts an editable combo box. 236
%ep Parameter box format. 263
%eq Equation format - inserts a mathematical equation in a window. 100
%es Escape format - causes the program to exit when the 4bRP_T key is 237
pressed.
%ew Exit Windows format - provides a call-back function which is called 238
when the user shuts down.
%fb Remember current font for subsequent buttons. 238
%ff Form feed. Move down to below any existing controls. 239
%fh Font handle - use a font created by the API function CreateFont. 239
%fl Floating point limit format - specifies the lower and upper limits for 41
subsequent %rf formats.
%fn Font name format - selects a font for subsequent text. 97
%fp Parameter box format. 263
32
Chapter 4 Format windows
%fr MDI frame format - defines a frame to contain child windows attached 123
by %aw.
%fs File selection format - specifies the working directory and file filter for 105
subsequent file open call-backs.
%ft File filter format - specifies filter information for subsequent file open 106
call-backs.
%ga Gang format - enables radio buttons and/or bitmap buttons to be ganged 59
together so that if one is switched on the others are switched off.
%gd Programmer's grid format - supplies a temporary grid to help with the 95
positioning of controls.
%gf Get font handle format. 97
%gi Draws a (possibly animated/transparent) GIF image. 243
%gp Get window position format - used to get the current co-ordinates of the 94
window position.
%gr Graphics format - provides a rectangular area for Salford graphics ch 15
routines.
%he Help format - specifies the location of help information. 119
%ht Hypertext document attachment. ch 19
%hw Obtains the window handle of the format window. 121
%hx Attaches a horizontal scroll bar to the next control. 247
%ib Image bar - a replacement format for %tb. 247
%ic Icon format - draws an icon. 77
%if Initial focus format - specifies that the next control will have the initial 249
focus.
%il Integer limit format - specifies the lower and upper limits for 42
subsequent %rd formats.
%it Switch to italic font. 97
%lc Obtain the control handle. 249
%ld LED format - displays a round LED (a coloured disk with a black 251
border).
%ls List box format 62
%lv Listview format 252
%lw Leave window open format - allows fX]X^/ to return without closing 122
the window that it creates.
%mg Message format - provides a call-back function for a given Windows 257
message.
%mi Minimise icon format - supplies the name of an icon resource to be used 77
if the window is minimised.
%mn Menu format - used to attach a menu to the window. 81
33
ClearWin+ User’s Guide Fortran
%ms Defines a multi-selection box that stores its settings in an array. Similar 64
to %ls
%mv Move format - provides a call-back function that is to be called when 259
the user moves or resizes the window.
%nc New class name format - provides a specified class name for the 260
application.
%nd Never-down format - prevents controls from sliding down when sizing a 260
window.
%nl New line 260
%nr Never-right format - prevents controls from sliding to the right when 261
sizing a window.
%ns Disable screen saver. 133
%ob Box open format - defines the top left hand corner of a rectangular box 91
into which subsequent objects are to be placed until a corresponding
%cb format is encountered.
%og Graphics format - provides a rectangular area for OpenGL graphics ch 16
routines
%pb Parameter box format. 263
%pd Is used to insert a Sterling pound symbol ‘£’ regardless of editor mode. 100
%pm Supplies a popup menu so that when the right mouse button is pressed 84
in the main window a menu appears.
%ps Property sheet - layer windows to produce a card index style. 129
%pv Pivot format - used to create a pivotal point for any subsequent re-sizing 93
of the window.
%rb Radio button format - defines a radio button or check box with text 55
supplied directly.
%rd Integer input format - creates an edit box and displays an integer that 37
can be updated.
%re Creates an multi-line edit box. 268
%rf Floating point input format - creates an edit box and displays a floating 37
point value that can be updated.
%rj Right justifying format - forces everything which follows it, up to the 90
next new line or form-feed character, to be right justified in the window.
A window margin, if any, is still applied.
%rm Read message format - Provides the name of a call-back function to 270
handle messages from another ClearWin+ application.
%rp Relative position format - Sets the position of the next control relative to 270
the current position.
%rs Character string input format - creates an edit box and displays a 40
character variable (i.e. a string) that can be updated.
34
Chapter 4 Format windows
%sc Start-up call-back. Causes a call-back to be called once when a window 123
is opened - useful for drawing initial %gr data.
%sd Subscript text format. 272
%sf Standard font format - resets to default text attributes after use of any 98
combination of %bf, %it, %ul, %fn, and %ts.
%sh Used with property sheet format. 130
%si Standard icon format - defines a standard icon that is to be placed to the 78
left of the block of text that follows the descriptor.
%sl Produces a slider control using a floating point variable to determine its 44
position.
%sm System menu format. 86
%sp Set window position format - used to initialise the position of the 94
window on the screen.
%ss Allows the settings of selected controls to be auto saved and loaded 48
from an INI file.
%st Variable string format - lays a string out in a field of n characters. The 100
string is re-drawn each time the window is renewed.
%su Superscript text format. 277
%sv Allows the program to become a screen saver executable. 132
%sy Style format - changes the style of a window. 277
%sz Size window format. 126
%ta Insert tab 8-character intervals or to predefined tab stops. See %tl. 279
%tb Bitmap button and toolbar format - defines a bit mapped button or a 56
whole tool-bar.
%tc Sets the colour of subsequent text. 99
%th Bubble help in the form of a ‘Tool tip’. 281
%tl Sets up tab locations for use with %ta. 90
%tp Parameter box format. 263
%ts Text size format - used to scale the text font size either up or down. 99
%tt Textual toolbar format. 54
%tv Hierarchical tree-view 68
%tx Displays an array of text in a rectangular region, defined by its 103
parameters.
%ul Underline text. 97
%up Parameter box format. 263
%uw User window allows windows code to be interfaced to ClearWin+. 131
%vx Attaches a vertical scroll bar to the next control. 286
%wc Character output. 45
%wd Integer output. 45
35
ClearWin+ User’s Guide Fortran
36
5.
Interactive I/O
Reading numbers or character strings from a window under ClearWin+ is very
similar to reading data in a traditional program using A403. However, it is important
to remember that each variable must be given an initial value before the window is
created since a default value will appear as soon as the window is displayed.
Tip Checkmate can be used to flag an error when a variable that has not been given a
value is used.
Those controls that allow the user to edit text in a box (such as %rd) can also transfer
text to/from the clipboard using the special ClearWin+ call-back functions 2DC
2>?H ?0BC4, defined in the standard call-back functions described in Chapter
20.
37
ClearWin+ User’s Guide Fortran
A call-back function is supplied using the caret (^) modifier. This function is called
whenever a change is made.
A grave accent format modifier (`) may be used to make the control read-only. In this
form no surrounding box is supplied, and the value displayed can only be changed by
the program, using fX]S^fNd_SPcT/ to reflect the changes.
38
Chapter 5 Input and output
X,fX]X^/MaUhR^]eTacNc^N_^[Pa
X,fX]X^/UU XcaOXc,cP
X,fX]X^/MaUaR^]eTacNc^Ngh
X,fX]X^/ U]JBh\Q^[LXc`bU ,cP
X,fX]X^/MaUcWTcPR^]eTacNc^Ngh
4=3
R
8=C464A 5D=2C8>= R^]eTacNc^N_^[Pa
3>D1;4 ?A428B8>= ghacWTcPcX]h
2><<>= ghacWTcP
cX]h, 3%
a,B@ACgghh
85g;CcX]h0=3h;CcX]hC74=
cWTcP,
4;B4
cWTcP,0C0=!hg
4=385
R^]eTacNc^N_^[Pa,
4=3
R
8=C464A 5D=2C8>= R^]eTacNc^Ngh
3>D1;4 ?A428B8>= ghacWTcP
2><<>= ghacWTcP
g,a2>BcWTcP
h,aB8=cWTcP
R^]eTacNc^Ngh,
4=3
A grave accent format modifier (`) is used to make the control read-only. In this form
no surrounding box is supplied, and the value displayed can only be changed by the
program, using fX]S^fNd_SPcT/ to reflect the changes.
The %co format (see page 40) is used to modify the way that %rf and %rd call-back
functions behave.
39
ClearWin+ User’s Guide Fortran
For example:
X,fX]X^/³R^J]^NSPcPNQ^aSTaLX[aS´ Y
X,fX]X^/³][R^JSPcPNQ^aSTaLaS´Z
places a box around the second data area but not the first.
40
Chapter 5 Input and output
41
ClearWin+ User’s Guide Fortran
value 525.0, the number would be rejected as soon as the first digit 5 is entered. If
2742:N>=N5>2DBN;>BB is not used then the lower limit should be chosen to avoid
this problem.
42
Chapter 5 Input and output
8=2;D34 +fX]S^fbX]b-
4GC4A=0; PRcX^]
8=C464A XcTgcdaTNch_T
3>D1;4 ?A428B8>= e_P
270A02C4A' cTgcdaTb%
270A02C4A! ]P\T
30C0 cTgcdaTbBcXRZh<Tbbh3Xach6aTPbhB[X\h
ETah b[X__Tah
30C0 Z Z!Z#Z$ecTgcdaTNch_TP !#$#$#"$#
_, !%
]P\T,1[PRZ ] BcXRZh !"
X,fX]X^/ffJRPbcbNbWPSS^fLRPJ?PaP\TcTa bTccX]VL
X,fX]X^/3^dQ[T R[XRZ ^] cWT _PaP\TcTa h^d fXbW c^´
´RWP]VT)!][
X,fX]X^/"'_QJb^acTSL
X,fX]X^/S_JcTbc LZ
X,fX]X^/S_JcTbc!LZ!
X,fX]X^/T_J>X[ cTgcdaTLcTgcdaTb%cTgcdaTNch_T
X,fX]X^/S_JCT\_TaPcdaT 3TV 2LZ#
X,fX]X^/S_J2PaQ^] \^]^gXST LZ$
X,fX]X^/U_J2daT]c 0\_bcTbc%LP
X,fX]X^/ "U_JE^[cPVTLe
X,fX]X^/U_J>X[ _aTbbdaT ?B8L_
X,fX]X^/
.c_J>X[ ]P\TLJFWPc Xb cWT ^UUXRXP[ ]P\T ^U cWXb ^X[.L
! ]P\T
X,fX]X^/d_JB_TRXP[ PRcX^]LPRcX^]
4=3
43
ClearWin+ User’s Guide Fortran
44
Chapter 5 Input and output
Data output
Each of the format codes %wd, %wx, %wf, %we, %wg, %ws, and %wc, can be
modified in order to control the way in which the information is presented in the
dialog window. The modifiers are all optional and appear after the % sign with the
following general form:
%[flags][width][.precision] code
where code is one of wd, wf, etc.
[width] represents a positive integer that specifies the minimum number of characters
that are to be output. More characters will be output rather than truncate the result.
Where fewer than the minimum are needed, by default the field is padded with spaces
on the left. Note, however, that with a proportionally spaced font, padding may have
little apparent effect.
[.precision] represents a full stop followed by a positive integer that specifies the
precision of the output. For floating point values, this integer is usually the required
number of decimal places in the output.
Alternatively the [width] and [.precision] values may be replaced with an asterisk (*).
For example:
%[flags][*.*] code
Integer values must then be supplied as arguments, one for each asterisk.
[flags] represents one or more of the characters: minus “-”, zero “0”, plus “+”, and the
hash symbol “#”. These modifiers have various effects depending on the current
format code. For example they are used to force left justification, to pad with zeros
rather than spaces, and to force a plus sign for a non-negative result.
In the following examples ∇ is used to represent a space.
%wc
%wc is used for the output of a single character. The width modifier may be used to
pad out a field with spaces and the minus flag will cause the character to be left
justified in such a field.
%wd
%wd is used for the output of integer values.
45
ClearWin+ User’s Guide Fortran
Use this format only for displaying formatted text output that does not need to be
refreshed when a variable is modified. Otherwise use %`rd in conjunction with the
fX]S^fNd_SPcT/ call. The grave accent makes the %rd format a read-only text
display box.
%we
%we is used for the output of floating point values in exponent form. The exponent
part (following the letter ‘e’) always contains a sign and two digits.
format output for x=0.0126 comment
%we 1.2607000e-02 6 decimal places, otherwise minimum
width
%14we ∇∇1.260000e-02 minimum of 14 characters, right justified
%10.2we ∇∇1.26e-02 10 characters, 2 decimal places
%6.0we ∇1e-02 6 characters, no decimal point
%-9.1we 1.3e-02∇∇ 9 characters, 1 decimal place, left justified
%010.3we 01.260e-02 right justified, padded with zeros
%+10.2we ∇+1.26e-02 force a + sign when not negative
%#8.0we ∇∇1.e-02 forces a decimal point when the precision
modifier is zero
46
Chapter 5 Input and output
%wf
%wf is used for the output of floating point values in decimal form.
%wg
%wg is used for floating point values and has essentially the same effect as %wf
unless the supplied value cannot adequately be represented in %wf form; in which
case %wg has the same effect as %we. To be specific, the %we form is only used if
the exponent is less than -4 or greater than or equal the precision value. Note,
however, that with %wg, trailing zeros after a decimal point are removed. Where
appropriate, the decimal point is also removed.
format value output comment
%wg 0.0126 0.0126
%10wg 1.26e-4 ∇∇0.000126 exponent is -4
%.3wg 126.7 126.7 exponent is less than the
precision
%9.2wg 1.267e-5 ∇1.27e-05 exponent is less than -4
%7.2wg 100.0 ∇∇1e+02 exponent is equal to the
precision
47
ClearWin+ User’s Guide Fortran
%ws
%ws is used for the output of character strings.
%wx
%wx is similar to %wd but is used to output hexadecimal values. A grave accent (`)
modifier is used to specify an upper case letter hexadecimal output.
48
Chapter 5 Input and output
]d\,
SXaTRc^ah,³ ³
X,fX]X^/³bbJUX[TbTRcX^]L´bPeTNR^]ca^[
X,fX]X^/³DbTab) aS][´]d\
X,fX]X^/³?PcW) ab´SXaTRc^ah
If the user enters ‘12’ and ‘c:\temp’ into the two edit boxes, this creates a file called
file.ini in the Windows directory containing:
JbTRcX^]L
DbTab, !
?PcW,R)KcT\_
49
ClearWin+ User’s Guide Fortran
50
6.
Button controls
A grave accent (`) is used to indicate that the button is the default when the Enter key
is pressed. A default button has a slightly different appearance.
The caret character (^) may be used to define a call-back function that is called when
the user clicks on the button (or, if the button is the default button, when the user
presses the Enter key).
For example:
8=C464A XfX]X^/
4GC4A=0; Ud]R
X,fX]X^/?aTbb cWXb c^ bTT fWPc WP__T]b ³
51
ClearWin+ User’s Guide Fortran
X,fX]X^/³MQcJ?A4BBLUd]R
4=3
R5d]RcX^] c^ S^ b^\TcWX]V
8=C464A Ud]RcX^] Ud]R
Ud]R,
4=3
The buttons in a format window (both %bt and %tt) are numbered from 1 in the order
in which they are defined in the format string. When the user clicks on a button that
does not have a call-back function, the format window closes and the corresponding
fX]X^/ call returns the number of the button pressed. For example:
?A8=C fX]X^/QcJ>:LcPQcJ2P]RT[L
outputs the value 1 if ‘OK’ is pressed, 2 if ‘Cancel’ is pressed and zero if the window
is closed without clicking on a button.
Alternatively, if a button has a call-back function that returns a negative value, then
clicking on the button causes the format window to close and the corresponding
fX]X^/ call returns this value made positive. For example:
8=C464A fX]X^/XUd]R
4GC4A=0; Ud]R
X,fX]X^/MQcJ>:LcPQcJ2P]RT[LUd]R
?A8=C X
4=3
8=C464A 5D=2C8>= Ud]R
Ud]R,
4=3
displays the value +1 if ‘OK’ is pressed, 2 if ‘Cancel’ is pressed and zero if the
window is closed without clicking on a button.
Normally a button created with %bt is permanently enabled. However, if the tilde (~)
format modifier is used then an extra 8=C464A argument must be supplied (before any
call-back function). This argument provides an integer that controls the state of the
button. When this integer is zero the button is greyed and cannot be used. When this
integer is 1 the button is enabled. Typically this control integer would be altered by
code responding to another control. For example, after a successful file-opening, a
52
Chapter 6 Button controls
number of options might be enabled. Note that there is no reason why the same
control integer should not control several buttons and/or menu items.
For example:
F8=0??
8=2;D34 +fX]S^fbX]b-
8=C464A VaThNR]ca[
4GC4A=0; ^_T]NUbPeTNUbPeTNPbNU
2><<>= VaThNR]ca[
R>][h cWT >?4= Qdcc^] Xb X]XcXP[[h PePX[PQ[T
VaThNR]ca[,
X,fX]X^/ MQcJ>_T]L ³^_T]NU
X,fX]X^/³mMQcJBPeTL ´VaThNR]ca[bPeTNU
X,fX]X^/³mMQcJBPeT PbLVaThNR]ca[bPeTNPbNU
4=3
R
8=C464A Ud]RcX^] ^_T]NU
8=C464A VaThNR]ca[
2><<>= VaThNR]ca[
VaThNR]ca[,
^_T]NU,!
4=3
The width of the button, in average characters, can be supplied using the parameter n
(e.g. QcJBPeTL) rather than this being determined by the width of its text. A
button is created wide enough for at least n characters (possibly more, if the font is not
mono-spaced). This enables a number of buttons of the same size to be created. %fn
and %ts can be used before %bt in order to modify the button text. %bi is used to add
an icon the a button whilst %bc is used to change its background colour.
The text on a button will be placed on more than one line if a line feed character
(270A ) is spliced into the text at the appropriate point.
For example:
Qdcc^]N]P\T,?aTbb270A WTaT
X,fX]X^/Qc/Qdcc^]N]P\T
53
ClearWin+ User’s Guide Fortran
54
Chapter 6 Button controls
For example:
F8=0??
8=C464A XfX]X^/
X,fX]X^/ffJ]^NQ^aSTaLRPJCTgcdP[ c^^[QPaL
X,fX]X^/\]J4gXcL4G8C
X,fX]X^/ccJ2^\_X[TLccJ;X]ZLccJAd]L
X,fX]X^/Qg3
X,fX]X^/QVJVaThL
X,fX]X^/_eUa#
4=3
55
ClearWin+ User’s Guide Fortran
X,fX]X^/cPOaQJ<TSXd\L][R!
X,fX]X^/cPOaQJ;^fLR"
4=3
The caret character (^) is used in association with a call-back function and this will be
called whenever the item is selected.
56
Chapter 6 Button controls
Where necessary the program should supply the appropriate bitmaps for the resolution
in use. Bitmaps can be created using the standard Microsoft “Paint” accessory.
Here is a simple example of the use of bitmap buttons:
F8=0?? S!aR
8=2;D34 +fX]S^fbX]b-
8=C464A P]bfTa
X,fX]X^/7T[[^cPcQ1CN>551CN>=1CN3>F=P]bfTa
4=3
The file d20.rc contains:
1CN>55 18C<0? 1C 1<?
1CN>= 18C<0? 1C!1<?
1CN3>F= 18C<0? 1C"1<?
Using the optional parameters n and m it is possible to create a whole toolbar as a
rectangular array of buttons n items across by m deep. For example, a 1-deep
horizontal bar of 10 items would be represented by %10.1tb (or just %10tb) together
with 30 bitmap resources as the corresponding arguments.
If call-back functions are used, these follow each set of bitmaps thus: ³^UU ´,
³^] ´, ³S^f] ´, Ud]R , ³^UU!´, ³^]!´, ³S^f]!´, Ud]R!,... etc. If the “?”
modifier is used, then n × m help strings must be provided. It is particularly valuable
to provide such help in the case of toolbar buttons, since their meaning is not always
obvious. The following example creates a 3-element horizontal toolbar with help
information and call-back functions. The second button is initially set to the on state.
F8=0?? S! aR
8=2;D34 +fX]S^fbX]b-
8=C464A Q Q!Q"
4GC4A=0; Ud]R Ud]R!Ud]R"
30C0 Q Q!Q"
X,fX]X^/" .McQJ0__[TbLJ>aP]VTbLJ?TPabL
>55 >= 3F= Q Ud]R
! >55!>=!3F=!Q!Ud]R!
" >55">="3F="Q"Ud]R"
4=3
R
8=C464A Ud]RcX^] Ud]R
Ud]R ,
4=3
The file d21.rc contains:
57
ClearWin+ User’s Guide Fortran
A4B>DA24B
Rdc 18C<0? RdcQ\_
R^_h 18C<0? R^_hQ\_
_PbcT 18C<0? _PbcTQ\_
The argument list for %ib consists of the following triplet repeated for each button in
turn: bitmap_name, stat_ctrl, cb_func.
58
Chapter 6 Button controls
The first part of the string bitmap_name gives the name of a bitmap resource. If you
want a string to be added to the bitmap then this must come next after an oblique (‘/’).
This string can include linefeed characters (char(10)).
The integer stat_ctrl is used to control the state of the button. The constant value 4 is
used to describe a button that does not toggle, i.e. it is in the down state only whilst
the mouse button is held down. For a button that toggles, use a variable that will take
the value 1 when it is in the up date and the value 2 when in the down state. The state
value 3 describes a button that is greyed and disabled. Every button has a call-back
function cb_func.
The option U[Pc gives a toolbar that is initially flat and grey. When the mouse cursor
is above a button, the image becomes coloured and the button is raised or depressed
depending on its state. When this option is not used the old style of button is
obtained.
%ib is designed for bitmaps that have a grey background. If the image has a one-pixel
border then the border colour is used as the background colour, otherwise the
background is assumed to be light grey (192,192,192). In the above example, the
image bitmaps are 48x24 pixels. This results in buttons of equal width when the
strings are added. See page 247 for further details.
59
ClearWin+ User’s Guide Fortran
The ganging format code may be placed before or after the formats in which the
control variables are actually used. A given variable may be used in more than one
control. However, it is unusual for a variable to appear in more than one gang format
for a given window. If it does then there must only be one variable that is common
and the effect is to merge the two gang sets. If the grave accent is used on one of the
gangs then it must be used on both.
60
7.
The bar is updated by using the fX]S^fNd_SPcT/ function. This should be called at
suitable intervals to provide a smooth progression. This is illustrated in the following
example:
F8=0??
8=2;D34 +fX]S^fbX]b-
8=C464A Rca[
3>D1;4 ?A428B8>= S
S,
X,fX]X^/RPJ1Pa U^a\PcL´
X,fX]X^/³?a^RTbbX]V !][´
X,fX]X^/³!Qa´SA61/!$$!$$
61
ClearWin+ User’s Guide Fortran
X,fX]X^/³[fRca[
3> F78;4S;C
3> X,
4=3 3>
S,S
R CWT SPcP WPb RWP]VTS b^ _a^\_c fX]S^fb c^
R d_SPcT cWT QPa SXb_[Ph
20;; fX]S^fNd_SPcT/S
4=3 3>
4=3
The above program will produce a horizontal bar which will extend to the right as the
task proceeds.
62
Chapter 7 Controls other than buttons
For example:
8=C464A Z
270A02C4A VaTTZ#$
30C0 VaTTZXX, #P[_WPQTcPVP\\P´ST[cP´
Z,
X,fX]X^/BT[TRc P 6aTTZ [TccTa) &"[bVaTTZ#;Z
4=3
The characters “7.3” before “ls” specify the width of the list box (as the number of
characters) and the depth of the list box (as the number of lines). Pre-setting k to 1
would cause “alpha” to be already highlighted when the window is displayed. If the
user selects “beta”, then k set to 2. If k were pre-set to zero, none of the items would
be initially selected. If the user were to exit without making a selection, k would keep
its pre-set value.
The grave accent (`) may be used with %ls to produce a drop-down combo box rather
than a list box (for an editable combo box see %el on page 236). The caret (^)
character is used in association with a call-back function. This function will be called
whenever an item is selected.
For example:
4GC4A=0; [bNUd]RcX^]
X,fX]X^/M[bPaaPh%;][bNUd]RcX^]
(See also the ;8BC1>GN8C4<NB4;42C43 parameter in R[TPafX]NX]U^/ page 337).
For a list box (i.e. when a grave accent modifier is not used), the option WbRa^[[QPa
provides a horizontal scroll bar whilst the option \d[cXR^[d\] provides a multiple
column display. For example:
270A02C4A' UadXc&
30C0 UadXc0__[Tb1P]P]Pb2WTaaXTb6aP_Tb
>aP]VTb?TPab?[d\b
X,fX]X^/!##;BJ\d[cXR^[d\]LUadXc&Z
63
ClearWin+ User’s Guide Fortran
64
Chapter 7 Controls other than buttons
X,fX]X^/[bcPcWX]Vb&Z
X,fX]X^/O[bcPcWX]Vb&Z
X,fX]X^/ "[bcPcWX]Vb&Z
X,fX]X^/\bcWX]Vb&XeTR
X,fX]X^/UU][=^cT cWPc cWT UXabc cWaTT Q^gTb PaT
X,fX]X^/´R^d_[TS c^VTcWTa][
X,fX]X^/QTRPdbT cWTh bWPaT cWT aTbd[c ePaXPQ[T Z
4=3
List-view - %lv[options]
A list view control is a window that displays a collection of items, each item
consisting of an optional icon and a label. List view controls provide several ways of
arranging items and displaying individual items. One of the arguments for %lv is an
integer variable in the range 0..3 that represents the type of view: 0=Icon view;
1=Report view; 2=Small icon view; 3=List view. In the report view, additional
information about each item can be displayed in columns to the right of the icon and
label. The Microsoft Explorer uses a list view in order to display directory
information. Here is a Fortran 90 example that illustrates the concept. For further
details see page 252.
8=C464A =
?0A0<4C4A =,!
270A02C4A"% X]U^= 2^[^daXR^]b%
8=C464A aVQ=bT[=eXTfWf]SfX]X^/A61/
2><<>= X]U^aVQWf]S
4GC4A=0; RP[[NQPRZ
65
ClearWin+ User’s Guide Fortran
8=C464A RP[[NQPRZX
bT[,*aVQ,
aVQ ,A61/!$$
aVQ!,A61/!$$
aVQ",A61/!$$
aVQ#,A61/!$$!$$
aVQ$,A61/!$$!$$
aVQ%,A61/!$$!$$
X]U^ ,k2^[^daN(kATSk6aTT]k1[dT
X]U^!,2^[^dak0ATSk aVQ
X]U^",2^[^dak16aTT]k aVQ!
X]U^#,2^[^dak21[dTk aVQ"
X]U^$,2^[^dak32hP]k aVQ#
X]U^%,2^[^dak4<PVT]cPk aVQ$
X]U^&,2^[^dak5HT[[^fk aVQ%
eXTf,
XR^]b,aTSVaTT]Q[dTRhP]\PVT]cPhT[[^fQ[P]Z
X,fX]X^/ffbhJ"SLRPJ;XbceXTf bP\_[TL
X,fX]X^/\]JEXTfbJ8R^]LL B4CeXTf
X,fX]X^/\]JJAT_^acLL B4CeXTf
X,fX]X^/\]JJB\P[[ XR^]LLB4CeXTf!
X,fX]X^/\]JJ;XbcLL B4CeXTf"
X,fX]X^/_eOM[eJTSXcN[PQT[bbX]V[TNbT[TRcX^]L
!# !X]U^=bT[eXTfXR^]bRP[[NQPRZ
X,fX]X^/UUR] Oab[RBT[TRcTS R^[^daWf]S
4=3
66
Chapter 7 Controls other than buttons
A4B>DA24B
aTS 82>= aTSXR^
VaTT] 82>= VaTT]XR^
Q[dT 82>= Q[dTXR^
RhP] 82>= RhP]XR^
\PVT]cP 82>= \PVT]cPXR^
hT[[^f 82>= hT[[^fXR^
Q[P]Z 82>= Q[P]ZXR^
The fX]X^/ statement that generates the list-view is:
X,fX]X^/OM[eJTSXcN[PQT[bbX]V[TNbT[TRcX^]L
!# !X]U^=bT[eXTfXR^]bRP[[NQPRZ
Here is an outline of the meaning of the symbols and variables used in this statement:
grave accent a list of icons (called icons) is supplied
caret a call-back function (called call_back) is supplied
edit_lables an option that enables the names of the colours to be edited by
the user
single_selection an option that ensures that at most one colour can be selected at
a time
240 the initial width of the list-view in pixels
67
ClearWin+ User’s Guide Fortran
68
Chapter 7 Controls other than buttons
displaying any children) and ‘E’ if the item is to be displayed expanded. Consider the
following list of things:
AEFood
BEFruit
CCApples
CCPears
BCNuts
CCHazel nuts
CCBrazil nuts
AEDrink
BCAlcoholic
BCNon-alcoholic
The children of a node (together with any of their children, etc.) are placed
immediately beneath the parent node. In the example shown the types of nuts would
not immediately be shown because of the ‘C’ in ‘BCNuts’. Any node is expanded and
contracted by simply by clicking on it. Usually you would code ‘C’ for the second
character of each string. This would produce an initial display showing only the top
level. As nodes are expanded and contracted, the information is stored in the strings.
This means that, if the strings are used to display the hierarchy a second time, the
display will start from where it left off. You could even store the strings in a file so
that the expanded state would be the same from one run to another.
Items with a lower case letter or a blank in the first position are ignored and never
displayed. This provides a means to hide elements, or to provide space for the display
to grow dynamically. If a node has no children you can use ‘E’ or ‘C’ - there is no
difference.
Notice that it makes no sense for a level 2 item (say) to be followed immediately by a
level 4 item. An item may not be followed immediately by its ‘grandchildren’. This
condition will be detected as an error. Conversely, a level may decrease by any
amount.
%tv can take a call-back function. The call-back function may use the index of the
chosen item (i.e. the argument sel) and can also get the value of
R[TPafX]NX]U^/´CA44E84FN8C4<NB4;42C43´. This value will be equal to 1
if the call-back is responding to a double click mouse event.
By default, the tree-view displays bullet marks to the left of the nodes. By using a
grave accent with %tv, the bullet marks are replaced by icons. When the grave accent
is used, the third character in each string is interpreted as an index (‘A’ - ‘Z’) into a
list of icons. This icon list is supplied as an extra argument that consists of icon
resources separated by commas (e.g. 82>= 82>=!82>="). You should
construct the icons in such a way that the image is confined to the top left 16 x 16
corner. The remainder of the icon should be filled with the transparent colour. The
Salford icon editor SCION can be used for this purpose.
69
ClearWin+ User’s Guide Fortran
By providing a call-back that examines the expansion indicator (character two of each
string) it is possible to change the icon index to reflect whether or not the icon is
expanded. If you perform a change of this sort you should pass the main array to
fX]S^fNd_SPcT/ to force the control to be updated.
The following example illustrates the use of tree-view controls:
F8=0??
1;>2: 30C0
270A02C4A" R^]cT]cb$%
8=C464A XcT\
2><<>=2R^]cT]cb
2><<>=8XcT\
30C0 R^]cT]cb
0201^^Z 1202WP_cTa 220BTRcX^]
220BTRcX^] ! 220BTRcX^] " 220BTRcX^] #
220BTRcX^] " 220BTRcX^] #
4=3
R
8=C464A 5D=2C8>= cTbc
R
R 2P[[QPRZ Ud]RcX^] bTcb cWT XR^] U^a
R TPRW ^QYTRc PRR^aSX]V c^ fWTcWTa Xc Xb Tg_P]STS ^a ]^c
R
270A02C4A" R^]cT]cb$%
8=C464A XcT\
2><<>=2R^]cT]cb
2><<>=8XcT\
270A02C4A" bcaX]V
bcaX]V,R^]cT]cbXcT\
85bcaX]V!)!4@4C74=
bcaX]V")",1
4;B4
bcaX]V")",0
4=385
20;; fX]S^fNd_SPcT/R^]cT]cb
cTbc,!
4=3
R <PX] _a^VaP\ Ydbc RP[[ F8=8>/
4GC4A=0; cTbc
70
Chapter 7 Controls other than buttons
270A02C4A" R^]cT]cb$%
8=C464A XcT\fX]X^/P
2><<>=2R^]cT]cb
2><<>=8XcT\
P,fX]X^/ff^Q_e´
P,fX]X^/³MO! $ce´
R^]cT]cb$%XcT\2;>B43N1>>:>?4=N1>>:cTbc
P,fX]X^/³RQUU][R]OQcJ>:L
4=3
Link this with a resource file containing the following:
2;>B43N1>>: 82>= 1>>: 82>
>?4=N1>>: 82>= 1>>:!82>
Branch-view - %bv[options]
The %bv format is used to construct a hierarchical tree-view that is similar to %tv.
%bv gives a control with a slightly different appearance. %bv has more options and is
71
ClearWin+ User’s Guide Fortran
simpler to use because a call-back function is nolonger needed in order to change the
image when expanding a node. Here is some sample code like that for %tv:
F8=0??
270A02C4A" R^]cT]cb$%U\c !
8=C464A XcT\XfX]X^/
30C0 R^]cT]cb
0411^^Z 1202WP_cTa 220BTRcX^]
XcT\,
U\c,OQeJWPbNQdcc^]bWPbN[X]TbbW^fNbT[TRcX^]NP[fPhb
TSXcN[PQT[b[X]TbNPcNa^^c_PXaTSNQXc\P_bL
X,fX]X^/ffbhJ"SL_e
X,fX]X^/RPJ1aP]RWeXTfL
X,fX]X^/U\c! %R^]cT]cb$%XcT\2;>B43>?4=
4=3
A4B>DA24B
2;>B43 18C<0? R[^bTQQ\_
>?4= 18C<0? ^_T]QQ\_
%bv uses 16x16 bitmaps. The character array called contents is constructed in the
same way as for %tv. The option _PXaTSNQXc\P_b indicates that the list of bitmaps
³2;>B43 >?4=´ is ordered such that the bitmap for an expanded node (OPEN)
follows immediately after that for the corresponding collapsed node (CLOSE). For
further details see page 222.
72
Chapter 7 Controls other than buttons
73
ClearWin+ User’s Guide Fortran
74
8.
Bitmap - %bm[bitmap_name]
This is similar to the icon format %ic (see page 77) but the picture is supplied as a
simple bitmap. For example we could write:
X,fX]X^/CWXb Xb P QXc\P_) Q\JcTPNQXc\P_L
and the resource script would include a line of the form:
cTPNQXc\P_ 18C<0? 1C 1<?
The grave accent is used to specify that the bitmap is supplied via a handle rather than
a name. A suitable handle is returned by \PZTNQXc\P_/ or by the Windows API
function LoadBitmap. If you want to use LoadBitmap to access one of the pre-
defined bitmaps then you will need to create your own binding to LoadBitmap. For
example:
8=C464A WNQXc\P_>1<N3=0AA>F
?0A0<4C4A >1<N3=0AA>F,I&55;
BC320;; <h;^PS1Xc\P_ ;^PS1Xc\P_0 E0;E0;)8=C464A
WNQXc\P_,<h;^PS1Xc\P_=D;;>1<N3=0AA>F
X,fX]X^/OQ\WNQXc\P_
A call-back function can be added to a bitmap by using the caret (^) format modifier.
The %gi format is also available and works in the same way as %bm except that it
uses a GIF resource created from an image file stored in GIF format. GIF files are
compressed and may be animated and/or partially transparent. They therefore make
ideal eye-catching features. See page 243 for further details.
75
ClearWin+ User’s Guide Fortran
Cursor - %cu[cursor_name]
By default the mouse cursor is represented by an arrow except in graphics regions
(such as %gr) where by default it is represented by a cross. Two formats are supplied
to change the mouse cursor representation. %dc sets the default cursor for the window
as a whole, and %cu sets the cursor for the next control in the window. Each is
followed by a standard character string (i.e. a string in square brackets or an @
character indicating that the required string is supplied as an argument). The string
should be the name of a 2DAB>A resource. By using a grave accent (`), you can use
constants representing the standard Windows cursors. These constants are defined in
windows.ins.
For example:
P,fX]X^/OSR´2DAB>AN8140<
P,fX]X^/³^QORd´2DAB>ANF08C
P,fX]X^/³Va´
P,fX]X^/³RQUU][R]OQcJ>:L
For further information see %dc below.
%cu and %dc also have a more complex form in which several alternative cursors are
supplied, together with an integer used to select the one to use. The integer should be
in the range from 1 to the number of different cursors supplied.
For example:
8=C464A Z
Z,
X,fX]X^/"SRJ2DAB>AN LJ2DAB>AN!LJ2DAB>AN"LZ
Whenever the cursor is in the main window, its shape will be governed by the current
value of Z. The %cu format is used in a similar way.
76
Chapter 8 Bitmaps, Cursors, Icons
For example:
X,fX]X^/OSR2DAB>AN8140<
whilst for a user defined cursor:
X,fX]X^/SRJ\hNRdab^aL
combined with a resource script that contains the line:
\hNRdab^a 2DAB>A Rdab^aRda
The file cursor.cur is created using an image editor.
See the description of %cu (page 76) for a further example of how %dc is used and
how several different cursors can be used for different parts of the format window.
Icon - %ic[icon_name]
This format supplies the name of an icon resource (as a standard character string). It
is drawn at the current position in the format window.
For example:
F8=0?? S!'aR
8=2;D34 +fX]S^fbX]b-
X,fX]X^/CWXb Xb P] XR^]) XRJfX]NXR^]L
4=3
77
ClearWin+ User’s Guide Fortran
The caret (^) character is used to attach a call-back function to an icon. The function
is called each time the user clicks on the icon.
Icons differ in one respect from bitmaps in that they may have transparent regions that
make the image appear to sit on the background in the same way that text does.
If a grave accent (`) is used, the icon is supplied via an icon handle. A suitable handle
is returned by \PZTNXR^]/ (see page 377) or by the Windows API function
LoadIcon. If you want to use LoadIcon to access one of the pre-defined icons then
you will need to create your own binding to LoadIcon. For example:
BC320;; <h;^PS8R^] ;^PS8R^]0 eP[eP[)8=C464A
8=C464A WNXR^]
WNXR^],<h;^PS8R^]=D;;838N@D4BC8>=
X,fX]X^/OXRWNXR^]
78
Chapter 8 Bitmaps, Cursors, Icons
The symbol is vertically centred to the left of n lines of text (the parameter n defaults
to 1), and a half icon width is left blank to the right so as to leave an appropriate gap
between the icon and subsequent text. Sound is added by attaching the “144?” call-
back (see page 206). Alternatively, you can call the API function MessageBeep
before creating the format window.
The caret character (^) is used with %si in order to attach a call-back function. This
function is called each time the user clicks on the icon. In the above example the ‘!’
icon uses the call-back function cb_icon.
79
ClearWin+ User’s Guide Fortran
80
9.
This format specifies five selectable items, three of which, 1TcP , 1TcP!, and 1TcP"
are contained in a drop-down menu. A bar symbol ( | ) between 1TcP! and 1TcP"
causes a separator to be drawn in the drop-down menu. The three top-level menu
items (0[_WP, 1TcP and 6P\\P) can be selected using accelerator keys Alt-A, Alt-B
and Alt-G that are specified by the inclusion of the ampersand character (&) placed to
the left of the character chosen to be the (unique) accelerator for this menu (a double
ampersand (&&) is required if you want an ampersand to appear in the text). Five
call-back functions are required as arguments corresponding to each selectable menu
item. A call-back function is called when the corresponding menu item is selected.
Individual menu items may also be greyed (so that they are visible, but not usable). In
order to grey an item, prefix its name with a tilde (~) and insert an 8=C464A
argument to provide a control integer. When the value of this integer is zero, the item
is greyed and disabled, otherwise it is enabled. Note that it is not necessary to use a
different control integer for every item. You can use one integer to control several
81
ClearWin+ User’s Guide Fortran
menu items and/or buttons. The following example illustrates a 3-item menu, in
which the middle item is greyed:
F8=0??
8=2;D34 +fX]S^fbX]b-
8=C464A SaX]ZTa
4GC4A=0; b`dPbWNUd]RQTTaNUd]RcTPNUd]R
SaX]ZTa,
X,fX]X^/\]JB`dPbWL´b`dPbWNUd]R
X,fX]X^/³\]Jm1TTaL´SaX]ZTaQTTaNUd]R
X,fX]X^/³\]JCTPLcTPNUd]R
4=3
R RP[[ QPRZ Ud]RcX^]
8=C464A 5D=2C8>= b`dPbWNUd]R
b`dPbWNUd]R,
4=3
The hash character (#) is used to control the placement of a check mark (tick) at the
front of a menu item. The corresponding control variable is set to the value 1 in order
to display a check mark otherwise it is set to zero. Top level menu items cannot be
checked.
As an alternative to using the ampersand (&) before a character, an accelerator key
may also be associated with a menu item and its corresponding call-back function as
illustrated in the following example.
X,fX]X^/\]J5X[TJ>_T]2ca[5 !LL^_T]NUd]R
The paragraph mark ¶ (270A!) is used here as an alias for the tab character
(270A() and is followed by the key name. Valid key names are illustrated with the
accelerator key format %ac below. The use of an accelerator key is is only permitted in
sub-menus and should not be used in top level menus.
In order to continue a menu in a new fX]X^/ statement, it is necessary to match
opening square brackets with closing brackets on the line to be continued. Then use
an appropriate number of opening square brackets on the next line. For example:
X,fX]X^/³\]JCTbc5X[TJ>_T]LL´U U!
X,fX]X^/³\]JJBPeTL7T[_L´U"U#
is equivalent to
82
Chapter 9 Menus and accelerator keys
X,fX]X^/³\]JCTbc5X[TJ>_T]BPeTL7T[_L´U U!U"U#
Help strings are provided by inserting a question mark (%?mn). All the strings are
placed in order at the end of the format description, one for each item that has a call-
back function. For example,
X,fX]X^/.\]J5X[TJ=TfLLJBcPac P ]Tf UX[TL´]TfU]
X,fX]X^/³.\]JJBPeTLLJBPeT cWXb UX[TLbPeTU]
Separators also require a help string but this is not used.
Dynamic Menus
If you wish to add or remove menu items whilst the program is running then this is
possible with the aid of a handle:
X,fX]X^/³\]JFX]S^fJLL ´ WP]S[T
The asterisk (*) causes %mn to provide a handle that is passed
to either PSSN\T]dNXcT\/ (see page 333) or
aT\^eTN\T]dNXcT\/ (see page 394). Note that items are
added to the end of the pop-down menu that contains the
handle. You may have a number of handles for various pop-
down menus.
Only one handle is required to create a menu with multiple
entries. To detect which menu entry has been selected use
R[TPafX]NbcaX]V/³2DAA4=CN<4=DN8C4<´ to obtain
the text of the menu item selected.
Here is some sample code that illustrates how to add a list of files to a file menu.
F8=0??
8=2;D34 +fX]S^fbX]b-
8=C464A XWP]S[TRca[RQRQ
270A02C4A !( U]P\T
4GC4A=0; RQRQ
2><<>= Rca[
X,fX]X^/\]J5X[TJ=TfLLRQ
X,fX]X^/\]JJ>_T]LL RQ
X,fX]X^/\]JJBPeTkLL RQ
X,fX]X^/\]JJLLWP]S[T
X,fX]X^/[fRca[
3> X, "
FA8C4U]P\TP8 5X[TX
20;; PSSN\T]dNXcT\/WP]S[TU]P\T RQ
4=33>
20;; PSSN\T]dNXcT\/WP]S[T270ARQ
83
ClearWin+ User’s Guide Fortran
84
Chapter 9 Menus and accelerator keys
R\^ST,
e ,3
e!, 3
X,fX]X^/ffJ]^NQ^aSTa]^N\PgQ^gLRPJ?^_d_L
X,fX]X^/!!^QJcWX]N_P]T[[TSL
X,fX]X^/M b[RQe \X]\PgRP[R
X,fX]X^/ Sh"3
X,fX]X^/SUM#aURQbcT_e RP[R
X,fX]X^/M b[RQe!\X]\PgRP[R
X,fX]X^/ Sh"3
X,fX]X^/SUM#aURQbcT_e!RP[R
X,fX]X^/UU^QJbcPcdbcWX]N_P]T[[TSL
X,fX]X^/cPShO&aURQ"3a
X,fX]X^/_\J<d[cX_[hL R bTc\^ST
X,fX]X^/_\Jm3XeXSTkLT]PQ[TR!bTc\^ST
X,fX]X^/_\J0SSL R"bTc\^ST
X,fX]X^/_\JBdQcaPRcL R#bTc\^ST
4=3
R
8=C464A 5D=2C8>= bTc\^ST
8=2;D34 _\X]b
270A02C4A XcT\
4GC4A=0; RP[R
8=C464A XRP[R
R\^ST,
XcT\,R[TPafX]NbcaX]V/2DAA4=CN<4=DN8C4<
85XcT\4@<d[cX_[h \^ST,
85XcT\4@3XeXST \^ST,!
85XcT\4@0SS \^ST,"
85XcT\4@BdQcaPRc \^ST,#
R\^ST,
X,RP[R
bTc\^ST,!
4=3
R
8=C464A 5D=2C8>= RP[R
8=2;D34 _\X]b
T]PQ[T,
85e!;C 3%C74=
T]PQ[T,
85\^ST4@! \^ST,$
4=385
85\^ST4@ a,e e!
85\^ST4@! a,e e!
85
ClearWin+ User’s Guide Fortran
Enhanced menus
A ClearWin+ window can have an enhanced standard menu (%`mn) as an alternative
to a standard (%mn) menu. Enhanced popup menus (%`pm) are also available. An
enhanced menu has more possibilities such as bitmap entries and is more flexible for
86
Chapter 9 Menus and accelerator keys
programs that update menus on the fly or read them from configuration files. Any
window can be given either a normal menu or an enhanced menu.
%`mn and %`pm each take one character argument, that describes the entire menu,
and one call-back function that is used for all menu events.
Example
8=C464A XfX]X^/RQUd]R
4GC4A=0; RQUd]R
270A02C4A!$% U\c
U\c,J5X[TJQ\J^_T]Q\_LbT4gXcL7T[_J0Q^dcLL
X,fX]X^/O\]U\cRQUd]R
4=3
8=C464A 5D=2C8>= RQUd]R
8=2;D34 +fX]S^fbX]b-
270A02C4A % \T]dXcT\
\T]dXcT\,R[TPafX]NbcaX]V/2DAA4=CN<4=DN8C4<
RQUd]R,
85\T]dXcT\4@5X[Tm4gXc RQUd]R,
4=3
A4B>DA24B
^_T]Q\_ 18C<0? ^_T]Q\_
87
ClearWin+ User’s Guide Fortran
-he[...] Subsequent item has help information given between square brackets.
This information can include newline characters.
-rc Subsequent item has a radio button placed in front of it.
Notice that sub-menus are specified using nested square brackets - just as they are for
standard menus.
The call-back function is invoked when the user selects a menu event. This function
uses 2;40AF8=NBCA8=6/2DAA4=CN<4=DN8C4< to determine which event is
required. In the given example, when the user selects ‘Exit’ the string ‘File~Exit’ is
returned. Strings are separated by a tilde ‘~’ character and any ‘&’ characters in the
menu names are left in place. In the given example, selecting ‘Open’ generates
‘File~openbmp’. (Menu items often represent recently opened files. File names might
contain tilde ‘~’ characters, however no ambiguity will occur because such items will
always appear in terminal positions in the menu tree structure.)
Newline and carriage return characters are ignored between menu items. This means
that a menu structure can conveniently be defined in a text file, read in and presented
as an enhanced menu.
If a menu is to be altered (whether it be to alter the grey/check status of an item, or to
add/remove entries etc.) the menu is simply replaced using one of the calls:
20;; A4?;024N4=70=243N<4=D/70=3;4 <4=D
20;; A4?;024N4=70=243N?>?D?N<4=D/70=3;4 <4=D
where 70=3;4 is an integer that is the (%hw) window handle of the parent window
and <4=D is the replacement character argument. 70=3;4 can be zero, in which case
the most recently created window is updated. It is an error to call these routines for a
window that does not use %`mn or %`pm.
88
10.
Format windows, created using fX]X^/, contain text and child windows called
controls. Text and controls are presented in the order in which they appear in the
format string. ClearWin+ automatically positions the text and controls in a window
and adjusts the size of the window to suit its contents. This automatic positioning
provides for a standard blank border within the window. This border surrounds all the
text and controls. It can be removed by using %ww together with its ]^NQ^aSTa
option.
Text and controls in a format string can be separated by one or more of the following
format codes.
%nl gives a new line
%ta advances to the next tab position
%ff advances to the left margin below any existing controls
%cn centres text and controls on the current line
%rj right justifies text and controls on the current line
%ta and %nl can be used with an integer modifier. For example, %2nl gives two new
lines. Further information about %cn and %rj is given below.
It is important to note that, if these codes appear within a %ob box, then the effect
relates to the box rather than the window as a whole. Moreover, %ob boxes can be
nested. As a result it is possible to exercise a fine control over the positioning of items
within a window. In extreme cases, there are other mechanisms for adjusting the
position of a given item. Details are given below.
Centre - %cn
%cn forces the text and controls that follow (up to the next %nl or %ff) to be centred
in the window (or box). It is often used in conjunction with buttons.
89
ClearWin+ User’s Guide Fortran
For example:
F8=0??
8=C464A XfX]X^/
X,fX]X^/RPJ2[TPaFX]LQVJVaThL
X,fX]X^/R]bXBPeT RdaaT]c RWP]VTb.!][
X,fX]X^/ccJHTbL ccJ=^L ccJ2P]RT[L
4=3
The %cn format code can take a grave accent format modifier. This causes centring
to apply to the remainder of the format window or box. Thus a whole window or a
box full of centred items may be created very easily.
For example:
X,fX]X^/OR]?a^VaP\ c^ cTbc _aX\T ]d\QTab
X,fX]X^/!][FaXccT] Qh 9^T 1[^VVb!][OQcJ>:L´
If %cn is used within a box then it centres objects within that box.
Tab location - %N tl
This format code allows you to change the default tab locations. Distances are
measured from the left-hand edge of the window or box using multiples of the width
of an average character. N is the number of tabs to set and an argument is supplied
for each location. For example, %4tl would take four integer arguments specifying
the first four tab locations. A complex window layout might contain several %tl
formats. Each %tl format takes effect for subsequent text and controls and cancels any
previous one. If you use the grave accent modifier with %tl, then the tab locations are
specified as 3>D1;4 ?A428B8>= values.
90
Chapter 10 Layout and positioning
]P\TSNR Places a given title in the top line of the box (in the centre)
]P\TSN[ Places a given title in the top line of the box (on the left).
]P\TSNa Places a given title in the top line of the box (on the right)
]^NQ^aSTa Creates an invisible box which is useful for grouping controls.
_P]T[[TS Creates a three-dimensional panel.
bWPSTS Equivalent to %`ob.
bcPcdb The box takes the form of a status bar.
cWX]N_P]T[[TS An alternative to _P]T[[TS.
bR^aTS Double line, three-dimensional shade effect.
ST_aTbbTS Single line, three-dimensional shade effect.
aPXbTS Single line, three-dimensional shade effect
A status bar is a strip (with the same colour as the face of a standard button) that is
placed at the bottom of a window. A status bar is typically used to display help
information. The status bar format should be used at the beginning of the first
(normally the only) line of status information. For example, ^QJbcPcdbLWTRQ
would create a status bar and place help information in it. Although status bars can be
made to cover more than one line (for example by using %he in a window in which
some of the help strings extend over more than one line), the result tends to look ugly.
No further controls should be specified after the final %cb that closes a status bar,
unless they are positioned via a %ap format code (see page 95).
A name that is to be placed in the top line of the box is provided as a standard
character string. For example:
F8=0??
8=C464A XfX]X^/
X,fX]X^/RPJ=P\TS Q^gTbLQVJVaThL
X,fX]X^/^QJ]P\TSN[LJ;TUcL
91
ClearWin+ User’s Guide Fortran
%ob can take integer modifiers in order to create a grid. For example, %2.3ob would
create a grid two items across and three down. The contents of each grid component
are terminated with %cb. Thus the above case would require six %cb format codes
following it to close each component of the grid.
Note that, if you place %rd (say) in the grid, you might also choose to use
R^J]^NSPcPNQ^aSTaL in order to remove the border from the %rd control.
Most of the %ob options may be uesd when %ob is used to create a grid. However, a
grid box cannot be named.
For example:
F8=0??
270A02C4A & bca
3>D1;4 ?A428B8>= eP[\X]\Pg
8=C464A XfX]X^/
eP[,
\X],
\Pg,
bca,BP[U^aS B^UcfPaT
X,fX]X^/ffJ]^NUaP\TLRPJ\d[cX_[T aTVX^]bL
R3TUX]T P !g! Q^g
X,fX]X^/!!^QJ_P]T[[TSL &QcJ^]TL RQ
X,fX]X^/ &QcJcf^L RQ´
X,fX]X^/³ &QcJcWaTTL RQ
R3STUX]T P b[XSTa
X,fX]X^/ b[JW^aXi^]cP[L RQ][eP[\X]\Pg
X,fX]X^/! ^QJbcPcdbcWX]N_P]T[[TSL´
X,fX]X^/³O#aURQ´eP[
X,fX]X^/³OabRQbca
4=3
92
Chapter 10 Layout and positioning
%ob can be used with the option ]^NQ^aSTa to divide a window into a rectangular
array of sub regions that are used to position text and controls within each region. As
a simple example, suppose we wish to place two buttons (one below the other) to the
right of some text. Here is some code that has the desired effect.
X,fX]X^/! ^QJ]^NQ^aSTaLSh$3
X,fX]X^/Cf^ Qdcc^]b _[PRTS ][c^ cWT aXVWc ^U cTgcRQ
X,fX]X^/ccJ>:L][ShccJ2P]RT[LRQ"3
Notice that %dy has been used to provide vertical displacement. In this context, if the
single argument for %dy were given the value 1.0D0 then the use of %dy would be
equivalent to %nl.
Pivot - %pv
In the absence of a pivot (%pv) a window will not re-size (except to minimise). A
pivot may only be placed before a control that will re-size in response. It is an error to
attempt to pivot any other type of control. The following controls will accept the pivot
(more may be added later, but many controls are intrinsically fixed in size):
%bv Branch-view
%cw Embedded ClearWin windows
93
ClearWin+ User’s Guide Fortran
94
Chapter 10 Layout and positioning
2><<>= gh
R FX]S^f fX[[ QT _^bXcX^]TS aT[PcXeT c^ cWT Qdcc^]
R R^]ca^[ X] cWT \PX] fX]S^f
X,fX]X^/b_7XSST]g$h$
\hUd]R,
4=3
95
ClearWin+ User’s Guide Fortran
96
11.
Displaying text
Displaying text
97
ClearWin+ User’s Guide Fortran
For example:
X,fX]X^/DbTb QUQ^[S UPRTOQU U^a T\_WPbXb
%sf (system font) is used after any combination of these format codes in order to
restore the sytem font.
Subscript - %sd
A font must be selected using %fn, before %sd is used. All text following %sd will be
in subscript style. A grave accent (%`sd) is used to return to the previous font setting.
For example:
X,fX]X^/³U]JPaXP[L FPcTa Xb 7bS!ObS>´
Superscript - %su
A font must be selected using %fn, before %su is used. All text following %su will be
in superscript style. A grave accent (%`su) is used to return to the previous font
setting.
For example:
X,fX]X^/³U]JPaXP[L4X]bcTX] bPXS cb4,<2bd!Obd´ '3
98
Chapter 11 Displaying text
This is the result of the examples above for %su and %sd used together. In general,
scaled down fonts are undesirable as they may become unreadable in lower screen
resolutions.
99
ClearWin+ User’s Guide Fortran
Alternatively one of the standard colours (Q[PRZ fWXcT VaTh aTS VaTT]
Q[dT and hT[[^f) can be specified by enclosing the colour name in square
brackets (for example: cRJaTSL).
Note that the text colour for a given control can be changed dynamically (after the
window has been created) by calling the subroutine B4CN2>=CA>;NC4GCN2>;>DA/.
100
Chapter 11 Displaying text
{rho} ρ {mu} µ
{nu} ν {omega} ω
{chi} χ {tau} τ
{infinity} ∞ {plus_minus} ±
{ge} ≥ {proportional} ∝
{curly_d} ∂ {le} ≤
{ne} ≠ {identically_eq} ≡
{approximately_eq} ≈ {such_that}
{vector_sum} ⊕ {empty_set} ∅
{set_intersection} ∩ {set_union} ∪
{proper_subset} ⊂ {subset} ⊆
{belongs_to} ∈ {not_belongs_to} ∉
{for_all} ∀ {there_exists} ∃
{del} ∇ {sqrt} √
{semicolon} ;
The names of these special symbols are case sensitive, and the Greek characters also
exist as upper case characters. For example, {Pi} will produce Π. In this context only
the first character is upper case.
In addition, a number of more complex constructions are supplied. In the list below ,
the asterisk “*” stands for any equation string:
{sup *} Superscript or exponent
{sub *} Subscript
{divide *;*} Division written with a horizontal bar
{sum *} Summation without upper limit
{sum *;*} Summation with both limits
{integral } Indefinite integral
{integral *} Integral with lower limit only
(integral *;*} Full definite integral.
{symbol nnn} Character number nnn (decimal) from the symbol font.
101
ClearWin+ User’s Guide Fortran
Note that the body of the sum or integral will be placed after the closing curly brace.
Spaces are important in the above constructions.
Badly formed equations will normally cause a Clearwin+ error. However, if a grave
accent modifier is specified (%`eq), the error will be suppressed.
Excessive nesting of constructs such as ‘sup’ or ‘sub’, that reduce the font size, may
result in unreadable equations.
Here are a few well known equations and chemical formulae as examples:
F8=0??
8=C464A XffX]X^/
270A02C4A' b#
b ,7jbdQ !lB>jbdQ #l
b!,4,\Rjbd_ !l
b",jST[l1,
b#,
jbd\ ], *jX]UX]XchlljSXeXST *]jbd_ !ll,jSXeXST j_Xljbd_ !l*%l
X,fX]X^/RPJ4`dPcX^]bLQVJVaThL
3> X, #
f,fX]X^/^QT`/RQbX
4=33>
f,fX]X^/
4=3
Equations are constructed using symbols from the Times New Roman and Symbol
fonts.
These same equation strings may be used in hypertext (%ht) embedded between
<equation> and </equation>. The string between these delimiters is treated as a pure
equation - no mark-up codes are recognised. So, for example, the ‘<’ symbol should
be written as it is.
102
Chapter 11 Displaying text
Edit boxes
Edit box - %eb
See Chapter 12.
103
ClearWin+ User’s Guide Fortran
104
Chapter 11 Displaying text
The system font is used in a %tx control, unless %fn appears before %tx. If %fn is
used then a mono-spaced font (such as Courrier New) should be selected because the
text array must be aligned both vertically and horizontally.
Note that the text array is not re-dimensioned if the control is re-sized. Re-sizing
simply changes the region that is visible.
105
ClearWin+ User’s Guide Fortran
106
12.
%N.Meb[options]
This format code provides a text editor and is by far the most complex format
available. However, many applications will not require any of the embellishments
detailed below. Note that %rs and %re are simpler to use but are limited to 32768
characters.
Two arguments are required, a pointer to the buffer containing the text to be edited,
and an integer specifying the maximum size of the buffer. The text should be
terminated by the null (270A) character, and new lines should consist of carriage
return/line feed pairs. This does not use the standard Windows edit control and as a
result there is no limit (other than the total available memory) to the size of the text
area. If the second argument (the length of the buffer) is set to zero, the edit box
allocates its own memory for the buffer, re-sizing it as required.
%60eb denotes an edit box that displays 60 characters on one line (which is the same
as %60.1eb). %60.20eb denotes an edit box that displays 60 characters by 20 lines.
The text itself has the format of a normal DOS text file (lines of text separated by a
carriage return/line feed character pair) with a closing a null terminator. The edit box
can also handle text lines separated by carriage return characters only, providing this
is used consistently.
In order to read/write data to a file in this format the file should be opened in binary
mode.
For example:
F8=0??
270A02C4A QdUUTa
270A02C4A' U]P\T
8=C464A WP]S[TTaaNR^STQhcTbNaTPS]QhcTbfX]X^/
U]P\T,\hUX[T
107
ClearWin+ User’s Guide Fortran
20;; ^_T]a/U]P\TWP]S[TTaaNR^ST
20;; aTPSU/QdUUTaWP]S[T QhcTbNaTPSTaaNR^ST
20;; R[^bTU/WP]S[TTaaNR^ST
X,fX]X^/%!TQQdUUTa
20;; ^_T]f/U]P\TWP]S[TTaaNR^ST
]QhcTb,8=34GQdUUTa270A
20;; faXcTU/QdUUTaWP]S[T]QhcTbTaaNR^ST
4=3
The only null character in the string must be at the end. You must include the null
character when calculating the length of a string. In the above example, the Fortran
8=34G intrinsic function has been used to obtain the size of the edit buffer. An
alternative method is given below. Note that ^_T]a/ etc. are Salford Fortran library
routines.
<option list> is a list of items surrounded by square brackets and separated by
commas. The entire (square-bracketed) list may be omitted if no options are required.
108
Chapter 12 Edit box (%eb)
109
ClearWin+ User’s Guide Fortran
110
Chapter 12 Edit box (%eb)
111
ClearWin+ User’s Guide Fortran
Note the use of the Salford-supplied intrinsic function 22>A4 to return the character
string at the given address.
The Salford-supplied intrinsic function ;>2 can be used when the address of a
variable is required. For example, if an edit buffer is provided, the following fragment
of code would give the position of any selected text in the window relative to the
beginning of the file.
270A02C4A QdUUTa
8=C464A _^bXcX^]X]U^!#
X,fX]X^/%!OTQQdUUTa X]U^
_^bXcX^],TQNbT[TRcX^];>2QdUUTa
Note also that, if an edit buffer is provided, a call-back function can be used to
monitor the size of the text in the buffer and to make a call to VTcNbc^aPVT/ if it is
getting full. If the buffer overflows, the system will generate a fatal error.
%eb can take the caret (^) format modifier to indicate that a call-back function is
supplied (after the address of the 438CN8=5> structure if any). This function is called
whenever the contents of the box change, a key is pressed, or the cursor is moved. If
the call-back function does not handle the response to control keys such as Delete,
BackSpace, etc., then it should return a zero value.
This format code can also use the tilde (~) format modifier to indicate that a grey
control variable is supplied. This variable should precede the call-back function (if
any) in the argument list.
An edit box will almost certainly contain information that the user will not wish to
lose, so it is a good idea to use the %cc format to monitor the closure of the main
window.
112
Chapter 12 Edit box (%eb)
B4;42CN0;;
113
ClearWin+ User’s Guide Fortran
Text search:
8=C464A 58=3N438CNBCA8=6/4BCA102:F0A3BF7>;4NF>A3
20B4NB4=B8C8E4
8=C464A 4!# 438CN8=5> Q[^RZ
270A02C4A BCA BcaX]V c^ bTTZ
;>6820; 102:F0A3B CadT c^ _TaU^a\ QPRZfPaS bTPaRW
;>6820; F7>;4NF>A3 BTTZ P fW^[T f^aS
;>6820; 20B4NB4=B8C8E4 2PbT \dbc \PcRW
;>6820; B4;42CNA4BD;C ;TPeT aTbd[c bT[TRcTS
This function searches for the specified string and returns 1 if successful and zero
otherwise. Typically you would supply a search menu item on a window containing
an edit box. In the call-back function associated with that menu you would display a
dialog box to obtain the string (%rs) and some of the various flags (%rb) and then call
UX]SNTSXcNbcaX]V/ Although designed for %eb, this function may also be
useful when searching for a sub-string in a string obtained from some other source.
Text search/replace:
8=C464A 58=3NA4?;024N438CNBCA8=6/4BCAA4?;024<4=C
102:F0A3BF7>;4NF>A320B4NB4=B8C8E4A4?;024N0;;
8=C464A 4!# 438CN8=5> Q[^RZ
270A02C4A BCA BcaX]V c^ bTPaRW U^a
270A02C4A A4?;024 AT_[PRT\T]c bcaX]V
;>6820; 102:F0A3B CadT c^ _TaU^a\ QPRZfPaS bTPaRW
;>6820; F7>;4NF>A3 BTTZ P fW^[T f^aS
;>6820; 20B4NB4=B8C8E4 2PbT \dbc \PcRW
114
Chapter 12 Edit box (%eb)
;>6820; A4?;024N0;;
2^]cX]dT d]cX[ cWT T]S ^a QTVX]X]V ^U UX[T
This function searches for the specified string and replaces it with the replacement
string. The function returns a count of the number of replacements made.
Buffer positioning:
8=C464A B2A>;;N438CN1D554A/47?>BE?>B
8=C464A 4!# 438CN8=5> Q[^RZ
8=C464A 7?>B
8=C464A E?>B
This function positions the buffer at a given point and returns 1 if successful and zero
otherwise.
8=C464A 5D=2C8>= 03E0=24N438CN1D554A/4=
8=C464A 4!# 438CN8=5> Q[^RZ
8=C464A = 2^d]c ^U RWPaPRcTab c^ \^eT
This routine moves the pointer through an edit buffer character by character. The
carriage return/line feed character pair are treated as one. = can be set to a negative
value in order to move backwards through the buffer. The number returned is the
number of character positions moved. Thus unless the start or end of the buffer was
encountered, the value of = will be returned unchanged.
Undo operations:
BD1A>DC8=4 D=3>N438CN270=64/4
8=C464A 4!# 438CN8=5> Q[^RZ
Performs one level of undo operation. A single undo may reverse the effects of several
function calls. Direct user interactions with the edit box are tagged so that one user
command is reversed at each step (even though it may be implemented in several
steps). Other operations should be tagged as required using
]TgcNTSXcN^_TaPcX^]/ described next.
BD1A>DC8=4 =4GCN438CN>?4A0C8>=/4
8=C464A 4!# 438CN8=5> Q[^RZ
Calling this function indicates to the edit box that future changes are to be considered
to belong to a new user operation. Typically you would call this routine at the head of
a menu call-back function that was about to change the edit buffer in some way. If
you perform a long series of changes without calling this function, they will all be
reversed as a block if the user performs an undo operation.
115
ClearWin+ User’s Guide Fortran
Opening a file:
8=C464A 5D=2C8>= >?4=N438CN58;4/458;4
8=C464A 4!# 438CN8=5> Q[^RZ
270A02C4A 58;4 =P\T ^U UX[T c^ ^_T]
This function discards any existing information in the edit buffer and reads the
contents of the specified text file into the buffer. It returns 1 on success and zero if it
was unable to open the file. To use this function successfully you are advised to
specify a zero buffer size with %eb to obtain a dynamically allocated buffer.
Inserting text:
BD1A>DC8=4 8=B4ACN438CNBCA8=6/4BCA
8=C464A 4!# 438CN8=5> Q[^RZ
270A02C4A BCA BcaX]V c^ X]bTac
Inserts the given string (including any trailing blanks) into the buffer at the current
point and advances the current point to beyond the insertion. To insert a new line into
data containing carriage return-line feeds (i.e. the binary image of a file) you should
insert carriage return (decimal 13) followed by line feed (decimal 10).
Deleting text:
8=C464A 5D=2C8>= 438CN34;4C4N;8=4B/4=
8=C464A 4!# 438CN8=5> Q[^RZ
8=C464A = =^ ^U [X]Tb c^ ST[TcT
This function deletes = lines starting at the current position. It returns the number of
lines actually deleted, which may be less than = if the end of the buffer is encountered.
116
Chapter 12 Edit box (%eb)
Marking blocks:
BD1A>DC8=4 438CN>?4=N;8=4N<0A:/4
8=C464A 4!# 438CN8=5> Q[^RZ
This starts a line-mode selection. Initially the selection covers the current line, but it
can be extended upwards or downwards by moving the cursor key. The selected area
can be cut/paste in the same way as an ordinary character selection.
BD1A>DC8=4 438CN>?4=N1;>2:N<0A:/4
8=C464A 4!# 438CN8=5> Q[^RZ
This starts a block (or column) selection. To use this you probably want to use the
]^NRdab^aNb]P_ option (see above) since the user will be creating and manipulating
rectangular regions on the screen.
BD1A>DC8=4 438CN2;>B4N<0A:/4
8=C464A 4!# 438CN8=5> Q[^RZ
This will close a selection of either type.
Clipboard cut/paste
The address of an 438CN8=5> structure associated with an edit box can also be passed
to the following functions:
8=C464A 5D=2C8>= 438CN2;8?1>0A3N2>?H/4
8=C464A 5D=2C8>= 438CN2;8?1>0A3N2DC/4
8=C464A 5D=2C8>= 438CN2;8?1>0A3N?0BC4/4
8=C464A 5D=2C8>= 438CNA45A4B7/4
8=C464A 4
117
ClearWin+ User’s Guide Fortran
The first three functions perform the indicated clipboard operation using the current
cursor position and current selected text in the edit box. They would typically be
called from an edit menu call-back. The last function informs the edit control that the
contents of the buffer have been replaced. In each case the function returns one if
successful, and zero otherwise.
Scroll position
The address of an 438CN8=5> structure associated with an edit box can also be used
to get the cursor position of the top left corner of the window and to scroll vertically to
make a given line appear as the first line.
BD1A>DC8=4 438CNF8=3>FNC>?N;45C/47?>BE?>B
BD1A>DC8=4 B4CN438CN58ABCN;8=4/4E?>B
8=C464A 4!# 438CN8=5> Q[^RZ
8=C464A 7?>BE?>B
In the first of these two routines, a return value of (-1) indicates an error condition.
118
13.
Help
The question mark “?” is used as a format modifier in order to signify that a help
string is supplied. By default, the help string is displayed at the bottom of the
window. The help string is either surrounded by square brackets, or an “@” character
is placed in the format string to indicate that the help string is supplied as an extra
argument. In addition to “?”, %bh, %th and %he are used to change the manner in
which a help string is presented.
119
ClearWin+ User’s Guide Fortran
c^VV[T,!
4=3
A grave accent can be added to %bh. This has the effect of generating a short delay
before the help bubble appears.
%th is used as an alternative to %`bh. %th provides a help bubble in the form of a
“tooltip”.
120
14.
Window attributes
Caption - %ca[title]
%ca defines the title for a format window. The title is supplied as a standard
character string.
For example:
X,fX]X^/RPJ4aa^aL
The caption will be re-drawn whenever the window is refreshed. This means that if
the title is supplied in the argument list (signified by the “@” character in the format
string) then the window title can be changed dynamically by changing the contents of
the string and calling fX]S^fNd_SPcT/.
121
ClearWin+ User’s Guide Fortran
122
Chapter 14 Window attributes
123
ClearWin+ User’s Guide Fortran
does not use %lw, and therefore does not have a control variable, use %cv (see above)
in the parent window. In general the child window should have a caption so that it
can be moved, maximised, minimised, etc. within the frame. This means that you
should not use the %ww ]^NRP_cX^] option in this context.
The following code provides the basis of a simple “multipad” editor using %fr and
%aw.
F8=0??
8=C464A Rca[fX]X^/
4GC4A=0; ^_T]NUd]R
270A02C4A !' U]P\T
2><<>= Rca[
U]P\T,³U^a³
X,fX]X^/ffJ]^NQ^aSTaL´
X,fX]X^/³\]J5X[TJ>_T]LL´
58;4N>?4=AJ>_T]LU]P\T^_T]NUd]R438CN58;4U]P\T
X,fX]X^/³\]JJ4gXcLL´4G8C
X,fX]X^/³_eUa´#;";
X,fX]X^/³[fRca[
4=3
8=C464A 5D=2C8>= ^_T]NUd]R
2><<>= Rca[
8=C464A Rca[fX]X^/
X,fX]X^/_ePf´Rca[
X,fX]X^/³!'TQJ]^NQ^aSTaL;
^_T]NUd]R,
4=3
124
Chapter 14 Window attributes
125
ClearWin+ User’s Guide Fortran
126
Chapter 14 Window attributes
not used and the next character in the format string is an open square bracket ‘[’).
The following options are available:
127
ClearWin+ User’s Guide Fortran
By default a main window uses the background colour that the user can select from the
Control Panel in the Program Manager. This colour is returned by
6TcBhb2^[^a2>;>ANF8=3>F.
The new colour can be supplied as one of the standard colours: Q[PRZ fWXcT
VaTh aTS VaTT] Q[dT and hT[[^f (for example: QVJhT[[^fL).
Alternatively %bg takes one integer argument that has a value given by A61/.
For example:
X,fX]X^/QVA61/!$$!$$
It is often desirable to base the new colour on the default by calling GetSysColor. In
other words, you could create an alternative shade of the default background colour by
unpacking the integer returned by GetSysColor and by modifying one or more of the
(red, green, blue) components. For example:
8=C464A R^[^aaTSVaTT]Q[dT
R^[^a , 6TcBhb2^[^a2>;>ANF8=3>F
aTS , 0=3R^[^a!$$
VaTT] , 0=3ABR^[^a' !$$
Q[dT , 0=3ABR^[^a %!$$
R^[^a , A61/aTSVaTT]Q[dT$
X , fX]X^/QVR^[^a
This will deepen the blue component of the background colour (the new value is
assumed to be less that 256). AB and 0=3 are Salford-supplied intrinsic functions (in
Fortran 90/95 you can use the standard intrinsics 8B75C and 80=3).
128
Chapter 14 Window attributes
Although a ClearWin window can be used for both input and output, it is normally
wise to perform input using other format codes and to use ClearWin windows for
scrolling results. ClearWin windows are also very useful while debugging a program.
The call-back functions 2DC, 2>?H and ?0BC4 will work from within a window
defined by %cw.
129
ClearWin+ User’s Guide Fortran
X,fX]X^/bWW!
X,fX]X^/RPJ=^cTbL
X,fX]X^/U]J<B BP]b BTaXULcb(3
X,fX]X^/!"aT]^cTb
R3Xb_[Ph cWT R^\QX]TS bWTTcb
X,fX]X^/RPJ?a^_Tach bWTTcLQVJVaThL
X,fX]X^/!_bW W!
4=3
130
Chapter 14 Window attributes
Wallpaper - %wp[bitmap]
%wp takes the name of a bitmap resource. bitmap is a standard character string.
%wp “wallpapers” the window with the bitmap before the text and controls are drawn.
For example:
F8=0?? RWXciaR
8=C464A XfX]X^/
X,fX]X^/RPJFP[[_P_TaLf_JRWXciL
X,fX]X^/QVJVaThLU]JCX\Tb =Tf A^\P]L
X,fX]X^/R]^Q2[TPaFX]RQ
4=3
where the resource script chitz.rc contains:
RWXci 18C<0? R)KfX]S^fbKRWXciQ\_
%wp is most effective in windows that contain only graphical objects. If the bitmap is
smaller than the dimensions of the window, it will be repeated horizontally and
vertically to fill the space. Therefore, your bitmap should either be sufficiently large,
or it should contain a pattern that is designed to repeat, like the standard Windows
wallpaper bitmaps. A grave accent (`) is added to %wp in order to ensure that the
window will be expanded to hold at least one copy of the bitmap.
131
ClearWin+ User’s Guide Fortran
132
Chapter 14 Window attributes
85Q6C!$$ Q,Q!$$
4=33>
aTSaPfNbRaTT],
4=3
133
ClearWin+ User’s Guide Fortran
134
15.
Graphics
Introduction
ClearWin+ includes a library of drawing routines for drawing lines and text, for
filling areas, for copying images, etc.. These routines do not have an explicit
argument referring to the ‘surface’ on which the drawing is to take place. Instead,
drawing routines are applied to what is called the current drawing surface. This
drawing surface can be:
1) one of a number of rectangular areas of the screen generated by %gr,
2) one of a number of printer bitmaps (created for example by ^_T]N_aX]cTa/),
3) an internal drawing surface created by RaTPcTNVaP_WXRbNaTVX^]/ (that is, a
bitmap that is created for copying to another drawing surface).
When it is necessary to distinguish one surface from another, the programmer
provides a unique integer identifier (called a handle) and the routine
bT[TRcNVaP_WXRbN^QYTRc/ is used to provide the switch. This chapter describes
drawing surfaces created using %gr and RaTPcTNVaP_WXRbNaTVX^]/. Printer
surfaces are described in Chapter 18.
%gr is one of four graphics format codes provided by ClearWin+. The others are %og
(used to create a region in which OpenGL routines are used; described in the next
chapter), %pl (used to create a region in which SIMPLEPLOT routines are used;
described in Chapter 17) and %dw (used to create a region in which Windows API
functions are used; described at the end of this chapter). Using these formats it is
possible to embed your graphics in a window together with other controls. The
ClearWin+ library of drawing routines is used only with %gr. Thus, only %gr (not
%og, %pl and %dw) generates a drawing surface.
135
ClearWin+ User’s Guide Fortran
%gr can be followed by a list of options that is any valid combination of the following:
1;02: F78C4 A43 Specifies the initial background colour of the
1;D4 H4;;>F 6A4H drawing surface. Otherwise this defaults to the
^a 6A0H background colour of the surrounding window.
%gr creates a ‘control’ that is a rectangular graphics area (a drawing surface) that will
be filled by subsequent calls to ClearWin+ drawing routines. In the absence of %gr,
using drawing surface routines causes ClearWin+ to create a separate window
136
Chapter 15 Graphics
containing a drawing surface together with a button to close the window. This is
analogous to the automatic creation of a ClearWin window for standard Fortran I/O.
The various options to the %gr format are explained in this and subsequent sections of
the chapter.
%gr takes two arguments that provide the pixel width and height of a rectangular
area. You may want to vary these values depending on the resolution of the user’s
screen. The pixel width and depth of the screen is obtained by calling
R[TPafX]NX]U^/ using B2A44=NF83C7 and B2A44=N34?C7.
The %gr options consisting of simple colour names (such as 1;02: supply an initial
background colour that would otherwise default to the background colour of the
surrounding window. The option A61N2>;>DAB can be used if the default has not be
changed to RGB colour mode by calling bTcNaVQNR^[^dabNSTUPd[c/ .
For example:
8=C464A Rca[X
X,fX]X^/ffVaJQ[PRZaVQNR^[^dabL#;";
X,fX]X^/QcJ>:L[fRca[
20;; SaPfN[X]TNQTcfTT]/ "!A61/!$$
This will draw a red line on a black background. In this example, %lw has been used
to leave the window open so that code to draw to the drawing surface can follow. A
alternative approach is to provide a startup call-back function using %sc and to place
the graphics code in the call-back. This approach is usually preferred unless you need
to use %lw for other reasons.
If more than one drawing surface is to be drawn (either within one window, or on
different windows) then a grave accent modifier is supplied to %gr and a third
argument is required to input an integer (called a handle) that you provide. This
handle is used in the subroutine bT[TRcNVaP_WXRbN^QYTRc/ in order to select the
current drawing surface.
The following example creates two drawing surfaces and draws to each in turn.
8=C464A Rca[W]S W]S!
30C0 W]S W]S! !
R 6aP_WXRb WP]S[Tb PaT X]_dc eP[dTb c^ Va
R
20;; bTcNaVQNR^[^dabNSTUPd[c/
X,fX]X^/OVa#;";W]S
X,fX]X^/OVa#;";W]S!
X,fX]X^/ff[fRca[
X,bT[TRcNVaP_WXRbN^QYTRc/W]S
20;; SaPfN[X]TNQTcfTT]/ "!A61/!$$
X,bT[TRcNVaP_WXRbN^QYTRc/W]S!
20;; SaPfNUX[[TSNT[[X_bT/! $&$$A61/!$$
137
ClearWin+ User’s Guide Fortran
Other drawing surfaces can be set up to write an image to memory or to write output
to the printer. The graphics calls in the above program can also be used on such
surfaces. Details appear later in this chapter and in Chapter 18.
Drawing text
Text may be added to a %gr drawing surface by using SaPfNRWPaPRcTab/, for
example,
20;; SaPfNRWPaPRcTab/CX\T BTRb"$"'A61/!$$!$$!$$
The initial font is the current font in the format window, but it can be changed by
using the following routines. These operate on the currently selected drawing surface.
Note that generally only TrueType fonts can have their appearance varied in all of the
ways shown below.
138
Chapter 15 Graphics
139
ClearWin+ User’s Guide Fortran
140
Chapter 15 Graphics
141
ClearWin+ User’s Guide Fortran
SaPf,!
4=3
2) An alternative method for re-sizing a %gr region is to supply the option
\TcPUX[TNaTbXiT to the %gr format code. In this case, a record (stored in a
Windows object known as a meta-file) of all graphics operations is made and the
result is re-played at the new box size. This approach is clearly the easiest to
program, however there are two factors to consider before using this technique.
a) The number of graphics operations being sent to the region must not be
unreasonably large since each graphics call will be recorded for re-play. For
example, a fractal drawing program (that continued to draw more detail for as
long as it ran) could not use this technique because it would ultimately run out
of memory.
b) Also some images may not respond well to such automatic re-scaling. This is
because floating point co-ordinates are truncated to integers when the original
image is drawn. When scaled, they are truncated a second time. In general,
line drawing will still look good, but images drawn pixel by pixel are probably
best re-sized by method 1.
142
Chapter 15 Graphics
also be generated.
A4B8I4 Given when the DB4ANA4B8I4 option is used and
the window has just been created or re-sized.
Usually the call-back function will draw or re-draw
the image.
3A06N0=3N3A>? Given when an icon has been dragged and dropped
on to the graphics area.
Tip Many systems are configured so that the middle mouse button is inactive, even though
it is physically present on the mouse. For this reason it is better to avoid relying on
this button.
Once the reason for the call-back has been established, additional information can be
obtained by calling R[TPafX]NX]U^/. You can use 6A0?782BN<>DB4NG and
6A0?782BN<>DB4NH to obtain the pixel co-ordinates of the mouse event that caused
the call-back. Also 6A0?782BN<>DB4N5;06B gives full information about the state
of the mouse keys (this is most useful when the 5D;;N<>DB4N8=?DC %gr option is
used). The mouse flags are bitwise significant as follows:
Graphics selections
Consider the task of writing a simple paint program. Such programs often allow the
user to hold down the left mouse key in order to open up a box that is used to select an
area. Alternatively, the effect of dragging the mouse could be to create a line rather
than a box.
%gr drawing surfaces have an associated ‘selection mode’. This mode tells
ClearWin+ what to do if the mouse is dragged (by the left button) over the area. The
143
ClearWin+ User’s Guide Fortran
mode can be set using the 1>GNB4;42C8>= or ;8=4NB4;42C8>= options on the %gr
format code. The mode can also be changed dynamically using the
bTcNVaP_WXRbNbT[TRcX^]/ function. This operates on the current drawing
surface. The argument to this function takes the following values:
0 default - no selection
1 box selection
2 line selection
When a selection is enabled, dragging the mouse with the left button depressed opens
an XOR drawn box or line. A program obtains the co-ordinates using
VTcNVaP_WXRbNbT[TRcTSNPaTP/. Typically you would call this function on the
release of the left mouse (or possibly in response to a button press) so that the program
would respond to the final position of the line or box.
The following example uses 1>GNB4;42C8>=. When the left mouse button is
released, the program draws a diagonal line using the box position and dimensions. If
the shift key is held down, a copy of the box is produced instead of a line.
Alternatively, if the control key is held down, an ellipse is drawn to fill the box.
F8=0??
8=C464A XfX]X^/
270A02C4A' U\c
4GC4A=0; VaNUd]R
X,fX]X^/ffJ]^NQ^aSTaLRPJ1^g BT[TRcX^]LbhJ"SNST_aTbbTSL
U\c,MVaJQ[PRZQ^gNbT[TRcX^]Ud[[N\^dbTNX]_dcaVQNR^[^dabL
X,fX]X^/U\c!!VaNUd]R
4=3
U[PVb,R[TPafX]NX]U^/VaP_WXRbN\^dbTNU[PVb
8bD_,0=3U[PVb<:N;1DCC>=4@
858bD_0=3FPb3^f]C74=
VaTh,A61/ & & &
20;; VTcNVaP_WXRbNbT[TRcTSNPaTP/g h g!h!
20;; bTcNVaP_WXRbNbT[TRcX^]/
850=3U[PVb<:NB785C4@<:NB785CC74=
20;; SaPfNUX[[TSNaTRcP]V[T/g h g!h!VaTh
144
Chapter 15 Graphics
4;B4850=3U[PVb<:N2>=CA>;4@<:N2>=CA>;C74=
P,$g!g
Q,$h!h
20;; SaPfNUX[[TSNT[[X_bT/g Ph QPQVaTh
4;B4
20;; SaPfN[X]TNQTcfTT]/g h g!h!VaTh
4=385
20;; bTcNVaP_WXRbNbT[TRcX^]/
4=385
FPb3^f],=>C8bD_
VaNUd]R,
4=3
145
ClearWin+ User’s Guide Fortran
64CN381NB8I4/ obtains information about an existing .BMP file. The file name is
an input argument that should have the .BMP suffix. The file name may be a full path
name. If the routine succeeds, an error code is returned with the value zero whilst
other arguments return the width and height (in pixels) of the image contained in the
file. The number of bits per pixel is also returned as one of the following values:
1 Monochrome black and white image
4 16-colour image
8 256-colour image
24 Full colour image in which each pixel is represented by eight bits per
red/green/blue value.
VTcNSXQNQ[^RZ/ extracts a rectangular block (that could be the whole image) from a
given file into an array. The first index of the array is the colour index in the order
(red, green, blue). Displacements 0G and 0H into the array are typically zero but they
can be set to other values if, for example, the array is to be composed of a montage of
several blocks. Arguments F and 7 represent the width and height of the block to be
transferred, whilst 3G, 3H represent the displacement (again typically zero) into the
image in the file.
SXb_[PhNSXQNQ[^RZ/ transfers a rectangular block of given size (F × 7) from the
array at a position (0G, 0H) to a position (G, H) on the current drawing surface (e.g. a
%gr region or a printer). Two arguments named 5D=2C8>= and <>34 are normally
set to zero. An argument for the error status is returned as zero if the process is
successful.
_dcNSXQNQ[^RZ/ transfers a rectangular block from an array to given file,
destroying any previous contents. Displacements 0G and 0H into the array are
typically zero, whilst arguments F and 7 are the width and height of the image to be
created. An argument for the number of bits per pixel is currently ignored and should
set to 24. This routine always writes BMP files with 24 bits per pixel.
The use of these routines is best illustrated by a simple example. The following
example reads a BMP file, alters the array to draw a red line through the image,
displays the result, and writes a new BMP file with the modified image.
F8=0??
8=2;D34 +fX]S^fbX]b-
270A02C4A$ UX[T
270A02C4A P" !# !#
8=C464A WaTbeaTb]QNR^[^dabXTaXZR^]ca^[
R =^cT h^d \Ph ]TTS c^ P[cTa cWXb _PcW
UX[T,R)KfX]S^fbKbTcd_Q\_
20;; VTcNSXQNbXiT/UX[TWaTbeaTb]QNR^[^dabXTa
146
Chapter 15 Graphics
147
ClearWin+ User’s Guide Fortran
WSXQ,X\_^acNQ\_/UX[TTaR^ST
85TaR^ST=4 BC>? 8\_^ac Taa^a
X,fX]X^/VaJaVQNR^[^dabL[fWaTbeaTbRca[
TaR^ST,SXQN_PX]c/WSXQ
85TaR^ST4@ BC>? ?PX]c Taa^a
RP[[ SaPfN[X]TNQTcfTT]/WaTbeaTbA61/!$$
85^_T]N_aX]cTa/&4@ C74=
20;; VTcNVaP_WXRP[NaTb^[dcX^]/fXScWWTXVWc
TaR^ST,_aX]cNSXQ/&fXScWWTXVWcWSXQWaTbeaTb
85TaR^ST4@ BC>? ?aX]c Taa^a
TaR^ST,R[^bTN_aX]cTa/&
85TaR^ST4@ BC>? 2[^bT _aX]cTa Taa^a
4=385
20;; aT[TPbTNbRaTT]NSXQ/WSXQ
4=3
This program imports a bitmap and then creates a drawing surface on the screen using
%gr. The bitmap is drawn to the screen and a red line is draw across it. The standard
printer dialog is then displayed via a call to ^_T]N_aX]cTa/. If the user clicks on
the OK button, the routine returns the value 1 and the current graphics device is now
the printer with device handle 7. The bitmap is drawn to this device. Calling
R[^bTN_aX]cTa/ sends the image to the printer.
148
Chapter 15 Graphics
The DB4ANBDA5024 option implies the A61N2>;>DAB option and must not be mixed
with <4C058;4NA4B8I4, although it can be combined with DB4ANA4B8I4. A trade-
off is involved here. The user surface will usually require more memory than the
device dependent bitmap that ClearWin+ normally uses to implement %gr. Also each
re-draw of the window will be slower. However, if you implement pixel-by-pixel
graphics by directly manipulating the buffer, you will see a substantial speed
improvement over making calls to SaPfN_^X]c/. If DB4ANBDA5024 is combined
with DB4ANA4B8I4 then the surface pointer variable will be updated each time the
window is re-sized. It is important not to copy this variable and so use an obsolete
version of the pointer. The row of the buffer has a layout corresponding to the
following array:
8=C464A QdUUTa"fXScW
The first index covers the colours as follows:
1[dT
! 6aTT]
" ATS
After each row a few bytes of padding are added if necessary to make the row a
multiple of four bytes. The next row then follows. This layout is imposed by the
Windows operating system and not by ClearWin+.
Here is a simple Fortran example:
F8=0??
8=2;D34 +fX]S^fbX]b-
4GC4A=0; SaPf
8=C464A _ca
2><<>= _ca
XP,fX]X^/ff_eMVaJQ[PRZdbTaNaTbXiT´
³dbTaNbdaUPRTL!$%!$%_caSaPf
4=3
149
ClearWin+ User’s Guide Fortran
_PSNfXScW,[bab"fXScW"!!
R 3aPf P SXPV^]P[ hT[[^f [X]T
3> X, \
g,X
h,X
R 2^\_dcT X]STg X]c^ PaaPh
`,"g_PSNfXScWh
Ud[[N^],!$$
R ATS R^\_^]T]c
2>A4 _ca`!,Ud[[N^]
R 6aTT] R^\_^]T]c
2>A4 _ca` ,Ud[[N^]
4=33>
4=385
SaPf,!
4=3
Note that it is possible (and often very useful) to mix calls to ClearWin+ graphics
routines and direct manipulation of the pixel buffer. If you do this under Windows NT
you must call the API function GdiFlush() to ensure that the effect of any previous
function calls have ‘flushed through’ before you manipulate the buffer directly. This
call is harmless but unnecessary under Windows 95. If you intend to perform all your
graphics by direct buffer manipulation this need not concern you.
If you want to display a large image but do not have the screen space to do so or if you
are producing a graphics and text output window, the routine bRa^[[NVaP_WXRb/
will be of great use. This routine will allow you to scroll graphics in any direction by
any displacement (see page 396).
Off-screen graphics
Sometimes, it is useful to build up graphics information in memory, rather than on the
screen. For example, such information might be subsequently copied to the screen at
several locations, or written to a file. A complex drawing could be built up off screen
whilst displaying other information. When complete, the drawing can be displayed.
In ClearWin+ there are two approaches to this issue each with its own set of routines.
The first creates an internal drawing surface using RaTPcTNVaP_WXRbNaTVX^]/
and is described below. The other approach uses what is called a virtual screen and is
described in the ClearWin+ User’s Supplement. Mixing routines from the two sets
may not produce the desired result.
An internal drawing surface uses the following set of routines together with the DIB
routines listed in the section on page 145.
150
Chapter 15 Graphics
151
ClearWin+ User’s Guide Fortran
Graphics icons
It is possible to supply the user with more interesting ways to interact with your
graphics area than merely clicking with the mouse. A %gr drawing surface can have
an icon resource ‘attached’ to it. The icon can be moved freely around the graphics
window with the mouse. Control of the icon is maintained by the call-back function
attached to %gr.
PSSNVaP_WXRbNXR^]/ is used to attach an icon resource (defined in a resource
script) to the current screen drawing surface. A =0<4 argument is used to stipulate
the resource. G and H variables are used as arguments that hold the initial location of
the image. These variables also hold the new position when the image is moved. The
call-back function for %gr can modify the G and H values if required. In this way it is
possible to ‘lock’ the image on to a horizontal or vertical plane by repeatedly setting
either G or H to a constant value.
The F83C7 and 74867C arguments of PSSNVaP_WXRbNXR^]/ should be set to zero
except when the icon image is less than 32x32 pixels. A smaller icon is constructed
by starting at the top-left corner and by filling the remaining unused area with the
‘transparent’ colour. In this case, if you do not specify the correct size of the icon then
the unused area will be detected by the mouse.
R[TPafX]NX]U^/’3A06643N82>=´ returns the handle of the icon that has
moved. This handle is initially obtained as the value returned by
PSSNVaP_WXRbNXR^]/.
When the icon is dropped, R[TPafX]NX]U^/3A>??43N82>= returns the
handle of the associated icon. A graphics icon can be removed with a call to
aT\^eTNVaP_WXRbNXR^]/.
The following program draws a horizontal scale with an icon that can be dragged
across it. The resource script attaches an icon file to the ‘arrow_r’ resource in the
program. The Windows API function ClipCursor is used to provide a clipping
rectangle for the mouse cursor when the left mouse button is held down over the icon.
The Salford intrinsic 2>A4# is used to pass a NULL pointer to ClipCursor.
152
Chapter 15 Graphics
8=C464A Xgh
2><<>= gh
4GC4A=0; bcPacNRQVaNRQ
g,#%
h,$
X,fX]X^/ffJ]^NQ^aSTaLRPJ<^ePQ[T XR^]L
X,fX]X^/ORd2DAB>AN0AA>F
X,fX]X^/MVaJVaThaVQNR^[^dabUd[[N\^dbTNX]_dcL
" VaNRQ
X,fX]X^/bRbcPacNRQ
4=3
153
ClearWin+ User’s Guide Fortran
;,2[X_2dab^aaR
FPb3aPV,CAD4
4=385
4=385
85FPb3aPV0=3=>C8b3aPVC74=
;,2[X_2dab^a2>A4#
FPb3aPV,50;B4
4=385
h,$
85g;C#% g,#%
85g6C!#%g,!#%
VaNRQ,
4=3
154
Chapter 15 Graphics
In 16 colour mode Windows uses a set palette. It holds ‘general’ colours that are of
most use. If the program requires shades or colours that do not exist in the palette,
Windows will attempt to dither that colour. Dithering gives a quick effect that often
matches the desired colour. It is done by placing pixels of different colours next to
each other so that when the user is a suitable distance away from the screen the pixels
will appear to be a third colour.
In 256 colour modes there are 256 unique palette entries. Each palette entry is made
by setting a red, a green and a blue component. In this mode, when a pixel is written,
a value between 0 .. 255 is placed in the display memory. When the display is
refreshed the red, green and blue values are ‘looked up’ and sent to the screen.
There have recently been several new display colour ‘depths’ added as new hardware
has been designed. These high colour modes store the colours directly in the display
memory thus avoiding the need for a palette at all. The two most common colour
depths are 65535 and 16.7 million. These depths allow each pixel to be set to any one
of the possible colours.
If you want to use a wide range of colours whilst avoiding the complexities of
managing a palette, one solution is to restrict the usage of your application to desktops
operating in high colour mode. For this purpose, you can use the function
WXVWNR^[^daN\^ST/ to test if the desktop is set to operate in high colour mode.
A call to R[TPafX]NX]U^/³B2A44=N=D<N2>;>DAB´ will
give the number of colours for the desktop unless this number is
greater than 256 (the value 8192 represents all values greater than
256, i.e. a high colour device). A list of palette functions is given
on page 322. These are documented in the ClearWin+ User’s
Supplement.
If the desktop graphics device is not a high colour device, when
you draw to the screen, the colour that you get will not always be
exactly the colour you specify in the program. This may cause
difficulties if you read a pixel from the screen and try to match the
colour with one that you have used earlier to draw to the screen.
The following program illustrates the problem together with one
method of solution. The program draws a set of ‘traffic lights’.
When the user clicks on any part of the picture, the colour for that
part cycles through the sequence: red, amber, green, black.
F8=0??
8=C464A XfX]X^/
4GC4A=0; UX[[NRQbcPacNRQ
X,fX]X^/ffJ]^NQ^aSTa]^N\Pg\X]Q^gL
X,fX]X^/bhJ"SNST_aTbbTSL
X,fX]X^/MVaJQ[PRZaVQNR^[^dabL !$UX[[NRQ
X,fX]X^/bRbcPacNRQ
155
ClearWin+ User’s Guide Fortran
4=3
R
8=C464A 5D=2C8>= bcPacNRQ
8=2;D34 +R[TPafX]X]b-
8=C464A XfWXcT
20;; bTcN[X]TNfXScW/!
fWXcT,A61/!!!
20;; SaPfNaTRcP]V[T/ ((!#(fWXcT
3> X,$!&$
20;; SaPfNT[[X_bT/$X"!"!fWXcT
4=33>
bcPacNRQ,
4=3
R
8=C464A 5D=2C8>= UX[[NRQ
8=2;D34 +R[TPafX]X]b-
8=C464A ghSUaTSVaTT]Q[PRZP\QTafWXcTR^[^daP
20;; VTcN\^dbTNX]U^/ghS
20;; VTcNaVQNeP[dT/ghR^[^da
aTS, VTcN\PcRWTSNR^[^da/A61/!$$
VaTT],VTcN\PcRWTSNR^[^da/A61/!$$
P\QTa,VTcN\PcRWTSNR^[^da/A61/!$$ %'
fWXcT,VTcN\PcRWTSNR^[^da/A61/!!!
Q[PRZ,
85R^[^da4@Q[PRZC74=
U,aTS
4;B485R^[^da4@aTSC74=
U,P\QTa
4;B485R^[^daT`P\QTaC74=
U,VaTT]
4;B4
U,Q[PRZ
4=385
20;; UX[[NbdaUPRT/ghR^[^daU
UX[[NRQ,
4=3
An alternative solution is to use VTcN]TPaTbcNbRaTT]NR^[^da/ in place of
VTcN\PcRWTSNR^[^da/. The effect is the same but you will probably get a different
amber colour on the screen for the following reasons.
When you draw to a screen drawing surface, ClearWin+ filters the colour through its
logical palette in order to find an optimum match (we are assuming the device is not a
high colour device). When ClearWin+ calls a Windows API drawing function, the
result is then filtered through the system palette. Now suppose we call one of the
156
Chapter 15 Graphics
F8=0??
8=2;D34 +fX]S^fbX]b-
8=C464A \hNSR
\hNSR,VTcNQXc\P_NSR/$$
20;; <^eTC^\hNSR
20;; ;X]TC^\hNSR$$
X,fX]X^/Sf QcJ>:L\hNSR
R CWT ]Tgc [X]T Xb ]^c ]TRTbbPah d][Tbb
R \P]h STeXRT R^]cTgcb fX[[ QT PR`dXaTS
20;; aT[TPbTNQXc\P_NSR/\hNSR
4=3
157
ClearWin+ User’s Guide Fortran
Note that you can continue to change the graphics in the bitmap after the window has
been displayed (from call-back functions, or using the %lw format to leave the window
in place) provided that fX]S^fNd_SPcT/732 is used to update the screen, where
732 is the handle of the device context. Other routines that operate in terms of a
handle to a device context are listed on page 319.
When it is created, the bitmap will be filled with the default background window
colour (i.e. it will be invisible unless displayed inside a shaded box). The colour can
be changed with a call to the standard Windows API FillRect function.
It is possible to change the pen associated with a device context acquired by calling the
ClearWin+ function VTcNQXc\P_NSR/ (see page 361), without worrying about
deleting used pens. This is performed by calling the ClearWin+ RWP]VTN_T]/
function (see page 335). The first argument in this function is a device context
acquired by calling VTcNQXc\P_NSR/ followed by three other arguments similar
those supplied to the Windows API CreatePen function.
Currently the option list, if present, may contain:
Ud[[N\^dbTNX]_dc With this option the %dw call-back function is called each
time the mouse is moved, or a button is pressed or released
within the area of the control. Otherwise the call-back
function only responds to mouse input when the user clicks
158
Chapter 15 Graphics
on the control.
You can use VTcN\^dbTNX]U^/ to obtain mouse data from within a %dw call-back
function.
159
ClearWin+ User’s Guide Fortran
160
16.
OpenGL
Introduction
OpenGL provides a relatively simple, platform independent, way to produce complex
(possibly animated) 2 or 3-dimensional images. Lighting and perspective effects are
easily introduced, although in order to achieve high performance, full ray tracing
(which produces shadows and effects caused by multiply scattered light rays) is not
available. The performance of OpenGL is sufficient that it is often used for 3-D
animation. The following two books explain the use of OpenGL without going into
platform-specific details:
OpenGL Programming Guide
OpenGL Reference Manual
See the end of this chapter for further details. OpenGL is available via two DLLs that
may already be installed on your PC.
This chapter does not present a tutorial on OpenGL nor does it describe the OpenGL
API. You are advised read the official “Red Book” learning guide to OpenGL, and to
visit the OpenGL web site at http://www.OpenGL.org
Examples in the Red Book are simplified by the use of a specially designed and
written auxiliary OpenGL library (called GLAUX). GLAUX provides an easy way to
open a window with the OpenGL attributes that you require. However, it is limited in
its use of mouse, keyboard and message handling and has the overwhelming
disadvantage you cannot attach menus or buttons. Also, it only allows one window to
be opened. ClearWin+ is very similar to GLAUX with regard to the ease with which
OpenGL windows can be opened. However, ClearWin+ has none of the above
restrictions. Nevertheless, the Red Book examples provide a convenient tutorial
approach to learning how to call the OpenGL library from ClearWin+. Much of this
161
ClearWin+ User’s Guide Fortran
chapter is devoted to discussing how to convert the Red Book examples that use
GLAUX to ClearWin+.
OpenGL - %og[options]
In order to open an OpenGL window with ClearWin+, you must use the %og format
code:
X,fX]X^^VJbcPcXRL
%og takes an list of options consisting of any valid combination of the following:
S^dQ[T This option is used for animation and causes OpenGL output to
be sent to an in-memory buffer until the
bfP_N^_T]V[NQdUUTab/ subroutine is called. This helps to
reduce flicker at the expense of requiring more memory.
ST_cW % Specifies 16 bits of depth buffering.
bcT]RX[ Stencil buffer. The stencil buffer is used to define masks used to
prevent part of image being drawn. For example, OpenGL only
allows convex polygons to be filled. More complex polygons
require the use of the stencil buffer.
PRRd\ The accumulation buffer is used to accumulate images for effects
such as anti-aliasing motion blur, depth of field etc.
dbTaNaTbXiT Same as %gr usage.
162
Chapter 16 OpenGL
163
ClearWin+ User’s Guide Fortran
500, 500 initial window size. This is specified using %og in ClearWin+.
"Simple OpenGL Sample" window caption.
In addition, GLAUX windows may be closed using the Escape key. Specify this with
%es using ClearWin+.
ClearWin+ uses %lw to allow a window to stay open when the fX]X^/ call returns.
If %lw were not specified, the drawing commands following would have no effect.
Lines 10 to 12 are replaced with the following calls to fX]X^/. The ampersands at
the end of every line are used to combine several fX]X^/ calls into one format
window.
R0[[^fb cWT dbTa c^ R[^bT cWT fX]S^f fXcW cWT +TbR- ZTh
X,fX]X^/Tb
RFX]S^f RP_cX^]
X,fX]X^/RPJBX\_[T >_T]V6; BP\_[TL
RBTcb X]XcXP[ fX]S^f _^bXcX^] c^
X,fX]X^/b_
R<PZTb cWT bP\T bch[T ^U fX]S^f Pb 6;0DG
X,fX]X^/ffJ]^NQ^aSTaL
R2aTPcTb cWT >_T]6; fX]S^f P]S aTcda]b [TPeX]V Xc ^_T]
X,fX]X^/^VJbcPcXRL[f$ $Rca[
This may all be combined into:
X,fX]X^/TbRPJBX\_[T >_T]V6; BP\_[TL
X,fX]X^/b_ffJ]^NQ^aSTaL^VJbcPcXRL[f
$$Rca[
The use of line 28 with the Red Book example is to keep the window open for 10
seconds before closing it. This is unnecessary since the ClearWin+ window will stay
open anyway until the user closes it. Note that the integer variable, Rca[ is required
since we have used %lw but that the variable itself is unused.
The Fortran include files clearwin.ins and opengl.ins must be included at the top of
the main program.
The remainder of the program is virtually unchanged. The full ClearWin+ version
appears below.
?A>6A0< BX\_[T
8=2;D34 +R[TPafX]X]b-]^[Xbc
8=2;D34 +^_T]V[X]b-]^[Xbc
A40; c c!
8=C464A X Rca[
X,fX]X^/TbRPJBX\_[T >_T]V6; BP\_[TL
X,fX]X^/b_ffJ]^NQ^aSTaL^VJbcPcXRL[f
164
Chapter 16 OpenGL
Argument types
Some OpenGL functions take single precision arguments, others double precision. In
many cases it is possible to determine the argument type from the variant of the name.
For example, glColor3f requires single precision arguments whereas, glColor3d
requires double precision arguments.
With other OpenGL functions, the name does not help. For example, glAccum and
glClearColor require single precision arguments whereas, glOrtho takes double
precision arguments.
Unlike OpenGL functions, all GLAUX functions that take floating-point arguments
require the arguments to be double precision.
You should carefully check the types of the arguments to any function before using it.
You must specify a double precision constant by using a ‘D’ exponent. Any constants
for which you use neither ‘D’ nor DBLE( ) will be regarded as single precision and
will yield unexpected results.
When linking, you are recommended to link directly with the import libraries rather
than the DLLs. Using the import library will cause mismatched arguments to result in
a link failure and enable you to quickly correct any errors.
165
ClearWin+ User’s Guide Fortran
166
Chapter 16 OpenGL
# l
#
#! e^XS 20;;102: bc^_8S[T5d]R 0DGN4E4=CA42 TeT]c
#" j
## Pdg8S[T5d]R*
#$ l
#%
#& e^XS \hX]Xc e^XS
#' j
#( V[2[TPa2^[^a *
$ V[2^[^a"U *
$ V[BWPST<^ST[ 6;N5;0C*
$! l
$"
$# e^XS 20;;102: \hATbWP_T6;bXiTX f 6;bXiTX W
$$ j
$% XU W aTcda]*
$& V[EXTf_^ac f W*
$' V[<PcaXg<^ST6;N?A>942C8>=*
$( V[;^PS8ST]cXch*
$ XU f +, W
% V[>acW^ $ $ $6;U[^PcW6;U[^Pcf
%! $6;U[^PcW6;U[^Pcf *
%" T[bT
%# V[>acW^ $6;U[^Pcf6;U[^PcW
%$ $6;U[^Pcf6;U[^PcW $ $ *
%% V[<PcaXg<^ST6;N<>34;E84F*
%& V[;^PS8ST]cXch *
%' l
%(
% <PX] ;^^_
& >_T] fX]S^f fXcW X]XcXP[ fX]S^f bXiT cXc[T QPa
&! A610 SXb_[Ph \^ST P]S WP]S[T X]_dc TeT]cb
&"
&# X]c \PX]X]c PaVR RWPa PaVe
&$ j
&% Pdg8]Xc3Xb_[Ph<^ST 0DGN3>D1;4 k 0DGNA61*
&& Pdg8]Xc?^bXcX^] $ $*
&' Pdg8]XcFX]S^f 3^dQ[T 1dUUTaX]V*
&( \hX]Xc *
& PdgATbWP_T5d]R \hATbWP_T*
' Pdg8S[T5d]R b_X]3Xb_[Ph*
'! Pdg<^dbT5d]R 0DGN;45C1DCC>= 0DGN<>DB43>F= bcPac8S[T5d]R*
'" Pdg<^dbT5d]R 0DGNA867C1DCC>= 0DGN<>DB43>F= bc^_8S[T5d]R*
167
ClearWin+ User’s Guide Fortran
'# Pdg<PX];^^_SXb_[Ph*
'$ aTcda]*
'% l
The converted program double.for is presented below. Note the use of common blocks
rather than C global variables.
Lines 76 to 78 in the Red Book sample have been replaced by a few ClearWin+ calls
at lines 109 to 111. %og has been replaced by %^og indicating that a call-back
function, ^_T]V[N_a^R, has been provided to handle messages. The use of %pv
means that A4B8I4 messages are sent to the call-back.
Mouse messages are also sent to ^_T]V[N_a^R, as are the special B4CD? and 38ACH
messages. B4CD? is sent only once, just after the window has been created and its
arrival precedes that of A4B8I4. 38ACH is sent when the window needs repainting,
for example, after A4B8I4 or when the window is brought to the top after being
partially obscured. If you take action on the 38ACH call-back, you will not need the
bcPcXR option on %og.
The Red Book variant of the program supplies several functions to handle events.
These functions are still needed and perform the same task, but they are called directly
in response to ClearWin+ messages sent to ^_T]V[N_a^R. The reshape function
\hATbWP_Tgh is called in response to A4B8I4. SXb_[Ph is called in response to
38ACH. The mouse handling functions startIdleFunc and stopIdleFunc are called in
response to <>DB4N;45CN2;82: and <>DB4NA867CN2;82:. These are registered as
call-backs with GLAUX at lines 70 and 82-83.
In the Red Book example, the initialising call to \hX]Xc at line 79 (just after the
window has been created) is handled by ClearWin+ as a message sent to
^_T]V[N_a^R. This message is B4CD? and is always sent before the first A4B8I4
message. The GLAUX idle function has no direct ClearWin+ equivalent. Instead,
%lw is used in the fX]X^/ call and program execution falls through into the
following idle loop. The test for Rca[+ at line 113 in the ClearWin+ example,
allows the program to detect when the window has been closed so that program
termination can proceed.
BD1A>DC8=4 SXb_[Ph
! 8=2;D34 +^_T]V[X]b-]^[Xbc
" A40; b_X]
# ;>6820; S^NSaPf
$ 2><<>= S^dQ[TNR^\S^NSaPfb_X]
%
& 20;; V[2[TPa6;N2>;>AN1D554AN18C
'
( 20;; V[?dbW<PcaXg
168
Chapter 16 OpenGL
169
ClearWin+ User’s Guide Fortran
$#
$$ BD1A>DC8=4 \hATbWP_Tf W
$% 8=2;D34 +^_T]V[X]b-]^[Xbc
$& 8=C464A fW
$' 3>D1;4 ?A428B8>= Pb_TRcNaPcX^
$( 85W=4 C74=
% Pb_TRcNaPcX^,A40;fW
%
%! 20;; V[EXTf_^ac f W
%" 20;; V[<PcaXg<^ST6;N?A>942C8>=
%# 20;; V[;^PS8ST]cXch
%$ 85 f;4W C74=
%% 20;; V[>acW^$S $S $SPb_TRcNaPcX^
%& $SPb_TRcNaPcX^ S S
%' 4;B4
%( 20;; V[>acW^$SPb_TRcNaPcX^
& $SPb_TRcNaPcX^ $S $S S S
& 4=385
&! 20;; V[<PcaXg<^ST6;N<>34;E84F
&" 20;; V[;^PS8ST]cXch
&# 20;; SXb_[Ph
&$ 4=385
&% 4=3
&&
&'
&( 8=C464A 5D=2C8>= ^_T]V[N_a^R
' 8=2;D34 +R[TPafX]X]b-]^[Xbc
' 270A02C4A!$% aTPb^]
'! 8=C464A fW
'" A40B>=,R[TPafX]NbcaX]V/20;;102:NA40B>=
'# 85aTPb^]4@B4CD?C74=
'$ 20;; \hX]Xc
'% 4;B4 85aTPb^]4@A4B8I4C74=
'& f,R[TPafX]NX]U^/>?4=6;NF83C7
'' W,R[TPafX]NX]U^/>?4=6;N34?C7
'( 20;; \hATbWP_TfW
( 4;B4 85aTPb^]4@<>DB4N;45CN2;82:C74=
( 20;; bcPac8S[T5d]R
(! 4;B4 85aTPb^]4@<>DB4NA867CN2;82:C74=
(" 20;; bc^_8S[T5d]R
(# 4=3 85
($
(% ^_T]V[N_a^R,!
(& 4=3
170
Chapter 16 OpenGL
('
(( ?A>6A0< S^dQ[T
8=2;D34 +R[TPafX]X]b-]^[Xbc
8=C464A X
! 8=C464A ^_T]V[N_a^RRca[
" 4GC4A=0; ^_T]V[N_a^R
# A40; b_X]
$ ;>6820; S^NSaPf
% 2><<>= S^dQ[TNR^\S^NSaPfb_X]
& 30C0 b_X]S^NSaPfCAD4
'
( X,fX]X^/TbRPJ3^dQ[T 1dUUTaX]VL
X,fX]X^/b_ffJ]^NQ^aSTaL_eM^VJS^dQ[TL[f
$$^_T]V[N_a^RRca[
!
" F78;4Rca[;C3>
# 20;; b_X]3Xb_[Ph
$ 4=3F78;4
% 4=3
This program follows the structure that will be used throughout this chapter, and your
attention is drawn again to the use of ^_T]V[N_a^R to call the reshape, display,
initialisation and mouse handling functions.
171
ClearWin+ User’s Guide Fortran
these functions will be found in the Microsoft Developer Network help files. You can
be sure that when ^_T]V[N_a^R is called, the expected device and rendering contexts
are current.
The font is also set by means of a WGL call, wglUseFontOutlines. Note how, in the
the program, a C type NULL pointer is simulated by 2>A4# This function call
will only be successful if the format code %fn is used in the definition of the parent
window.
0]X\PcX^] dbX]V >_T]6;
BD1A>DC8=4 SXb_[Ph
8=2;D34 +^_T]V[X]b-]^[Xbc
8=2;D34 +R[TPafX]X]b-]^[Xbc
8=2;D34 SP]X\PcTX]b
BD1A>DC8=4 bfP_2^]cTgcbfX]S^f
8=C464A fX]S^f
8=2;D34 +^_T]V[X]b-
8=2;D34 SP]X\PcTX]b
20;; fV[<PZT2daaT]cSTeXRTR^]cTgcfX]S^f
aT]STaX]VR^]cTgcfX]S^f
4=3
BD1A>DC8=4 b_X]B[PQfX]S^f
8=C464A fX]S^f
8=2;D34 SP]X\PcTX]b
S^NSaPffX]S^f,CAD4
4=3
BD1A>DC8=4 bc^_B[PQfX]S^f
172
Chapter 16 OpenGL
8=C464A fX]S^f
8=2;D34 SP]X\PcTX]b
S^NSaPffX]S^f,50;B4
4=3
BD1A>DC8=4 PbbT\Q[TN[Xbc
8=2;D34 +R[TPafX]X]b-]^[Xbc
8=2;D34 +^_T]V[X]b-]^[Xbc
A40;# fWXcTNR^[^da#VaThNR^[^da#SPaZNVaThNR^[^da#
A40;# aTSNR^[^da# hT[[^fNR^[^da# VaTT]NR^[^da#
A40;# Q[dTNR^[^da# _da_[TNR^[^da# RhP]NR^[^da#
A40;' SX\T]bX^]bRP[TSUSUa^]cQPRZ
8=C464A U[PVbZ
8=C464A WSR
;>6820; ^Z
30C0 fWXcTNR^[^da
30C0 VaThNR^[^da$$$
30C0 SPaZNVaThNR^[^da"""
30C0 aTSNR^[^da
30C0 hT[[^fNR^[^da
30C0 VaTT]NR^[^da
30C0 Q[dTNR^[^da
30C0 _da_[TNR^[^da
30C0 RhP]NR^[^da
30C0 Ua^]cQPRZ S$S
20;; V[4]PQ[T6;N34?C7NC4BC
W32,R[TPafX]NX]U^/>?4=6;N34E824N2>=C4GC
20;; V[2^[^a"U
173
ClearWin+ User’s Guide Fortran
R3aPf VaP_W
20;; V[1TVX]6;N;8=4B
20;; V[2^[^a"UefWXcTNR^[^da
20;; V[ETacTg!SbRP[TS
20;; V[ETacTg!SbRP[TS
20;; V[ETacTg!SSbRP[T
20;; V[ETacTg!SSbRP[T
Z,
174
Chapter 16 OpenGL
BD1A>DC8=4 \hX]Xc
20;; PbbT\Q[TN[Xbc
4=3
BD1A>DC8=4 \haTbWP_TfW
8=2;D34 +^_T]V[X]b-]^[Xbc
8=C464A f
8=C464A W
3>D1;4 ?A428B8>= Pb_TRcNaPcX^
175
ClearWin+ User’s Guide Fortran
85W=4C74=
Pb_TRcNaPcX^,SQ[TfW
20;; V[<PcaXg<^ST6;N?A>942C8>=
20;; V[;^PS8ST]cXch
20;; V[d?Tab_TRcXeT"SPb_TRcNaPcX^ S $S
20;; V[EXTf_^acfW
4=385
4=3
85aTPb^]4@B4CD?C74=
20;; \hX]Xc
4;B485aTPb^]4@A4B8I4C74=
f,R[TPafX]NX]U^/>?4=6;NF83C7
W,R[TPafX]NX]U^/>?4=6;N34?C7
20;; \haTbWP_TfW
4;B485aTPb^]4@38ACHC74=
20;; SXb_[Ph
fX]S^f NPRcXeT,cadT
4;B48UaTPb^]4@<>DB4N;45CN2;82:C74=
20;; b_X]B[PQ
4;B485aTPb^]4@<>DB4NA867CN2;82:C74=
20;; bc^_B[PQ
4=385
^_T]V[N_a^R ,!
4=3
176
Chapter 16 OpenGL
85aTPb^]4@B4CD?C74=
20;; \hX]Xc
4;B485aTPb^]4@A4B8I4C74=
f,R[TPafX]NX]U^/>?4=6;NF83C7
W,R[TPafX]NX]U^/>?4=6;N34?C7
20;; \haTbWP_TfW
4;B485aTPb^]4@38ACHC74=
20;; SXb_[Ph
fX]S^f!NPRcXeT,cadT
4;B485aTPb^]4@<>DB4N;45CN2;82:C74=
20;; b_X]B[PQ!
4;B485aTPb^]4@<>DB4NA867CN2;82:C74=
20;; bc^_B[PQ!
4=385
20;; cT\_^aPahNhXT[S/
^_T]V[N_a^R!,!
4=3
?A>6A0< 0]X\PcT
8=2;D34 +^_T]V[X]b-]^[Xbc
8=2;D34 +R[TPafX]X]b-]^[Xbc
3>D1;4 ?A428B8>= b_X]NPaaPh!
8=C464A XfX]S^f fX]S^f!
8=C464A ^_T]V[N_a^R ^_T]V[N_a^R!
4GC4A=0; ^_T]V[N_a^R ^_T]V[N_a^R!
8=2;D34 SP]X\PcTX]b
S^NSaPf ,cadT
S^NSaPf!,cadT
STeXRTR^]cTgc ,
STeXRTR^]cTgc!,
aT]STaX]VR^]cTgc ,
aT]STaX]VR^]cTgc!,
b_X],S
b_X]NPaaPh ,S
b_X]NPaaPh!,S
fX]S^f NPRcXeT,UP[bT
fX]S^f!NPRcXeT,UP[bT
177
ClearWin+ User’s Guide Fortran
"$"$^_T]V[N_a^R fX]S^f
STeXRTR^]cTgc ,fV[6Tc2daaT]c32
aT]STaX]VR^]cTgc ,fV[6Tc2daaT]c2^]cTgc
STeXRTR^]cTgc!,fV[6Tc2daaT]c32
aT]STaX]VR^]cTgc!,fV[6Tc2daaT]c2^]cTgc
S^NSaPf ,cadT
S^NSaPf!,cadT
178
Chapter 16 OpenGL
>?4=N6;N?A8=C4A/ 381
>?4=N6;N?A8=C4A / 381
?A8=CN>?4=6;N8<064/ 389
References
• Woo, Mason, Jackie Neider, and Tom Davis. OpenGL Programming Guide: The
Official Guide to Learning OpenGL, Version 1.1.Reading, MA: Addison Wesley
Longman Inc. 1997. ISBN 0-201-46138-2.
• OpenGL Architecture Review Board; Renate Kempf and Chris Frazier, editors.
OpenGL Reference Manual. The Official Reference Document for OpenGL,
Version 1.1. Reading, MA: Addison Wesley Longman Inc. 1996. ISBN 0-201-
46140-4.
• Fosner, Ron. OpenGL Programming for Windows95 and Windows NT. Reading,
MA: Addison Wesley Longman Inc. 1996.
• Wright Jr., Richard S. and Michael Sweet. OpenGL Superbible: The Complete
Guide to OpenGL Programming for Windows NT and Windows 95. Waite Group
Press. 1996.
• Angel, Edward. Interactive Computer Graphics: A top-down approach with
OpenGL. Reading, MA: Addison Wesley Longman Inc. 1997. ISBN 0-201-
85571-2.
Online information
The reference pages for OpenGL are available at:
http://www.opengl.org/
http://www.sgi.com/software/opengl/
179
ClearWin+ User’s Guide Fortran
http://www.digital.com/pub/opengl/
http://msdn.microsoft.com/
The OpenGL World Wide Web Centre contains links to a variety of articles, the
OpenGL specification, and the OpenGL usenet mailing list.
Other items are available to members of the Microsoft Developer Network. Online
versions of technical articles are also available on the Microsoft Developer homepage.
180
17.
SIMPLEPLOT
Introduction
SIMPLEPLOT is a library of Fortran subroutines designed and marketed by BUSS
Ltd.1 to produce pictures of data with speed and accuracy. The basic SIMPLEPLOT
library offers a wide range of facilities for drawing Cartesian and polar graphs.
Extensions are available for contouring and surface pictures, presentation graphics for
high quality output and representations of 4D data.
ClearWin+ provides access to SIMPLEPLOT via a dynamic link library (simple.dll)
that is distributed with Salford compilers. Access to this library is available by using
the fX]X^/ function together with the %pl format code. %pl is designed to be similar
to %gr.
In this chapter we shall look at three elementary programs that illustrate the essential
features of the interface between ClearWin+ and SIMPLEPLOT. The first two
examples illustrate an automatic mode of access. This is by far the easiest way to
access the SIMPLEPLOT library from ClearWin+. The final example shows you how
to make direct calls to the SIMPLEPLOT library. Further information about
SIMPLEPLOT can be found in the documentation provided by BUSS Ltd.
181
ClearWin+ User’s Guide Fortran
A simple example
In our first example we create a window and draw a quadratic curve within it.
RBX\_[T U^a
F8=0??
8=C464A =fX]X^/X
?0A0<4C4A=,
A40;' g=h=
R2aTPcT cWT SPcP c^ QT _[^ccTS
3> X, =
gX,X
hX,gX!
4=33>
R?[^c cWT SPcP
X,fX]X^/RPJB8<?;4?;>C@dPSaPcXRLQVJVaThL
X,fX]X^/_[JgNPaaPhL#!$=gh
X,fX]X^/UU][R]ccJ>:L
4=3
182
Chapter 17 SIMPLEPLOT
%pl options
The following options are available for use with %pl in automatic mode:
Option Description
SCALE=LINEAR Specifies a Cartesian plot with linear x and y data. This
is the default.
SCALE=LOG_LINEAR Specifies a Cartesian plot with linear x and log y data.
SCALE=LINEAR_LOG Specifies a Cartesian plot with log x and linear y data.
SCALE=LOG_LOG Specifies a Cartesian plot with log x and log y data.
N_GRAPHS=<n> Specifies the number of graphs to be drawn on the same
axes (the default is N_GRAPHS=1)
X_AXIS=<text> Specifies text for x-axis label (the default is X_AXIS=X)
Y_AXIS=<text> Specifies text for y-axis label (the default is Y_AXIS=Y)
TITLE=<text> Specifies the title for graph (by default there is no title).
X_ARRAY Specifies that an array of x values is supplied. If this
option is not specified then the first x value together with
a constant increment must be supplied.
Y_MIN=<value> Specifies the minimum y value. By default this is
computed from the data.
Y_MAX=<value> Specifies the maximum Y value. By default this is
computed from the data.
COLOUR=<name> Specifies the colour of the plot (red, black, blue, etc.).
The first use of COLOUR refers to the first plot, the
second to the second plot and so on.
183
ClearWin+ User’s Guide Fortran
Note that where text is supplied for the label of an axis or for the title, this text is
terminated by the next comma, space or square bracket. In order to include commas,
spaces or square brackets in the text you should enclose it in single or double
quotation marks.
Here is a fragment of code that shows how to plot two graphs on one set of axes.
X,fX]X^/_[JGN0G8B,CX\T<X[XbTR^]SbHN0G8B,0\_[XcdST
C8C;4,BP\_[T=N6A0?7B,!2>;>DA,aTS2>;>DA,Q[dTGN0AA0HL
""=gPaahPaa hPaa!
184
Chapter 17 SIMPLEPLOT
There is one x-array for the two y-arrays. The first graph would be red in colour and
the second blue.
Note that the arrays of data supplied to %pl usually need to be available for as long as
the window is displayed. In particular, the data will be re-plotted if the window is re-
sized. It is also possible to call the routine bX\_[T_[^cNaTSaPf/ to force all such
plots to be re-drawn using whatever values are currently present in the arrays.
bX\_[T_[^cNaTSaPf/ is a subroutine that takes no arguments.
185
ClearWin+ User’s Guide Fortran
186
Chapter 17 SIMPLEPLOT
187
ClearWin+ User’s Guide Fortran
188
18.
Introduction
One of the advantages of the Windows operating system is its built-in support for a
wide range of printers. ClearWin+ caters for three different types of printer output:
• Simple text output to the printer.
• HTML text output.
• Graphics output.
Before you can send output to the printer it is usually necessary to prompt the user to
select the printer to use (this also gives users the opportunity to cancel the print
request). There are several methods to obtain this information each of which is
described below.
The resolution of a printer varies from one machine to another, but typically printers
offer a much finer resolution than even a high quality graphics driver. This means
that screen images must be re-drawn for a printer after determining the resolution of
the printer selected by the user. If you are using bitmap images as part of your printer
output, you may need to use a higher resolution image on the printer than on the
screen.
If you send simple text to the printer it will look rather plain because a single font will
be used. However, this is sometimes useful for debugging purposes. It is almost as
easy to send HTML output to the printer, and this is the recommended method for
producing professional printed output from ClearWin+.
For printed output using OpenGL see page 179.
189
ClearWin+ User’s Guide Fortran
Selecting a printer
Using a standard call-back function
In most Windows applications, such as Word for Windows, a standard printer dialog
box is produced in response to a user button press or menu activation. Several
ClearWin+ standard call-back functions are supplied to perform this task, each of
which takes another call-back as an additional argument. The standard printer dialog
is automatically displayed and the call-back will contain your code to write or draw to
the printer. This call-back will only be called if the user selects a printer from the
dialog (as opposed to pressing the Cancel button).
For example, here is a program that will respond to the button press by prompting the
user for a printer and printing ‘Hello’.
4GC4A=0; _aX]cTa
X,fX]X^/³?aTbb cWXb Qdcc^] c^ _aX]c P _PVT) ³
X,fX]X^/³MQcJ?aX]cL´´?A8=C4AN>?4=´&_aX]cTa
X,fX]X^/³!][R]QcJ>:L´
4=3
R
8=C464A 5D=2C8>= _aX]cTa
190
Chapter 18 Using the printer
FA8C4&´7T[[^´
2;>B4&
_aX]cTa,!
4=3
Notice that the unit is closed before the call-back function exits. Typically, the call-
back function should return a value of 2 to indicate that the associated window should
stay open without a screen update. However, other call-back return values may be
used as described on page 205.
Using the 7C<;N?A8=C4AN>?4= or 7C<;N?A8=C4AN>?4= standard call-backs it is
easy to generate pleasantly formatted text output to the printer. This mechanism uses
the same subset of HTML as that used by %ht except that one mark-up <PB> is added
to set a page break.. Here is a simple example:
F8=0??
8=C464A XfX]X^/
4GC4A=0; cTbc
X,fX]X^/bR7C<;N?A8=C4AN>?4=&cTbc
4=3
R
8=C464A 5D=2C8>= cTbc
FA8C4&P+W -CWT ^dc_dc+W -
FA8C4&PCWXb Xb +X-8cP[XR+X-+_-
FA8C4&P0]S cWXb Xb +Q-1^[S+Q-+_-
2;>B4&
cTbc,!
4=3
Under Win16, it is necessary to call 8=8CN?A8=C4AN7C<;/.
The standard call-backs 6?A8=C4AN>?4= and 6?A8=C4AN>?4= do not connect the
printer to a Fortran unit number, but rather they create a drawing surface that
becomes the current drawing surface. The call-back that is an additional argument to
these standard call-backs is used to draw to this surface. The current drawing surface
reverts to the previous surface (if any) at the end of the call-back. An example is
given on page 194.
191
ClearWin+ User’s Guide Fortran
Each of these functions returns zero if the user cancels the operation, and each takes a
handle argument as input that is used to switch between drawing surfaces using
bT[TRcNVaP_WXRbN^QYTRc/. An example is given on page 195.
192
Chapter 18 Using the printer
193
ClearWin+ User’s Guide Fortran
At most one of A5, A6, A8 should be set non-zero, as they select mutually exclusive
options. These defaults work for both built in call-backs and explicit routine calls.
Four other R[TPafX]NX]U^/ parameters are also used to control the initial
appearance of the printer dialog box. These parameters are set using
bTcNR[TPafX]NX]U^/. The parameters are:
?A8=C4AN3450D;CN<8=N?064
?A8=C4AN3450D;CN<0GN?064
?A8=C4AN3450D;CN5A><N?064
?A8=C4AN3450D;CNC>N?064
In some situations it may be necessary to set these parameters in a multiple call-back,
for example:
X,fX]X^/MQcJ?aX]cLbTcN_aX]cTaNX]U^?A8=C4AN>?4=
where bTcN_aX]cTaNX]U^ is a user-defined function that makes appropriate calls to
bTcNR[TPafX]NX]U^/.
Printer graphics
Here is a simple program that uses the standard call-back 6?A8=C4AN>?4= to repond
to a button press and draws a diagonal line across the entire page. 6?A8=C4AN>?4=
creates a drawing surface and an additional call-back argument is used to to contain
code to draw to this surface.
F8=0??
8=C464A XfX]X^/
4GC4A=0; cTbc
X,fX]X^/MQcJ>_T]L6?A8=C4AN>?4=cTbc
4=3
R
8=C464A 5D=2C8>= cTbc
8=2;D34 +fX]S^fbX]b-
8=C464A g\Pgh\Pg
20;; VTcNVaP_WXRP[NaTb^[dcX^]/g\Pgh\Pg
20;; SaPfN[X]TNQTcfTT]/g\Pg h\Pg $
cTbc,!
4=3
Notice that the call to VTcNVaP_WXRP[NaTb^[dcX^]/ will work for all types of
drawing surfaces. This means that the same code can be used to generate graphics
output to the screen and to the printer.
194
Chapter 18 Using the printer
195
ClearWin+ User’s Guide Fortran
bRP[X]V,
R 6XeT XS ]d\QTab c^ cWT bRaTT] P]S _aX]cTa
bRaTT]NXS,
_aX]cTaNXS,!
R
X,fX]X^/³ffRPJBP[U^aS VaP_WXRbL´
X,fX]X^/OVaJQ[PRZL´%##'bRaTT]NXS
X,fX]X^/³OQcJ>:L[ffR
20;; VaP_WXRb
20;; VTcNVaP_WXRP[NaTb^[dcX^]/bRaTT]NfXScW
bRaTT]NWTXVWc
R BT[TRc _aX]cTa P]S bcPac S^Rd\T]c
aTb,^_T]N_aX]cTa/_aX]cTaNXS
85aTb=4C74=
20;; dbTNaVQNR^[^dab/_aX]cTaNXScadT
20;; VTcNVaP_WXRP[NaTb^[dcX^]/_aX]cTaNfXScW
_aX]cTaNWTXVWc
R BRP[X]V UPRc^a U^a _aX]cTa
bRP[X]V,_aX]cTaNfXScWbRaTT]NfXScW
R >_T] \TcPUX[T c^ aTR^aS _aX]cTa SaPfX]V
20;; ^_T]N\TcPUX[T/_aX]cTaNXS
20;; VaP_WXRb
]R^_XTb,R[TPafX]NX]U^/_aX]cTaNR^_XTb
R Bc^_ aTR^aSX]V
20;; R[^bTN\TcPUX[T/_aX]cTaNXS
]R^_XTb,]R^_XTb
R <PZT R^_XTb ^U cWT _PVT
20;; S^NR^_XTb/_aX]cTaNXS]R^_XTb
R ?aX]c S^Rd\T]c
aTb,R[^bTN_aX]cTa/_aX]cTaNXS
20;; bT[TRcNVaP_WXRbN^QYTRc/bRaTT]NXS
bRP[X]V,
4=385
4=3
BD1A>DC8=4 VaP_WXRb
8=2;D34 +fX]S^fbX]b-
8=C464A g h
8=C464A W_^[igPgQTaa
A40; bRP[X]V
8=C464A bRaTT]NXS_aX]cTaNXS
2><<>= bRP[X]VbRaTT]NXS_aX]cTaNXS
20;; bTcN[X]TNfXScW/"
R BT[TRc U^]c
196
Chapter 18 Using the printer
197
ClearWin+ User’s Guide Fortran
198
19.
Hypertext windows
Hypertext %N.Mht
Most programmers and many users will be familiar with the use of Web Browsers
such as Internet Explorer. Such browsers display information that has been encoded
as ASCII files containing Hypertext Markup Language (HTML). A subset of HTML
forms the basis for ClearWin+ hypertext windows.
Hypertext windows provide a way of building very easy to use GUI applications. A
hypertext window contains text with hypertext links, that enable users to switch
between pages (by clicking on highlighted text and images) or to initiate parts of your
program. A hypertext window is created using %ht and can be surrounded by other
controls as required.
For example, the format %70.20ht[introduction] would create a hypertext window of a
width sufficient to display 70 average width characters and 20 rows. The text would
be supplied by a prior call to PSSNWh_TacTgcNaTb^daRT/ with the name of a
hypertext resource, say ‘start’, containing the required initial topic called
‘introduction’. This would be defined as a resource thus:
bcPac 7H?4AC4GC \hUX[TWc\
You must use the Salford resource compiler SRC for hypertext files, rather than the
Microsoft compiler RC. By default, SRC is automatically invoked when a program
containing the WINAPP directive is compiled.
The file called browse.htm, that is built into the ClearWin+ browser program, is
available as an example program and is an excellent illustration of a hypertext file.
Note that hypertext resources are stored in a compressed format, which is not
accessible to your users if they choose to binary edit your program file.
199
ClearWin+ User’s Guide Fortran
The HTML text is displayed in the window that is both left and right justified with
scroll bars if necessary. The %ht format may be preceded by a pivot format (%pv) so
that the text area changes size as the window is adjusted by the user.
Mark-up codes are contained within diamond brackets < >. For example, a paragraph
end is marked using <P>. Mark-up codes are case insensitive. Some codes define a
condition that pertains until cancelled by a corresponding mark-up starting with a ‘/’
character. For example, bold face text is preceded by <B> and followed by </B>.
Special characters (such as the diamond brackets used to define mark-up codes) are
encoded as follows:
200
Chapter 19 Hypertext windows
201
ClearWin+ User’s Guide Fortran
202
Chapter 19 Hypertext windows
2DAA4=CNC4GCN8C4<
2DAA4=CNC4GCN3>2D<4=C
2DAA4=CNC4GCNC8C;4
Equation character strings, that follow the rules for %eq (see page 100), may also be
used in hypertext documents. Equation strings are embedded between <equation>
and </equation>. The string between these delimiters is treated as a pure equation -
no mark-up codes are recognized in this context. So, for example, the ‘<’ symbol
should be written as it is.
Conditional Hypertext
The ClearWin+ BROWSER program uses conditional hypertext to display different
information depending on the programming language selected.
For example:
Call the <if Fortran> WINIO@ <else> winio </if> function to display a window.
This uses an named integer parameter with the name ‘Fortran’, set up using the
bTcNR[TPafX]NX]U^/ function. The <if> clause is selected if the parameter is non-
zero. The <else> clause is optional. Conditional constructs can be nested, and may
contain arbitrary amounts of other mark-up codes and text.
If a call-back function changes the value of a parameter referenced in a conditional
construction, it should either return 1 (to cause all controls in the window to be
updated) or use fX]S^fNd_SPcT/ to ensure that the hypertext is updated.
To get a working example of the use of this format code, open the browse.htm file and
the associated program browse.cpp.
For example:
F8=0?? ³aTb^daRTaR´
R >][h RP[[ cWT ]Tgc [X]T ^]RT
20;; PSSNWh_TacTgcNaTb^daRT/³Wh_TaWT[_´
X,fX]X^/³RPJ7h_TacTgc WT[_ bhbcT\L´
X,fX]X^/³ffQVJVaThL_e´
X,fX]X^/³M%!!WcJ8]ca^SdRcX^]L´RP[[QPRZ
Where resource.rc contains:
Wh_TaWT[_ 7H?4AC4GC ³WT[_UX[TWc\´
A summary of ClearWin+ hypertext functions is given on page 325. Details can be
found in Chapter 27.
203
ClearWin+ User’s Guide Fortran
204
20.
205
ClearWin+ User’s Guide Fortran
ABOUT
This takes one character string argument (which may include newline characters) and
displays a simple “about” box. Each line of the text is centred, and an OK button is
supplied for the user to close the box.
BEEP[sound option]
If you require a button to make a (Windows) beep sound this call-back will provide a
quick and simple way of doing so. It may be most useful when used in conjunction
with the call-back joiner ³+´. It takes one of the following five possible arguments:
J4G2;0<0C8>=L
J@D4BC8>=L
J70=3L
J<1>:L
J0BC4A8B:L
These correspond to the warning icons built into Windows (see page 78).
For example:
X,fX]X^/ MQcJ?A4BBL 144?J<1>:L RQN^_T]UX[T
CASCADE
If this function is invoked from a window containing a MDI frame (%fr). The child
windows created with %aw are cascaded leaving the active window at the top.
CONFIRM_EXIT
This call-back function takes one character string argument and displays it as a yes/no
question. It is designed to be used with a button or menu option that will exit a
window. If the user responds yes, the function returns zero, thus closing the window
with the return number of the original button. If the user responds no (the default
response) the window remains open.
206
Chapter 20 Standard call-back functions
Menu items and buttons attached to these callback functions are greyed according to
circumstances. For example, a control associated with the 2DC function would be
greyed if no text were currently marked as selected on the screen. However, if the
control has a grey control variable then this variable takes precedence.
Apart from %eb, standard accelerator keys (Ctrl+C, Ctrl+X, and Ctrl+V) can also be
used for 2>?H, 2DC and ?0BC4.
CONTINUE
This function returns a non-zero value which therefore leaves the window open. It is
used as a dummy when no action is required.
EDIT_FILE_OPEN
This standard call-back is used with %eb and takes a character string argument
containing a file pattern (e.g. '*.TXT'). A second character string argument (called
fname say) is required for the resultant file name (of size 129). A standard Windows
‘file open’ dialog is displayed and the resultant file is written to fname. The file is
then displayed in a %eb edit box that is included in the current format window,
replacing any text already there. This standard call-back must only be used in a
format window containing one and only one %eb edit box. The corresponding edit
box is usually supplied with a buffer length of zero when it is set up, so that the system
allocates the buffer and adjusts its size as necessary. An example program appears on
page 212.
EDIT_FILE
This is used with %eb and takes one character string argument that is the file name of
the file to be opened. Unlike 438CN58;4N>?4=, the standard Windows ‘file open’
dialog is not presented.
EDIT_FILE_SAVE, EDIT_FILE_SAVE_AS
These call-back functions operate on a %eb edit box in same same manner as
438CN58;4N>?4=. If an edit box has not been filled using 438CN58;4N>?4=
438CN58;4NB0E4 operates like 438CN58;4NB0E4N0B and displays the standard
‘file save’ dialog. Each call-back takes two character string arguments: one for the
file pattern and the other for the resultant file name (see 438CN58;4N>?4= above).
The contents of the edit box are written to the file but the edit box is not closed. An
example program appears on page 212.
207
ClearWin+ User’s Guide Fortran
EXIT
This closes the window. If a window closure call-back (%cc) has been specified, the
%cc call-back is called before the closure takes place.
DEC
This takes one 8=C464A variable as an argument and subtracts 1 from the variable
each time 342 is called. Any controls that use this variable are automatically updated.
FATAL
The 50C0; call-back terminates the program at once without performing any of the
normal cleanup activities. Typically this is attached to the OK button in a window
that displays a fatal error condition. Use this only if the program is likely to be
corrupt and where performing a normal cleanup might hang the system.
FILE_OPENR[caption]
58;4N>?4=A is used to display the standard Windows ‘file open’ dialog. It takes a
character string argument which is a buffer to receive the file name selected by the
user from the dialog. Initially this buffer must be preset to be either blank or have the
form ‘*.abc’ otherwise the behaviour of 58;4N>?4=A is indeterminate. A call-back
function should follow the buffer in the argument list. This call-back is called if the
user selects a file (as opposed to pressing cancel, etc.).
For example:
4GC4A=0; RQ
8=C464A RQ
270A02C4A !( bcaNUX[T
bcaNUX[T,³ ³
X,fX]X^/³MQcJ>_T] UX[TL´ ³58;4N>?4=AJ>_T]L´ bcaNUX[T RQ
The value returned to the calling fX]X^/ is the return value of this call-back function,
or 1 if no file is selected (so that the underlying window is kept open). By default (if
the file name string is initially blank) the file selection box starts by displaying all files
from the current directory. However, this and several other default actions of
58;4N>?4=A can be modified by the prior use of the %fs and %ft formats or by
setting the file name string to the form ‘*.abc’ before the call. For an example of the
use of the 58;4N>?4=A and ±² call-back functions see the description of the %aw
format on page 123. See also %fs and %ft on page 105.
208
Chapter 20 Standard call-back functions
FILE_OPENW[caption]
58;4N>?4=F is analogous to 58;4N>?4=A but allows the user to type in a new file
name, since it is assumed that the file is required for writing.
GPRINTER_OPEN
6?A8=C4AN>?4= is used to produce output on a graphics printer or plotter. It
operates in a manner similar to ?A8=C4AN>?4=. However, 6?A8=C4AN>?4= takes
only one argument which is a call-back function supplied in the program. This call-
back function will use drawing surface routines to produce the graphics output (see
Chapter 15).
Note that graphics printing and plotting can also be carried out using
^_T]N_aX]cTa/ (see page 382).
HELP_CONTENTS
74;?N2>=C4=CB takes one character string argument giving the full path name of a
help file (.HLP). The file is opened at its contents page. When the main window
closes, the help window will also be closed if it has been left open.
HELP_ON_HELP
74;?N>=N74;? provides the standard help-on-help information. This also takes a
character string argument giving the name of a help file.
HTML_PRINTER_OPEN
7C<;N?A8=C4AN>?4= provides for the output of text with embedded HTML
markups. See page 191 for further details.
INC
8=2 takes one 8=C464A variable as an argument and adds 1 to this variable each time
8=2 is called. Any controls that use this variable are automatically updated.
209
ClearWin+ User’s Guide Fortran
INTERNET_HYPERLINK
8=C4A=4CN7H?4A;8=: takes one 270A02C4A string argument which is the full
URL of a file on the web. For example:
X,fX]X^/MQcJBP[U^aSL8=C4A=4CN7H?4A;8=:
Wcc_)fffbP[U^aSR^dZ
See also DB4NDA;/.
PRINT_ABORT
?A8=CN01>AC is used to cancel a print job whilst it is being spooled.
PRINTER_OPEN
?A8=C4AN>?4= displays the standard Windows ‘Print’ dialog that enables the user to
select a printer. The function takes two arguments. The first is an integer that is the
Fortran unit number on which to open the printer. The second argument is a call-back
function supplied in the program. If the printer is successfully selected, the call-back
function is called. (The value returned by the call-back becomes the value returned by
the enclosing fX]X^/. Hence, a return value of 1, for example, has the effect of
keeping the parent window open). If no printer is selected, ?A8=C4AN>?4= returns 1
to keep the window open. The call-back function should perform print operations
using standard Fortran output statements (for example, FA8C4) on the specified unit
number. It is necessary to 2;>B4 the unit number in order to dispatch the output to
the printer.
PRINTER_OPEN1
?A8=C4AN>?4= has the same purpose and takes the same arguments as
?A8=C4AN>?4= but does not display the standard Windows ‘Print’ dialog. Instead it
uses the default printer or the printer that was selected in an ealier call to
?A8=C4AN>?4=.
PRINTER_SELECT
?A8=C4ANB4;42C displays the standard Windows ‘Print’ dialog and is used in
with the standard call-back >?4=N?A8=C4A
conjunction or the routine
^_T]N_aX]cTa /.
210
Chapter 20 Standard call-back functions
SELECT_ALL
B4;42CN0;; has no arguments and selects all of the text in the current %eb edit box.
SET
The B4C call-back takes two arguments each of type 8=C464A. When the call-back is
called, the first argument is set to the value of the second at the time when fX]X^/ is
called. B4C returns the value 1 so that any necessary updates take place. Here is an
example.
F8=0??
8=C464A effX]X^/gRca[
e,
g,
f,fX]X^/OR]MccJBTcLB4Ceg
f,fX]X^/!][#aSe
f,fX]X^/[fRca[
g,!
4=3
The variable v is initially zero and tekes the value 1 (rather than 2) when the button is
clicked.
SOUND
If you require a sound that is not one of the standard system sounds (see 144? above)
and a sound card is installed, you can include small sound samples previously stored
in standard wave file format (.WAV). The wave file must be included in a resource
script or in the resource section of the program. For example:
<hB^d]S B>D=3 S^V]^XbTfPe
The following code illustrates how the sample is played back.
X,fX]X^/³MQcJ1PaZL³ ³B>D=3´ ³<hB^d]S´
STOP
This call-back function closes the window and terminates the program.
SUPER_MAXIMISE
The BD?4AN<0G8<8B4 (the spelling BD?4AN<0G8<8I4 also accepted) call-back is
used to expand a window so that only the client area is visible. This is useful to
211
ClearWin+ User’s Guide Fortran
enable a graphic display to be shown on the entire screen. Programs that use this call-
back should provide an accelerator key or other means to exit from this mode (there
will be no standard or system menu visible).
TEXT
The C4GC call-back can only be invoked from a format window that uses %ht. It
provides a quick way of displaying text in a window. The text itself is provided in a
character string that is placed in the fX]X^/ argument list after this call-back.
TEXT_HISTORY
The C4GCN78BC>AH call-back can only be invoked from a format window that
includes %ht. A dialog box is displayed that shows the hypertext history and allows
the user to select an earlier topic.
TOGGLE
The C>66;4 call-back is used to toggle an 8=C464A variable between 0 and 1. The
variable follows the call-back in the fX]X^/ argument list.
+
Sometimes it is useful to invoke more than one call-back function at once. The ±²
call-back function takes two subsequent call-back functions as arguments and calls
each in turn. The return value from the ±² call-back function is the return from the
second call. For an example of the use of the ±² and 58;4N>?4=A call-back
functions see the description of %aw on page 123. Note that the result of
R[TPafX]NbcaX]V/³20;;102:NA40B>=´ reflects the original reason for the
call-back and not ±².
212
Chapter 20 Standard call-back functions
X,fX]X^/\]JJBPeTLL 438CN58;4NB0E4]TfNUX[T
X,fX]X^/\]JJBPeT 0bLL438CN58;4NB0E4N0B]TfNUX[T
X,fX]X^/\]JJ4gXcLL 4G8C
X,fX]X^/\]J4SXcJ2^_hLL2>?H
X,fX]X^/\]JJ2dcLL 2DC
X,fX]X^/\]JJ?PbcTLL ?0BC4
X,fX]X^/\]J7T[_J2^]cT]cbLL74;?N2>=C4=CBWT[_NUX[T
X,fX]X^/\]JJ7T[_ ^] WT[_LL 74;?N>=N74;? WT[_NUX[T
X,fX]X^/%!TQ
4=3
213
ClearWin+ User’s Guide Fortran
214
21.
This chapter provides a detailed reference to format codes that can be used with
fX]X^/. New features are continuously being added to ClearWin+, details of which
can be found in the enhancements files on the distribution disks.
An introduction to format windows and the fX]X^/ function is presented on page 22.
It includes general information about format strings and the form of a format code;
about format modifiers, option lists, standard character strings, and help strings. It
also describes the general order in which components appear in the format string and
in the fX]X^/ argument list. Please note that lowercase n and m are used to represent
optional size modifiers, whilst uppercase N and M denote mandatory size modifiers
(e.g. %br).
%ac
Purpose To define an accelerator key.
Syntax fX]X^/³PRJZThNSTbRaX_cX^]L´RQNUd]R
TgcTa]P[ RQNUd]R
Description key_description is a standard character string (can be replaced by @ and a F8=8>/
argument) that may include key words of the form: Rca[, bWXUc, P[c, TbR, ST[, X]b,
b_PRT, QPRZb_PRT, T]cTa, [TUc, aXVWc, d_, S^f], _Vd_, _VS], cPQ, W^\T, T]S,
ZTh_PSNRT]caT, U U !. Character keys must be combined with one or more of
Rca[, bWXUc and P[c, but the forms Rca[P[ccharacter are reserved for use by
the system.
Example fX]X^/³PRJ2ca[BWXUc3T[L´RQNUd]R
215
ClearWin+ User’s Guide Fortran
%ap
Purpose To set the absolute position of the next control.
%aw
Purpose To attach a MDI child to a parent window.
216
Chapter 21 Format code reference
Notes a) The system menu will contain Ctrl-F4 to close a child window (as opposed to the
parent window), and Ctrl-F6 to move to the next MDI child.
b) As additional children are added to a frame these windows are offset with respect to
the origin to make all windows visible. This offset is not reset to zero when all the
children in a frame are closed.
c) If the standard call-back function 20B2034 is invoked from a window
containing a MDI frame, this will cascade the child windows with the active
window left at the top.
%bc
Purpose To specify the colour of the next %bt button.
Syntax fX]X^/³QRJR^[^daL´
fX]X^/³QR´ R^[^daNeP[dT
X]cTVTa R^[^daNeP[dT X]_dc
Modifiers Grave accent (`) - allows colour_value to be changed dynamically.
Description colour is one of: Q[PRZ, fWXcT, VaTh, aTS, VaTT], Q[dT, and hT[[^f.
Alternatively one of the additional named colours listed for %bg can be used.
colour_value is typically a value returned by A61/. If the grave accent is used, this
value can be changed after the button has been displayed. colour_value is then passed
to fX]S^fNd_SPcT/ in order to update the screen.
217
ClearWin+ User’s Guide Fortran
%bd
Purpose To specify all four window borders individually.
%bf
Purpose To switch to bold font.
Syntax fX]X^/³QU´
Modifiers Grave accent (`) - use the grave to switch off.
Description %bf is cancelled by %`bf, %fn and %sf.
%bg
Purpose Background colour format.
Syntax fX]X^/³QVJR^[^daL´
fX]X^/³QV´ R^[^daNeP[dT
X]cTVTa R^[^daNeP[dT X]_dc
Modifiers Grave accent (`) - set the colour of the next control.
Description colour is one of: Q[PRZ, fWXcT, VaTh, aTS, VaTT], Q[dT, and hT[[^f.
Alternatively one of the following additional named system colours can be used:
bRa^[[QPa, QPRZVa^d]S, PRcXeTRP_cX^], X]PRcXeTRP_cX^], \T]d, fX]S^f
(use this for the default window background), fX]S^fUaP\T, \T]dcTgc,
218
Chapter 21 Format code reference
%bh
Purpose To provide a bubble help system.
Syntax fX]X^/³QW´Rca[
X]cTVTa Rca[ X]_dc
Modifiers Grave accent (`) - introduces a delay before the message appears.
Description Set ctrl to 1 in order to enable help messages and to 0 in order to disable messages.
%bi
Purpose To supply an icon for the next button.
Syntax fX]X^/³QXJXR^]N]P\TL´
219
ClearWin+ User’s Guide Fortran
Description icon_name is a standard character string (can be replaced by @) that provides a name
appearing in a resource script.
Notes icon_name can contructed from a known Windows handle (see page 79).
Example fX]X^/³QXJ\hXR^]L´
\hXR^] 82>= UX[TXR^ aTb^daRT UX[T
See also %ic
%bk
Purpose To allow a right mouse click to be used on the next %bt button.
Syntax fX]X^/³QZ´
Description %bk can be used before %^bt with the result that the associated call-back function is
also called with a right mouse click. To differentiate between right and left mouse
button clicks use R[TPafX]NbcaX]V/20;;102:NA40B>=.
%bm
Purpose To draw a bitmap.
Syntax fX]X^/³Q\JQXc\P_N]P\TL´
fX]X^/³OQ\´ WP]S[T
X]cTVTa WP]S[T X]_dc
Modifiers Grave accent (`) - use a Windows API bitmap handle.
Caret (^) - the call-back is called when the user clicks on the bitmap.
Question mark (?) - a help string is supplied.
Description bitmap_name is standard character string (can be replaced by the @ symbol) giving
the name appearing in a resource script.
handle is a value returned by a modified form of the API function LoadBitmap.
Example fX]X^/³Q\J\hQXc\P_L´
\hQXc\P_ 18C<0? UX[TQ\_ aTb^daRT UX[T
220
Chapter 21 Format code reference
%br
Purpose To draw a horizontal or vertical bar which is partially filled with a user-selected
colour.
%bt
Purpose To insert a standard button.
Syntax fX]X^/³]QcJQdcc^]NcTgcL´
fX]X^/³m]QcJQdcc^]NcTgcL´ VaThNRca[
X]cTVTa VaThNRca[ X]_dc
Modifiers Tilde (~) - used to add a grey control.
Grave accent (`) - used to make this the default button (one for each dialog).
Caret (^) - the call-back function is called when the user clicks on the button.
Question mark (?) - a help string is supplied.
221
ClearWin+ User’s Guide Fortran
Description n is an optional positive integer which is used to specify the width of the button.
grey_ctrl is set to 1 to enable the button and 0 to disable (grey) it.
button_text is a standard character string (can be replaced by @) and can include an
ampersand (&) to mark an accelerator key. To change the text dynamically use %lc
and the API function SetWindowText.
The background colour can be specified using %bc and the text font and size can be
specified using %fn and %ts. Other effects can be obtained by using %lc.
%bv
Purpose To insert a hierarchical tree.
Syntax fX]X^/QeJ^_cX^]bLfXScWWTXVWcXcT\b]d\NXcT\bbT[
fX]X^/OQeJ^_cX^]bLfXScWWTXVWcXcT\b]d\NXcT\bbT[
Q\_Nbca
RWPaPRcTa XcT\b]d\NXcT\b X]_dc^dc_dc
X]cTVTa ]d\NXcT\b X]_dc _PaP\TcTa
X]cTVTa bT[ X]_dc^dc_dc
X]cTVTa fXScWWTXVWc X]_dc
RWPaPRcTa Q\_Nbca X]_dc
Modifiers Grave accent (`) - used to provide a list of bitmaps.
Caret (^) - call-back function is provided.
Question mark (?) - a help string is supplied.
Description %bv (branch view) provides a tree view that is similar in some respects to %tv but the
%bv control has a different appearance and %bv has more options. It also shares
commom features with %lv.
width and height provide the dimensions of the control in pixels.
num_items is an integer constant giving the number of nodes in the tree. Nodes with
blank data are not displayed in the control. This means that the number of nodes that
are displayed can be changed under program control.
items is an array of num_items character strings, each string describing a node in turn
222
Chapter 21 Format code reference
Label editing
TSXcN[PQT[b enables label editing and requires a call-back function that can test for
the call-back reasons 1468=N438C, 4=3N438C and 438CN:4HN3>F=.
With 1468=N438C you can get the index of the selected node by the call
223
ClearWin+ User’s Guide Fortran
Call-back reasons
8C4<N4G?0=343 A node has been expanded or collapsed (see above).
1468=N438C A label is about to be edited (see above).
438CN:4HN3>F= The user has pressed a keyboard key during a label edit.
R[TPafX]NX]U^/:4H1>0A3N:4H provides the key
code (see above).
4=3N438C A label has been edited (see above).
B4CNB4;42C8>= A node has been selected.
R[TPafX]NX]U^/A>FN=D<14A provides the index.
<>DB4N3>D1;4N2;82: The user has double-clicked using the left mouse button.
R[TPafX]NX]U^/A>FN=D<14A provides the index.
:4HN3>F= The user has pressed a keyboard key.
R[TPafX]NX]U^/:4H1>0A3N:4H provides the key
code.
224
Chapter 21 Format code reference
%bx
Purpose To add a raised grey bar to a tool bar.
%ca
Purpose To provide a caption for the window or property sheet.
Syntax fX]X^/³RPJRP_cX^]L´
Modifiers Grave accent (`) - when used, the minimum width of the window is not limited by the
width of the caption and part of the caption may be hidden.
Description caption is a standard character string (can be replaced by @).
In order to change the caption dynamically use the @ symbol and follow a change in
the string variable by a call to fX]S^fNd_SPcT/. Alternatively use the API function
SetWindowText together with %hw.
When used with %sh in a property sheet, the caption can include an ampersand (&) to
mark an accelerator key.
225
ClearWin+ User’s Guide Fortran
%cb
Purpose To close a box that has been opened using %ob.
Syntax fX]X^/³RQ´
See also %ob
%cc
Purpose To control the closure of a window.
Syntax fX]X^/³RR´RQNUd]R
TgcTa]P[ RQNUd]R
Modifiers Grave accent (`) - the call-back is called after the window has closed rather than
before..
Description Provides a link to a call-back function by which the user controls the action to be taken
just before a window is closed. If a grave is used (%`cc) then the associated call-back
function is called immediately after the window is closed. You can use both %cc and
%`cc in one window.
%ch
Purpose Child window format - inserts a child window.
Syntax fX]X^/³RW´Rca[
X]cTVTa Rca[ X]_dc
Description ctrl is a handle returned by %`lw .
226
Chapter 21 Format code reference
%cl
Purpose To display a colour palette.
Syntax fX]X^/³R[J^_cX^]bL´R^[^daNeP[dTb
X]cTVTa R^[^daNeP[dTb" ^dc_dc
Description Up to three values can be returned from the resulting dialog box, the first for the left
mouse button, the next for the right button and the third for the middle button.
options may be one or more of:
Example fX]X^/³R[JQ"cXc[T!,?P[TccTL´R^[^daNeP[dTb
%cn
Purpose To centre text and controls in the window.
Syntax fX]X^/³R]´
Modifiers Grave accent (`) - extends the scope to the remainder of the window.
Description %cn is principally used on text and buttons. It forces everything which follows it, up
to the next new line or form-feed character, to be centred in the window.
When used within a box (%ob) the centring applies within that box.
227
ClearWin+ User’s Guide Fortran
%co
Purpose To modify subsequent %rd, %rf , %rs, %re, %el boxes.
Syntax fX]X^/³R^J^_cX^]bL´
Description options is a list containing one or two of:
Example fX]X^/³R^JRWTRZN^]NU^RdbN[^bbL´
See also %rd, %rf, %rs, %re, %el
%cu
Purpose Establishes a cursor for the next control in a format.
Syntax fX]X^/³RdJRdab^aN]P\TL´
fX]X^/³ORd´ R^]bc
X]cTVTa R^]bc X]_dc
fX]X^/³=RdJ]P\T LJ]P\T!L J]P\T=L´bT[
fX]X^/³O=Rd´ R^]bc R^]bc! R^]bc= bT[
X]cTVTa bT[ R^]bc R^]bc! R^]bc= X]_dc
Modifiers Grave accent (`) - cursor is specified by using a ClearWin+ parameter from
windows.ins.
Description cursor_name is a standard character string (can be replaced by @) that is used to
228
Chapter 21 Format code reference
If const is not one of these values then it is assumed to be a valid Windows API handle
of an existing cursor (cf. %bm and %ic).
Another pair of alternatives uses a positive integer N to provide a selection of N
different cursors. In this case the variable sel is given a value in the range 1 .. N in
order to specify a particular cursor. The examples below illustrate the first pair of
alternatives.
Example fX]X^/³RdJ\hRdab^aL´
\hRdab^a 2DAB>A UX[TRda aTb^daRT UX[T
fX]X^/³ORd´2DAB>AN8140<
See also %dc, bTcNRdab^aNfPXcX]V/
229
ClearWin+ User’s Guide Fortran
%cv
Purpose To set a control variable for a window.
Syntax fX]X^/³Re´Rca[
X]cTVTa Rca[ ^dc_dc
Description %cv has the same effect as %lw but does not leave the window open. The returned
value of ctrl can be used with %aw.
%cw
Purpose To insert a ClearWin window.
230
Chapter 21 Format code reference
%dc
Purpose Establishes a default cursor for the window.
Syntax fX]X^/³SRJRdab^aN]P\TL´
fX]X^/³OSR´ R^]bc
X]cTVTa R^]bc X]_dc
fX]X^/³=SRJ]P\T LJ]P\T!L J]P\T=L´bT[
fX]X^/³O=SR´ R^]bc R^]bc! R^]bc= bT[
X]cTVTa bT[ R^]bc R^]bc! R^]bc= X]_dc
Modifiers Grave accent (`) - cursor is specified by using a ClearWin+ parameter from
windows.ins.
Description cursor_name is a standard character string (can be replaced by @) used to identify a
cursor via a resource script.
The alternative uses a grave accent modifier together with const which is one of:
If const is not one of these values then it is assumed to be a valid Windows API handle
of an existing cursor (cf. %bm and %ic).
Another pair of alternatives uses a positive integer N to provide a selection of N
different cursors. In this case the variable sel is given a value in the range 1 .. N in
order to specify a particular cursor. It is not necessary to call fX]S^fNd_SPcT/ when
231
ClearWin+ User’s Guide Fortran
sel is changed. The examples below illustrate the first pair of alternatives.
Example fX]X^/³SRJ\hRdab^aL´
\hRdab^a 2DAB>A UX[TRda aTb^daRT UX[T
fX]X^/³OSR´2DAB>AN8140<
See also %cu
%dd
Purpose To insert a spin wheel for an integer edit box (%rd) or a string edit box (%rs).
Example fX]X^/³SS´ ;
See also %rd, %il, %rs
%de
Purpose To disable some other window while this window is active.
Syntax fX]X^/³ST´Wf]S
X]cTVTa Wf]S X]_dc
232
Chapter 21 Format code reference
Description %de is used to force some other window to be disabled while the current window is
active. This is the default behaviour for other ClearWin+ windows unless %ww is
used. This format is particularly useful in situations in which there are non
ClearWin+ windows present.
%df
Purpose To insert a spin wheel for a floating point value.
%dl
Purpose To set a call-back function to be called at regular intervals via a timer.
Syntax fX]X^/³S[´X]cTaeP[RQNUd]R
S^dQ[T _aTRXbX^] X]cTaeP[ X]_dc
TgcTa]P[ RQNUd]R
Description interval is the minimum time in seconds between calls. A call is made at idle time
(e.g. awaiting input) and when hXT[SN_a^VaP\NR^]ca^[/ is called. A given
window cannot have more than one timer.
233
ClearWin+ User’s Guide Fortran
%dr
Purpose To provide a call-back that is called when a file or a group of files is dragged and
dropped onto the window.
Syntax fX]X^/³Sa´RQNUd]R
TgcTa]P[ RQNUd]R
Description Use a call to R[TPafX]NbcaX]V/3A>??43N58;4 within the call-back in order
to get the name of the file that has been dropped. If there is more than one file then the
call-back function is called for each in turn. You can use
R[TPafX]NX]U^/3A>??43N2>D=C to get the number of files that have been
dropped (call this n say) and then use R[TPafX]NX]U^/3A>??43N2DAA4=C to
get the index of the current file in the range from 1 to n.
%dw
Purpose To insert an owner draw graphics box.
234
Chapter 21 Format code reference
%dy
Purpose To provide a vertical displacement by a non-integral number of character depth units.
Syntax fX]X^/³Sh´S
S^dQ[T _aTRXbX^] S X]_dc
Description %dy is used to force a vertical displacement by a possibly fractional number of
character depths. The displacement is calculated in terms of the initial font size,
regardless of any %ts formats that may have been used. The displacement can be
negative, but unlike %rp, the normal mechanism will operate to prevent two controls
overlapping, so %dy cannot be used to place a control over something else.
%eb
Purpose To insert an edit box.
235
ClearWin+ User’s Guide Fortran
N represents the width of the box in average characters. M represents the depth which,
if omitted, defaults to 1.
buffer is a character string for the text which must be terminated with chr(0).
buff_size is the size of the buffer. A zero value may be supplied to allow the edit box to
allocate its own memory re-sizing as required (buffer is ignored).
%eb will take a pivot (%pv).
If the caret modifier (^) is used and the call-back function does not handle the response
to control keys such as Delete, BackSpace, etc., then it should return a zero value.
%el
Purpose To insert an editable combo box.
Syntax fX]X^/³]\T[J^_cX^]L´XcT\b]d\NXcT\bRdaNXcT\
fX]X^/³m]\T[J^_cX^]L´XcT\b]d\NXcT\bRdaNXcT\VaThNRca[
RWPaPRcTa] XcT\b]d\NXcT\b X]_dc
X]cTVTa ]d\NXcT\b X]_dc _PaP\TcTa
RWPaPRcTa] RdaNXcT\ X]_dc^dc_dc
X]cTVTa VaThNRca[ X]_dc
Modifiers Caret (^) - call-back function is called when the user selects an item.
Question mark (?) - a help string is supplied.
Tilde (~) - adds a variable that controls the grey (enable/disable) state.
%co[RWTRZN^]NU^RdbN[^bb] can be used with %el.
Description This control is similar to %`ls but cur_item is a string for the current text rather than the
index of the selected item.
If a call-back is supplied, option can be set to the keyword TgcT]STS. The result is that
the call-back is called when the list drops down or closes up. These events must be
detected from the call-back by calling R[TPafX]NbcaX]V/ with the argument
³20;;102:NA40B>=´ which returns 3A>?3>F= or 2;>B4D?.
Using R[TPafX]NX]U^/ with the argument ³438C01;4N;8BC1>GN8=34G´ provides
the index of the listbox item that has been selected by the user. If this value is obtained
within the %el callback function then you may need to add the option TgcT]STS in
236
Chapter 21 Format code reference
order ot ensure that the callback function is called every time an item is selected.
See %ls for further details.
%eq
Purpose To insert a mathematical equation in a window.
%es
Purpose To cause the window to close when the Escape key is pressed.
Syntax fX]X^/³Tb´
Description This is equivalent to fX]X^/³PRJ4bRL´´4G8C´
237
ClearWin+ User’s Guide Fortran
%ew
Purpose To specify a call-back function to be called if the user shuts down the Windows session
(exit Windows) whilst the program is running.
Syntax fX]X^/³Tf´RQNUd]R
TgcTa]P[ RQNUd]R
Description The call-back function could be used to ask the user if results are to be saved before the
session ends, etc.. If the call-back function returns zero, the shutdown is allowed to
proceed. Any other value will abort the shutdown and leave the application running.
Note that if your program allows shutdown to proceed, other applications that are still
running may still elect to abort the shutdown.
%fb
Purpose To select a font for use with all subsequent buttons.
Syntax fX]X^/³UQ´
Description If %fn is used to select a font (optionally with %ts, %tc, %bf, %it and %ul) then
following this by %fb (with no arguments) will cause the font to be remembered for use
with all subsequent buttons unless and until %fb is used again.
%fd
Purpose To set the font to the default Windows 95 font (Windows 95/98 only).
Syntax fX]X^/³US´
See also %fn, %sf
238
Chapter 21 Format code reference
%ff
Purpose Form feed. To move down to below any existing controls.
Syntax fX]X^/³UU´
See also %nl, %ta, %ob
%fh
Purpose To use a Windows API font.
Syntax fX]X^/³UW´WP]S[T
X]cTVTa WP]S[T X]_dc
Description handle is the font handle of a font created by, for example, the Windows API function
CreateFont. %fh makes this the current font for the window.
%fl
Purpose To specify the lower and upper limits for subsequent %rf formats.
239
ClearWin+ User’s Guide Fortran
%fn
Purpose To select a font for subsequent text.
Syntax fX]X^/³U]JU^]cN]P\TL´
Description font_name is a standard character string (can be replaced by @) that provides the name
of a font that is in the user’s system.
%fn cancels %bf but not %it and %ul.
%fr
Purpose To define a MDI frame to contain child windows attached by %aw.
240
Chapter 21 Format code reference
%fs
Purpose To specify the working directory and file filter for subsequent file open/save call-backs.
Syntax fX]X^/³UbJ_PcWN]P\TL´
Description path_name is a standard character string (can be replaced by @) giving the current
working directory which optionally may include a wild-card. %fs cannot be used to
change the path dynamically at run time (use VTcNUX[cTaTSNUX[T/ instead).
Example fX]X^/³UbJR)K_a^YTRcKcgcL´
See also %ft, VTcNUX[cTaTSNUX[T/ bTcN^_T]NSXP[^VN_PcW/
%ft
Purpose To specify filter information for subsequent file open call-backs.
Syntax fX]X^/³UcJUX[cTaNch_TLJfX[SNRPaSL´
Modifiers Grave accent (`) - used to start again rather than add to earlier %ft information.
Description filter_type is the description of the type of file, wild_card represents the file extension
of the files to be listed in the standard file-open and file-save dialog boxes. filter_type
and wild_card are standard character strings (can be replaced by @) but %ft cannot be
used to change this information dynamically at run time (use VTcNUX[cTaTSNUX[T/
instead).
%ft can be used more than once to supply a number of different filters.
241
ClearWin+ User’s Guide Fortran
%ga
Purpose To enable radio buttons and/or bitmap buttons to be ganged together so that if one is
switched on, all the others are switched off.
Syntax fX]X^/³=VP´bcPcT bcPcT! bcPcT=
X]cTVTa bcPcT bcPcT! bcPcT= ^dc_dc
Modifiers Grave accent (`) - used to specify that one control is always on.
Description N is a positive integer greater than 1. state1 . . stateN are the on/off state controls for
radio buttons and/or bitmap buttons defined elsewhere. A given state variable can be
used in more than one control (%rb and/or %tb). However, it is unusual for a variable
to appear in more than one %ga format for a given window. If it does then there must
only be one variable that is common and the effect is to merge the two gang sets. If the
grave accent is used on one of the gangs then it must be used on both.
%gd
Purpose To supply a temporary grid to help with the positioning of controls.
Syntax fX]X^/³VS´
Description The grid is placed at positions corresponding to the units in %ap.
%gf
Purpose To get the handle of a font.
Syntax fX]X^/³VU´U^]cNWS[T
X]cTVTa U^]cNWS[T ^dc_dc
Description font_hdle is returned as the handle of the current font. This handle can be used in calls
to Windows API functions that need a font handle.
242
Chapter 21 Format code reference
%gi
Purpose To draw a (possibly animated/transparent) GIF image.
Syntax fX]X^/³VXJVXUN]P\TL´
Modifiers Caret (^) - the call-back is called when the user clicks on the image.
Question mark (?) - a help string is supplied.
Description gif_name is a name appearing in a resource script if type GIF. The resource compiler
stores such resources in a non-GIF format (for legal reasons). The GIF file can be
animated and/or partially transparent.
A call-back can be supplied to receive single and double clicks. The call-back function
can interrogate the R[TPafX]NX]U^/ parameters 685N<>DB4NG and 685N<>DB4NH
to determine where within the image the click occurred. This means that a medium to
large image can contain regions which respond in different ways to mouse clicks. Co-
ordinates are in pixels relative to the top left of the image. Note that if the GIF image
is displayed at another screen resolution, these pixel co-ordinates will consistently refer
to the same point in the image.
Example fX]X^/³VXJ\hNVXUL´
\hNVXU 685 UX[TVXU aTb^daRT UX[T
Notes A GIF file can contain more than one image frame, and each image can specify the
duration for which it is shown. Animations can be one-shot, repeated for a finite
number of times, or (most usefully) cycled indefinitely. Many image processing and
paint tools will create simple (non-animated) GIF files, and these can be assembled
into animated GIFs using a variety of tools, such as the Microsoft GIF Animator,
available from the Microsoft Web site. GIF files are commonly available on the
internet. MATHEMATICA can export graphics as GIF files.
A GIF image contains size information, so none is required with the format.
Hypertext (%ht) containing images normally refers to BITMAP resources.
However, if a particular named resource is not found as a bitmap, ClearWin+ will look
for the corresponding GIF resource. This means that GIFs (possibly
animated/transparent) can also be used in hypertext.
Animations require memory and processing time, so it might be unwise to use a large
and complex animation on a ‘please wait’ screen that is displayed while a lengthy
operation is being performed. Obviously, slower animations are less expensive than
rapid ones. Also, for the animation to be maintained, it is important that very lengthy
calculations are broken up with calls to cT\_^aPahNhXT[S/
One way to reduce the performance cost of many animations is to exploit the fact that
243
ClearWin+ User’s Guide Fortran
much of an image may remain the same from frame to frame. Consider for example
an animated ballot paper. It might be that only the region that contains the cross
would actually need to change. It is possible to assemble a GIF consisting of one full
image and a series of patches, which will obviously require less memory and
processing resources than the corresponding set of full images. If you decide to
proceed this way your program will remain unchanged, it will simply require more
work with the image processing tools.
On 16 or 256 colour systems, GIF images are displayed without the use of a palette.
This is to avoid some of the problems with Windows when two or more processes
compete for the use of the palette. GIF images are best viewed in a high colour mode.
If in doubt it is worth switching your screen to 256 colour mode to ensure that your
graphic looks acceptable. You can read the R[TPafX]NX]U^/ parameter,
B2A44=N=D<N2>;>DAB do determine what to do at run time.
GIF images may be used to provide fancy buttons that attract attention because of their
animation, to provide front cover screens for programs, and to add colour and interest.
Larger images can even be used as image maps by reading the click co-ordinates, as
explained above.
The GIF resources are decompressed by the resource compiler and recompressed by a
different method. This means that your executables and the DLL salflibc.dll do not
contain any code related to the processing of the GIF format. For this reason we have
not supplied any routines to enable you to export graphics to GIF files. However, if
you want to incorporate your graphics in animated GIFs this is still possible. Simply
create a series of still images as BMP files, convert them to GIFs using a shareware
image processing program, and assemble the result as an animated GIF.
%gp
Purpose To get the current co-ordinates of the window position.
Syntax fX]X^/³V_´ g h
X]cTVTa g h ^dc_dc
Modifiers Grave accent (`) - used only in conjunction with %aw in order to provide co-ordinates
that are relative to an enclosing MDI frame.
Description x and y are returned as the co-ordinates in pixels of the current position in the window
relative to the top left-hand corner (0,0) of the window. These values can be used with
%sp.
244
Chapter 21 Format code reference
%gr
Purpose To provide a rectangular area for use with drawing surface routines.
%he
Purpose To specify the location of help information.
Syntax fX]X^/³]\WT´
Description If %he, %bh and %th are not used, help information (obtained using the question mark
modifier with certain format codes) is placed at the bottom of the window. %he
specifies the current position as the required position for help information.
n and m are optional (m cannot be specified without n). m defaults to 1. They specify
the width and depth of the area to take the help string measured in average character
units.
245
ClearWin+ User’s Guide Fortran
%ht
Purpose To attach a hypertext document.
Syntax fX]X^/³=<WcJbcPacNc^_XRL´
Modifiers Caret (^) - called when a jump is made to a topic that does not exist.
Grave accent (`) - used to enable the given call-back function to be called every time a
topic is changed.
Description N and M are the width and depth of the viewing area measured in average character
units. %ht may be preceded by %pv in order to allowing re-sizing at run time.
start_topic is a standard character string giving the name of the first topic to be
viewed.
The hypertext document is attached by a call to PSSNWh_TacTgcNaTb^daRT/.
For further information see Chapter 19.
%hw
Purpose To return the handle of the current window.
246
Chapter 21 Format code reference
%hx
Purpose To attach a horizontal scroll bar to the next control.
%ib
Purpose To insert a image button or toolbar.
Syntax fX]X^/³]\XQJ^_cX^]bL´QXc\P_N]P\TbcPcNRca[RQNUd]R
RWPaPRcTa QXc\P_N]P\T
X]cTVTa bcPcNRca[
TgcTa]P[ RQNUd]R
Modifiers Question mark (?) - A help string for each button is placed in order (in square
247
ClearWin+ User’s Guide Fortran
brackets) after the options (use empty brackets for the options list if it is blank).
Description %ib provides an enhanced and simplified replacement for %tb. Like %tb, %ib can be
used to create toolbars or rectangular arrays of image buttons. However, only one flat
image is required for each button - all the variants are created automatically. Also, text
can be automatically added to the image.
]\XQ creates block of buttons n buttons wide and m deep. n and m are optional and
both default to 1. When n is used .m is optional. The arguments consist of the
following triplet repeated for each button in turn: bitmap_name, stat_ctrl, cb_func.
Note that every button has a call-back function.
bitmap_name is the name of a bitmap resource. If text is to be added to the image, the
name is followed by a forward slash and then the text. For example, here is the code
for a single button with some text:
X,fX]X^/XQ\hNQdcc^]?aTbb \TRca[RQ
The button text can include newline characters:
³\hNQdcc^]?aTbb´270A ´\T´
The integer variable stat_ctrl encodes the state of the button with 1=up, 2=down,
3=greyed, and 4=push button. States 1 and 2 are used with a button that toggles up
and down, i.e. a button that requires two separate clicks to return it to the up state.
Each time the user presses and releases a button that is not greyed, the call-back
function is invoked with call-back reason 1DCC>=N?A4BB. If you decide to use the
same call-back function for several buttons you can use
R[TPafX]NX]U^/1DCC>=N=D<14A to establish which button was pressed
(buttons are numbered along the rows starting at 1).
A call-back function (or any other code) can alter the control variable stat_ctrl and
pass it to fX]S^fNd_SPcT/ to change the state of a button. For example, you could
disable/enable a button. Passing any of the control variables belonging to a given %ib
toolbar will update the entire block.
%ib[flat] produces a different style of button which pops up and becomes coloured
when the mouse is moved over it.
Images are padded as required to produce a rectangular array, however for best results
you should try to make the images the same size.
%ib is designed for bitmaps that have a grey background. If the image has a one-pixel
border then the border colour is used as the background colour, otherwise the
background is assumed to be light grey (192,192,192).
Notes If strings are included, you can make the buttons of equal width by making the images
wide enough to allow for the strings.
When using High Color (16 bit) mode some display drivers convert grey (192,192,192)
248
Chapter 21 Format code reference
%ic
Purpose To draw an icon.
Syntax fX]X^/³XRJXR^]N]P\TL´
fX]X^/³OXR´ WP]S[T
X]cTVTa WP]S[T X]_dc
Modifiers Grave accent (`) - use a Windows API handle.
Caret (^) - the call-back function is called when the user clicks on the icon.
Question mark (?) - a help string is supplied.
Description icon_name is a standard character string (can be replaced by @) associated with a icon
file in a resource script.
handle is a value returned by a modified form of the API function LoadIcon
Icons can include transparent regions where the background can be seen.
Example fX]X^/³MXRJ\hXR^]L´RQNUd]R
\hXR^] 82>= UX[TXR^ aTb^daRT UX[T
See also \PZTNXR^]/Q\VX
%if
Purpose To specify that the next control will have the initial focus.
Syntax fX]X^/³XU´
See also PSSNRdab^aN\^]Xc^a/, aT\^eTNRdab^aN\^]Xc^a/, PSSNU^RdbN\^]Xc^a/,
aT\^eTNU^RdbN\^]Xc^a/, R[TPafX]NX]U^/5>2DBB43NF8=3>F
249
ClearWin+ User’s Guide Fortran
%il
Purpose To specify the lower and upper limits for subsequent %rd formats.
%it
Purpose To switch to italic font.
Syntax fX]X^/³Xc´
Modifiers Grave accent (%`it) - used to switch off the effect.
Description %it is cancelled by %`it and %sf.
%lc
Purpose To return the handle of the previous (last) control.
250
Chapter 21 Format code reference
%ld
Purpose To display a round LED symbol (a coloured disk with a black border).
%ls
Purpose To insert a list box or combo box.
Syntax fX]X^/³]\[bJ^_cX^]bL´XcT\b]d\NXcT\bRdaNXcT\
fX]X^/³m]\[bJ^_cX^]bL´XcT\b]d\NXcT\bRdaNXcT\
VaThNRca[
RWPaPRcTa] XcT\b]d\NXcT\b X]_dc
X]cTVTa ]d\NXcT\b X]_dc _PaP\TcTa
X]cTVTa RdaNXcT\ X]_dc^dc_dc
X]cTVTa VaThNRca[ X]_dc
Modifiers Grave accent (`) - used to provide a drop-down combo box (for editable lists see %el).
Caret (^) - call-back function is called when the user selects an item.
Question mark (?) - a help string is supplied.
Tilde (~) - adds a variable that controls the grey (enable/disable) state.
Description n and m are optional (m cannot be specified without n). n represents the width of the
listbox in characters and m the depth. n and m can be replaced by asterisks (*) in
which case the values of n and m must be supplied as the first two arguments in the
251
ClearWin+ User’s Guide Fortran
argument list.
num_items is the number of items in the list.
cur_item is the item number that is selected in the range zero to num_items both on
input and output. Zero signifies that no item is selected.
items is an array of text entries, one for each item. Blank entries at the end of the list
are not displayed. This means that you can use blank entries to create a list that can be
changed dynamically.
If the grave accent is used and a call-back is supplied, option can be set to the keyword
TgcT]STS. The result is that the call-back is called when the list drops down or closes
up. These events must be detected from the call-back by calling
R[TPafX]NbcaX]V/³20;;102:NA40B>=´ which returns 3A>?3>F= or
2;>B4D?.
For a list box (i.e. when a grave accent modifier is not used), the option WbRa^[[QPa
provides a horizontal scroll bar whilst the option \d[cXR^[d\] provides a multiple
column output (see page 62).
If the grave acent modifier is not used, %ls can be preceded by a pivot %pv.
grey_ctrl is 1 (enabled) or 0 (disable/greyed). Any call-back function must be placed
after this control variable.
Notes The %ls control is limited to 32768 characters.
%lv
Purpose To include a list view control.
Syntax fX]X^/³[eJ^_cX^]bL´fXScWWTXVWcXcT\b]d\NXcT\bbT[eXTf
fX]X^/³O[eJ^_cX^]bL´fXScWWTXVWcXcT\b]d\NXcT\bbT[
eXTfXR^]Nbca
RWPaPRcTa XcT\b]d\NXcT\b X]_dc^dc_dc
X]cTVTa ]d\NXcT\b X]_dc _PaP\TcTa
X]cTVTa bT[]d\NXcT\b X]_dc^dc_dc
X]cTVTa fXScWWTXVWceXTf X]_dc
252
Chapter 21 Format code reference
253
ClearWin+ User’s Guide Fortran
and widths. The first character defines the separator between the data for each column.
In this example, the first column has the caption "Header". A trailing underscore
followed by an integer provides the pixel width of the column. If this is ommitted then
the length of the text defines the width. In this example the second column header is
blank and the second column width is 50 pixels. The number of characters (80 in this
case) must be sufficient to allow ClearWin+ to add the column width to each heading (4
characters per column).
items(2) provides data for the first row of a report. Again the first character defines the
separator. The second character defines the icon as an index (A,B,C...) into the list of
icons 'icon1,icon2' (when a grave accent is used). Next comes the label and then the
data for column two etc..
Options
bX]V[TNbT[TRcX^] Allows only one item at a time to be selected.
By default Shift and Control keys can generate multiple
selections.
TSXcN[PQT[b Allows item text to be edited (first column in report view).
]^NR^[d\]NWTPSTab Column headers are not displayed in report view
(items(1) is still needed for column widths)
bW^fNbT[TRcX^]NP[fPhb Always show the selection, if any, even if the control does
not have the focus.
]^NQ^aSTa Displays the control without a border.
]^N[PQT[NfaP_ Displays the item label on a single line in an icon view.
P[XV]Nc^_ Items are top-aligned in icon and small icon view.
P[XV]N[TUc Items are left-aligned in icon and small icon view
TSXcNRT[[b Allows all columns in the report view to be edited (see below).
Label editing
TSXcN[PQT[b enables label editing and requires a call-back function that can test for
the call-back reasons 1468=N438C, 4=3N438C and 438CN:4HN3>F=.
With 1468=N438C you can get the index of the selected item by the call
R[TPafX]NX]U^/A>FN=D<14A. If your call-back function returns the value 4
then editing of this item is prevented.
With 438CN:4HN3>F= you can validate each character as it is typed. Use
R[TPafX]NX]U^/:4H1>0A3N:4H to get the key and/or
R[TPafX]NbcaX]V/438C43NC4GC to get the resulting string with the character
inserted. If the call-back function returns the value 4 then the character is not accepted.
If you want to translate the input key to another key then the call-back function must
return the ASCII character code (31<code<256) of the translated key.
With 4=3N438C you can get the result of the edit by the call
R[TPafX]NbcaX]V/438C43NC4GC. Having validated the label, you should then
254
Chapter 21 Format code reference
255
ClearWin+ User’s Guide Fortran
Call-back reasons
1468=N438C A label or cell is about to be edited (see above).
438CN:4HN3>F= The user has pressed a keyboard key during a label or cell
edit. R[TPafX]NX]U^/:4H1>0A3N:4H provides the
key code (see above).
4=3N438C A label or cell has been edited (see above).
B4CNB4;42C8>= A item has been selected.
R[TPafX]NX]U^/³A>FN=D<14A´ provides the index.
2>;D<=N2;82: The user has clicked on a column header.
R[TPafX]NX]U^/³2>;D<=N=D<14A´ provides the index.
<>DB4N3>D1;4N2;82: The user has double-clicked using the left mouse button.
R[TPafX]NX]U^/³A>FN=D<14A´ provides the index.
:4HN3>F= The user has pressed a keyboard key.
R[TPafX]NX]U^/³:4H1>A03N:4H´ provides the key
code.
In reponse to a column click you might choose to sort the items using the given column
index. Having reconstructed the data, you should then make a call to
fX]S^fNd_SPcT/XcT\b in order to view the new order.
Example See page 65.
%lw
Purpose To allow fX]X^/ to return without closing the window that it creates.
Syntax fX]X^/³[fJ^_cX^]L´ Rca[
X]cTVTa Rca[ ^dc_dc
Modifiers Grave accent (`) - used to delay the creation of the window until ctrl has been passed to
%ch.
Description Using %lw causes fX]X^/ to return whilst leaving the window open. ctrl is a control
variable that is returned with the value -1. Subsequently the window can be closed by
setting ctrl to zero (or a positive value) and calling fX]S^fNd_SPcT/Rca[.
%lw can take the option ^f]TS ( %lw[owned] ). This option defines certain properties
of the window in relation to its parent. The “owned” properties are those of a window
that does not use %lw, namely that the parent cannot overlay the child and, if the
parent is closed, the child automatically closes. For these properties to be meaningful
256
Chapter 21 Format code reference
the parent must be created using %ww. Also %lw[owned] must be used in the
definition of a child window that appears in a call-back function of the parent.
%mg
Purpose To provide a call-back function for a given Windows message.
%mi
Purpose To supply the name of an icon resource to be used when the window is minimised.
Syntax fX]X^/³\XJXR^]N]P\TL´
fX]X^/³O\X´ WP]S[T
257
ClearWin+ User’s Guide Fortran
Example fX]X^/³\XJ\hXR^]L´
\hXR^] 82>= UX[TXR^ aTb^daRT UX[T
See also \PZTNXR^]/, %ic
%mn
Purpose To attach a menu to the window.
Syntax fX]X^/³\]J\T]dNb_TRL´
Modifiers Question mark (?) - All the strings are placed in order at the end of the format
description, one for each and every menu item that has a call-back function.
Grave accent (`) -Creates an enhanced menu (see page 86).
Description See page 81.
%ms
Purpose To include a multi-selection box.
258
Chapter 21 Format code reference
The list of possible options is currently empty. This item is included for future
developments. If you include a help string in square brackets then you must also
include an empty options list.
num_items is the number of items in the list. If m is less than num_items then a scroll
bar is presented.
sel is an array whose elements are set to 1 if the item is selected otherwise to zero.
items is an array of text entries, one for each item. Blank entries at the end of the list
are not displayed. This means that you can use blank entries to create a list that can be
changed dynamically.
%ms will take a pivot %pv.
%mv
Purpose To provide a call-back function that is to be called when the user moves or resizes the
window.
Syntax fX]X^/³\e´ RQNUd]R
TgcTa]P[ RQNUd]R
Modifiers Grave accent (`) - without the grave the call-back is for a moving window; with the
grave the call-back is for a resizing window.
Description The call-back function is also called when the window is created (if two are used, one
for moving and one for re-sizing, then both are called).
The call-back function will typically call the Clearwin+ function
VTcNfX]S^fN[^RPcX^]/ in order to determine the new size and position.
Note that certain window operations involve both moving and resizing. For example if
the user drags the top-left corner, then the window is both moved and resized
(‘moving’ changes the co-ordinates of the top left corner, ‘resizing’ changes the width
259
ClearWin+ User’s Guide Fortran
and/or height).
%nc
Purpose To provide a specified class name for the application.
Syntax fX]X^/³]RJR[PbbN]P\TL´
Description class_name is a standard character string (can be replaced by @) that specifies the new
class name. Some applications display the class name in their output.
Notes The Windows API function FindWindow can be used in order to get a handle to
another application from its class name. The handle can then be used to target
messages. If you want the current application to act as such a target you can specify
the class name using %nc.
Example fX]X^/³]RJ\hP__R[PbbL´
See also bT]SNcTgcN\TbbPVT/, %rm
%nd
Purpose To prevent controls from sliding down when sizing a window.
Syntax fX]X^/³]S´
Modifiers Grave accent (`) - used to switch off the effect.
Description Used with %pv and %ww under the old re-sizing mechanism (see page 93).
%nl
Purpose To insert new lines.
Syntax fX]X^/³\][´
260
Chapter 21 Format code reference
Description m is the number of new lines to insert. m is optional and defaults to 1. To move
directly below a control or graphics area use %ff instead.
Example fX]X^/³"][´
See also %ff, %cn, %rj
%nr
Purpose To prevent controls from sliding right when sizing a window.
Syntax fX]X^/³]a´
Modifiers Grave accent (`) - used to switch off the effect.
Description Used with %pv and %ww under the old re-sizing mechanism (see page 93).
%ns
Purpose To disable a screen saver whilst the current window is open.
Syntax fX]X^/³]b´
See also %sv
%ob
Purpose To open a box.
Syntax fX]X^/³^QJ^_cX^]bLJcXc[TL´
fX]X^/³]\^QJ^_cX^]bLJcXc[TL´
Modifiers Grave accent (`) - provides a shaded background.
Description Defines the top left hand corner of a rectangular box into which subsequent objects are
to be placed until a corresponding %cb format is encountered.
title is optional and is a standard character string that is used with an option from the
261
ClearWin+ User’s Guide Fortran
]P\TSNR Splices a name into the top line of the box (in the centre)
]P\TSN[ Splices a name into the top line of the box (on the left).
]P\TSNa Splices a name into the top line of the box (on the right)
]P\TS The same as ]P\TSNR.
]P\T[Tbb Occupies the same vertical space as ]P\TSNR etc. but has no
name.
]^NQ^aSTa Create an invisible box which is useful for grouping controls.
X]eXbXQ[T The same as ]^NQ^aSTa.
_P]T[[TS This replaces the simple line box with a 3-dimensional panel.
cWX]N_P]T[[TS Similar to panelled but perhaps a slightly more attractive effect.
bWPSTS This has the same effect as the use of the grave accent.
bcPcdb This provides a box in the form of a status bar.
Q^cc^\NTgXc Begins the next control below this box rather than to the right.
bR^aTS Double line, 3-dimensional shade effect.
ST_aTbbTS Single line, 3-dimensional shade effect.
aPXbTS Single line, 3-dimensional shade effect
When n and m are used, %ob creates a rectangular grid of boxes (n across, m down)
each requiring its own %cb. Thus %3.2ob would require six %cb codes. A title cannot
be supplied for a grid of boxes. When used with the option ]^NQ^aSTa, this provides
a mechanism for positioning text and controls within rectangular sub regions of the
window (see the section on page 91 for a simple example).
%ap can be used before %ob in order to specify the position of the box from the %ap
arguments.
Notes %ob boxes can be nested, one within another, in order to provide a fine control over
the positioning of items in a window.
The options bR^aTS, ST_aTbbTS and aPXbTS should not be used with a background
colour of white or black (grey is typical).
Example fX]X^/³^QJ]P\TSNaLJATbd[cbL´
See also %ap
262
Chapter 21 Format code reference
%og
Purpose To create an OpenGL graphics region (Win32 only).
%pb
Purpose To insert a parameter box.
Syntax fX]X^/³=<_QJ^_cX^]bL´
Modifiers Question mark (?) - can be attached to %dp, %fp, %tp, %ep and %up.
Description N is the width of the box in average characters. M is the number of lines in the control
which will include a scroll bar if M is not large enough.
options can be omitted or can take the value b^acTS to specify that the parameters are
to be alphabetically sorted by name.
After a parameter block has been defined parameters can be attached by subsequent
formats thus:
S_ - Integer parameter
U_ - Floating point parameter
c_ - Text parameter
T_ - Enumerated parameter (a set of named alternatives)
d_ - User parameter (just activates a call-back)
Each of these codes is followed by a standard character string that provides the text to
be displayed. See page 42 for further information.
263
ClearWin+ User’s Guide Fortran
%pd
Purpose To insert a Sterling pound symbol ‘£’.
Syntax fX]X^/³_S´
%pl
Purpose To create a SIMPLEPLOT graphics region (Win32 only).
%pm
Purpose To supply a popup menu.
264
Chapter 21 Format code reference
%ps
Purpose To produce layered windows in a card-index style (property sheet).
265
ClearWin+ User’s Guide Fortran
selectable.
Notes If an individual sheet is closed (e.g. by placing a button without a callback function in
the sheet) then the parent window will close.
%pv
Purpose To allow certain controls to be re-sized under user control.
Syntax fX]X^/³_e´
Description Use %pv before %eb, %fr, %dw, %gr, %cw, etc. so that the control can be re-sized at
run time. A thick frame is added to the window to enable it to be resized.
%rb
Purpose To define a radio button or check box.
266
Chapter 21 Format code reference
%rb can be used in conjunction with the gang format code %ga. Note that it is not
conventional to gang check boxes.
%rd
Purpose To create an edit box and display an integer that can be updated.
267
ClearWin+ User’s Guide Fortran
%re
Purpose To create an multi-line edit box and display a character variable (i.e. a string).
N represents the width of the box in average characters. M represents the depth which
should not be less than 2.
buffer is a character string for the text (maximum of 32*1024 characters).
The following options are available:
Notes The %rs ?0BBF>A3 option is not available with %re. %re does not take a pivot (%pv).
268
Chapter 21 Format code reference
%rf
Purpose To create an edit box and display a floating point value that can be updated.
269
ClearWin+ User’s Guide Fortran
%rj
Purpose To right justify text and controls.
Syntax fX]X^/³aY´
Description %rj forces everything that follows it, up to the next new line or form-feed character, to
be right justified in the window. A window margin, if any, is still applied.
When %rj is used within a box (%ob), the format applies only to that box.
%rm
Purpose To provide the name of a call-back function to handle messages from another
ClearWin+ application.
Syntax fX]X^/³a\´ RQNUd]R
TgcTa]P[ RQNUd]R
Description If one application uses the subroutine bT]SNcTgcN\TbbPVT/ to send text to a second
application, the second application should use %rm to supply the name of a call-back
function to handle the message and send a reply.
%rp
Purpose To set the position of the next control relative to the current position.
270
Chapter 21 Format code reference
default font.
%rs
Purpose To create an single-line edit box and display a character variable (i.e. a string).
n is optional and specifies the number of average width characters in the displayed
output. The output will scroll horizontally within the specified width if necessary.
If %`rs is specified, then the string presented can only be changed by the program
using fX]S^fNd_SPcT/eP[dT.
grey_ctrl is 1 (enabled) or 0 (disable/greyed). If a call-back function is used, it is
placed after this control variable.
The standard call-back functions 2>?H, 2DC, and ?0BC4 can be used in this
context by attaching them to menu items and/or accelerator keys.
When %dd is used before %rs, a spin wheel is added (see %dd for details).
The subroutine bTcNWXVW[XVWcTS/ can be called to select all of the text in the edit
box. It takes one argument which is the handle given by %lc.
The following options are available:
?0BBF>A3 An asterisk (*) appears on the screen for each character typed
whilst the string is correctly stored.
271
ClearWin+ User’s Guide Fortran
%sc
Purpose To provide a call-back function when a window is initially displayed.
%sd
Purpose To provide subscript text.
Syntax fX]X^/³bS´
Modifiers Grave accent (`) - cancels the effect of an earlier %sd.
Description This format code cannot be applied to the default font so select a font and then enclose
the text that is to be subscripted between %sd and %`sd.
272
Chapter 21 Format code reference
%sf
Purpose To return to the standard font.
Syntax fX]X^/³bU´
Modifiers Grave accent (`) - Windows 95 only (see page 98).
Description Resets to default text attributes after use of any combination of %bf, %it, %ul, %fn,
and %ts.
%sh
Purpose To create a property sheet.
%si
Purpose To insert a standard icon.
Syntax fX]X^/³]bXbh\Q^[´
Modifiers Caret (^) - call-back is called when the user clicks on the icon.
Question mark (?) - the help string goes after the symbol.
Description Defines a standard icon that is to be placed to the left of the block of text that follows
%si.
symbol is one of:
273
ClearWin+ User’s Guide Fortran
Example fX]X^/³bX´
See also %ic
%sl
Purpose To insert a slider control.
274
Chapter 21 Format code reference
%sm
Purpose To modify the system menu.
Syntax fX]X^/³b\J\T]dNb_TRL´
Modifiers Grave accent (`) - used to replace rather than add to the existing system menu.
Question mark (?) - All the strings are placed in order at the end of the format
description, one for each and every menu item that has a call-back function.
Description See page 86.
%sp
Purpose To set the position of a window.
Syntax fX]X^/³b_´ g h
X]cTVTa g h X]_dc
Modifiers Grave accent (`) - used in a call-back function to give the position relative to the
position of the event that resulted in the call.
Description x and y represent the position of the top left corner of the window in screen co-
ordinates. Typically these values are returned by %gp.
%ss
Purpose To save and load settings using an INI file.
275
ClearWin+ User’s Guide Fortran
%st
Purpose To insert a variable string.
276
Chapter 21 Format code reference
%su
Purpose To provide superscript text.
Syntax fX]X^/³bd´
Modifiers Grave accent (`) - cancels the effect of an earlier %su.
Description This format code cannot be applied to the default font. You must select a font and then
enclose the text that is to be superscripted between %su and %`su.
%sv
Purpose To create a screen saver executable.
Syntax fX]X^/³be´
Description A window whose definition includes %sv will close as soon as it receives mouse or
keyboard input. See page 132 for further information.
%sy
Purpose To change the style of a dialog box.
Syntax fX]X^/³bhJ^_cX^]bL´
Description By default, a format window that uses neither %ww nor %sy has a caption bar but does
not have: a) system menu, b) a minimise box and c) a maximise box. Such a window
is called a dialog box and by default has a double frame that is raised. This means that
a dialog box cannot be maximised, minimised or re-sized. %sy is used to change the
style of such a dialog box. The list includes options for changing the border of the
window. This refers to the space that, by default, is provided by ClearWin+ to
surround the text and controls within a window (as in %bd). Do not confuse this
border with the frame of the window that is determined by the Windows API style.
277
ClearWin+ User’s Guide Fortran
The "S style has an effect on the position of subsequent controls and must be used
before the controls are defined. Some controls are not affected (for example, buttons
are not changed). The window is created using the standard button face colour for its
background with the controls appearing in relief. With bhJ"SL, by default %ob
boxes are given the bR^aTS property provided the aPXbTS and ST_aTbbTS properties
are not used with %ob. ^QJbWPSTSL boxes are rendered as ^QJST_aTbbTSL
boxes.
%sz
Purpose To size a window.
278
Chapter 21 Format code reference
when the window is re-sized. If code is added to save these settings, then the values
can be used when the same window is next opened.
Special values are used to represent a maximised window. Consequently, if the
dimensions of a maximised window are saved and used to re-open the window, the
window will be restored in its maximised state.
%ta
Purpose To skip to the next tab stop.
Syntax fX]X^/³]cP´
Description Tab stops can be used for text and for controls. Default tab stops are at 8-average
character width intervals. The default settings can be changed by using %tl.
n is an optional positive integer which defaults to 1. It provides an alternative to
multiple consecutive applications of %ta.
Example fX]X^/³"cP´
See also %tl
%tb
Purpose To insert a bitmap button or toolbar.
279
ClearWin+ User’s Guide Fortran
Description This control has been superceded by %ib. For new code use %ib instead.
off, on, down and disab provide the names of bitmap resources through a resource
script.
stat_ctrl is set to 1 when the button is on and to 0 when the button is off.
grey_ctrl is set to 1 when the button is enabled and to 0 when it is disabled (greyed).
n and m are optional and both default to 1. When n is used .m is optional. These
provide for a toolbar n buttons wide and m deep. A full set of arguments are required
for each button (scanning in order across the rows of buttons) using the same order of
arguments as for a single button.
For further information see page 68.
Notes Bitmap resource names can be contructed from known Windows handles (see page 79).
%tc
Purpose To set the colour of subsequent text.
Syntax fX]X^/³cRJR^[^daL´
fX]X^/³cR´ aVQNeP[dT
X]cTVTa aVQNeP[dT X]_dc
Modifiers Grave accent (`) - used with an integer argument in order to set the text colour for %eb
(see page 113).
Description colour must be one of Q[PRZ, fWXcT, VaTh, aTS, VaTT], Q[dT and hT[[^f.
rgb_value is typically obtained by a call to A61/. Using the value (-1L) resets the
colour of subsequent text to its default value.
Notes The text colour for a given control can be changed dynamically (after the window has
been created) by calling the subroutine B4CN2>=CA>;NC4GCN2>;>DA/.
Example fX]X^/³cRJaTSL´
280
Chapter 21 Format code reference
fX]X^/³cR´ A61/!!
See also %fn, %ts, %bf, %it, %ul, and the Windows API call
6TcBhb2^[^a2>;>ANF8=3>FC4GC
%th
Purpose To provide “tooltip” help.
%ti
Purpose To provide a taskbar icon.
Syntax fX]X^/³cXJXR^]N]P\TLJc^^[cX_L´RQNUd]R
TgcTa]P[ RQNUd]R
Description Under Windows 95/NT 4.0 (and later operating systems) there is a region on the
taskbar to the right where some programs place an icon - usually because they are in a
quiescent state. This area is typically used by the modem, speaker volume control, and
clock. These icons usually display some text if the mouse is placed over them and
respond to mouse clicks by becoming active in some way. Win32 ClearWin+
programs can use this area via the %ti format code.
This format takes two standard strings (the icon resource and help text respectively)
and a call-back function. The call-back function will be called for all mouse actions
over the taskbar icon. The different mouse actions can be distinguished by using
R[TPafX]NbcaX]V/20;;102:NA40B>=.
Typically, the call-back function should respond to clicks (or perhaps double clicks)
only. A window containing a %ti format will be invisible apart from the taskbar icon,
so there is no point in adding other controls to a %ti window. However, in other ways
281
ClearWin+ User’s Guide Fortran
Notes icon_name can contructed from a known Windows handle (see page 79).
%tl
Purpose To set up tab locations for use with %ta.
%ts
Purpose To set the text size.
282
Chapter 21 Format code reference
%tt
Purpose To insert a textual toolbar.
Syntax fX]X^/³ccJQdcc^]NcTgcL´
fX]X^/³mccJQdcc^]NcTgcL´ VaThNRca[
X]cTVTa VaThNRca[ X]_dc
Modifiers Tilde (~) - adds a grey control.
Grave accent (`) - specifies that this is the default button.
Question mark (?) - the help string is placed in square brackets after [button_text].
Caret (^) - the call-back function is called when the user clicks on the button.
Description %tt is similar to %bt but provides a button that is not as deep and whose width is
rounded to one of a set of standard sizes.
button_text is a standard character string (can be replaced by @).
%tt is typically used with ffJ]^NQ^aSTaL and/or %bx.
%tv
Purpose To insert a hierarchical tree.
283
ClearWin+ User’s Guide Fortran
Notes Icon resource names can be contructed from known Windows handles (see page 79).
284
Chapter 21 Format code reference
%tx
Purpose To display an array of text with attributes in a rectangular region.
285
ClearWin+ User’s Guide Fortran
%ul
Purpose To switch to underlined text.
Syntax fX]X^/³d[´
Modifiers Grave accent (`) - switches off underlined text.
Description %ul is cancelled by %`ul and %sf.
%uw
Purpose To allow Windows API code to be interfaced to ClearWin+.
%vx
Purpose To attach a vertical scroll bar to the next control.
286
Chapter 21 Format code reference
Description cur_val is the value that corresponds to the position of the scroll box (also called the
thumb). It returns a value between zero and max_val - 1.
page_step is the amount that cur_val is to be increased/decreased when the user clicks
on the scroll bar (other than on the thumb). For a document, page_step will be set to
the number of lines that are to be displayed in the window and max_val should be set
to n - page_step, where n is the total number of lines in the document.
With %hx and %vx the three arguments cur_val, page_step and max_val can be
passed as variables and changed dynamically with a call to fX]S^fNd_SPcT/
A call to R[TPafX]NX]U^/³8=C4A<4380C4NB2A>;;´ will determine if the
callback was called whilst the thumb was moving. A return value of 1 indicates
movement whilst zero indicates that the thumb is stationary. Both of these events
occur at the end of a move.
%hx and %vx should not be used with controls like %eb and %cw which have their
own scroll bar mechanism.
%wc
Purpose To display a character.
%wd
Purpose To display an integer.
Syntax fX]X^/³fS´ e
X]cTVTa e X]_dc
Description See page 45.
287
ClearWin+ User’s Guide Fortran
%we
Purpose To display a real value.
Syntax fX]X^/³fT´ e
S^dQ[T _aTRXbX^] e X]_dc
Description See page 45.
%wf
Purpose To display a real value.
Syntax fX]X^/³fU´ e
S^dQ[T _aTRXbX^] e X]_dc
Description See page 45.
%wg
Purpose To display a real value.
Syntax fX]X^/³fV´ e
S^dQ[T _aTRXbX^] e X]_dc
Description See page 45.
%wp
Purpose To supply the name of a wallpaper bitmap.
Syntax fX]X^/³f_JQXc\P_N]P\TL´
Modifiers Grave accent (`) - ensures that, if necessary, the window is expanded to hold at least
one copy of the bitmap.
Description bitmap_name is a standard character string (can be replaced by @). The bitmap is
used as a back drop to the contents of the window and, if necessary, is repeated
288
Chapter 21 Format code reference
Example fX]X^/³f_JfP[[_P_TaL´
fP[[_P_Ta 18C<0? UX[TQ\_ aTb^daRT UX[T
See also %bg
%ws
Purpose To write a string.
Syntax fX]X^/³fb´ b
RWPaPRcTa b X]_dc
Description See page 45.
%ww
Purpose To change the style of a window.
Syntax fX]X^/³ffJ^_cX^]bL´
Description By default, a format window that uses neither %ww nor %sy has a caption bar but does
not have: a) system menu, b) a minimise box and c) a maximise box. Such a window
has a double frame that is raised.
%ww is used to change the style a window. If %ww is used without any of its options,
the resulting window has a caption bar that includes: a) system menu, b) a minimise
box and c) a maximise box. Such a window has a single frame that is not raised.
The list of options given below includes options for changing the border of the
window. This refers to the space that, by default, is provided by ClearWin+ to
surround the text and controls within a window (as in %bd). Do not confuse this
border with the frame of the window that is determined by the Windows API style.
A window that uses %ww can be re-sized if a pivot (%pv) is also included.
options can be one or more of:
289
ClearWin+ User’s Guide Fortran
290
Chapter 21 Format code reference
%wx
Purpose To display a hexadecimal value.
Syntax fX]X^/³fg´ e
X]cTVTa e X]_dc
Description See page 45.
291
ClearWin+ User’s Guide Fortran
292
22.
293
ClearWin+ User’s Guide Fortran
These represent stack and heap size values that are redundant in Win32 applications.
For Win32 applications, the resource file name must have a different stem (i.e. the
part before the extension) from all the other source file names. For example, do not
use prog.rc with prog.for. If you did not obey this rule, both files would be compiled
into prog.obj and one would overwrite the other.
Resources are automatically appended to the executable or DLL being created.
However, by default ClearWin+ only searches for resources in the current executable.
Calling the subroutine DB4NA4B>DA24N;81A0AH/ causes ClearWin+ to also search
in a given DLL. The call takes the form:
20;; DB4NA4B>DA24N;81A0AH/³<H;81´
where mylib.dll is the name of the DLL.
Fortran 77 routines that use ClearWin+ and/or the Windows API should include the
line
8=2;D34 +fX]S^fbX]b-
unless the routine only refers to fX]X^/ or A61/ (say) which can be declared as
8=C464A in the routine. Note the use of “<” and “>” to denote that the default
directory for system include files should be searched. The file called windows.ins
references three other files as follows:
8=2;D34 +R[TPafX]X]b-
8=2;D34 +fX]"!P_XX]b-
8=2;D34 +fX]"!_a\X]b-
These files are installed into the INCLUDE sub-directory of your chosen installation
directory (the default installation directory is c:\win32app\salford). Where
appropriate, clearwin.ins can be used in place of windows.ins in your program. This
will reduce the amount of processing at compile time.
Fortran 90/95 routines can alternatively make use of the file mswin.mod instead of
windows.ins via the statement
DB4 <BF8=
The source file for mswin.mod references three other files as follows:
<>3D;4 \bfX]
DB4 \bf"!_a\
DB4 \bfX]"!
DB4 R[afX]
4=3 <>3D;4 \bfX]
Where appropriate, clrwin can be used in place of mswin in your program. This will
reduce the amount of processing at compile time.
294
Chapter 22 Compiling and linking
It is recommended that you use the IMPLICIT NONE statement at the start of any
routine that uses the windows.ins file. Without IMPLICIT NONE, a mispelt Windows
parameter (some are very long) will not be detected at compile time. Such bugs are
very hard to find in the Windows environment.
Tip Of necessity, the three include files and the equivalent module files contain many
thousands of lines of declarations in order to provide you with full access to all the
ClearWin+ functions and the Windows API. Once you are familiar with the concepts
described in this guide, you may find it helpful to create your own include or module
file that contains only those declarations that are used by your programs. If you use
IMPLICIT NONE, and remove references to windows.ins or msmod, the compiler will
report all usage of undeclared variables and functions. You can then search the
relevant include or module files for the missing names and, using a text editor, build
up your own include or module file. Note that ClearWin+ routines (whose names
usually end in an “@” character) will appear in a C_EXTERNAL statement in order
to provide the compiler with a reference to a routine in the run time library. If you
take the time to make your own include or module file, the benefits of much faster
compilation will be immediately obvious, especially if your program contains many
sub-programs that use these include or module files.
SLINK commands
If the /LINK and /LGO compiler command line options are not used, SLINK must be
called in order to link programs.
If your application uses a resource script (resource.rc say) then it must be separately
compiled using the Salford Resource Compiler SRC. This generates the object file
resource.obj which can then be loaded in the same way as other object files.
The following example shows the commands required to compile and link a simple
Windows application from a file myapp.for using FTN77:
5C=&& <H0?? F8=3>FB
BA2 A4B>DA24
295
ClearWin+ User’s Guide Fortran
B;8=:
;> <H0??
;> A4B>DA24
58;4
Note
a) Because myapp.obj and resource.obj are both used in the SLINK commands it is
evident that we cannot use myapp.rc as the name of the resource.
b) If there is more than one file of source code in addition to myapp.for then the first
to be loaded must contain the main program and be marked as a Windows
application either by using the /WINDOWS compiler option or by including the
WINAPP directive.
c) Not more than one resource object can be loaded.
d) A SLINK command line of the form:
bdQbhbcT\ fX]S^fb\PY^a\X]^a
specifies the Windows GUI style to use. The default is now
bdQbhbcT\ fX]S^fb#
The former Windows 3.10 subsystem can also be obtained by setting the
environment variable
LINK_SUBSYSTEM=3
296
Chapter 22 Compiling and linking
Once a resource script has be written, it should be stored in a file with the .RC
extension. The resource can then be compiled with a call to SRC of the form:
BA2 A4B>DA24
This command takes the file resource.rc as input and produces an object file called
resource.obj. This means that resource must not be used as the stem for both a
Fortran filename and resources in the same directory and project. The resulting object
file can then be linked with other object files using SLINK as follows.
B;8=:
;> <H0??
;> A4B>DA24
58;4
FTN95
Using FTN95, it is possible to append resource directives to the end of a program
using the RESOURCES directive. Everything after this directive (up to the end of
the file) is treated as resources and passed to the SRC command. The result is
combined with the object code produced by FTN95. In order to use the
RESOURCES directive, the SRC command must be available on the PATH. All
the resources for a program must be supplied in one place.
Here is a simple example:
F8=0??
8=C464A XfX]X^/
X,fX]X^/³RPJ0 QTPdcXUd[ QXc\P_L´
X,fX]X^/³Q\J\hQXc\P_L!][R]OQcJ>:L´
4=3
A4B>DA24B
\hQXc\P_ 18C<0? R)KQXc\P_bK_XR Q\_
297
ClearWin+ User’s Guide Fortran
298
23.
ClearWin windows
Introduction
This chapter describes the attributes of a ClearWin window. A summary of functions
that can be used with ClearWin windows is given on page 315. Details of these
functions can be found in Chapter 27.
A ClearWin window has the attributes of a Windows window but has added
functionality. In particular a ClearWin window can be used in association with the
standard Fortran I/O routines A403 FA8C4 and ?A8=C.
Note that a ClearWin window is not the same as a window created with fX]X^/
(which is called a format window). It is, however, possible to embed a ClearWin
window in a format window (see page 123).
Graphics can be drawn to a ClearWin window by using VTcNVaP_WXRbNSR/ and by
calling Windows API drawing functions (details are given in the ClearWin+ User’s
Supplement). However, it is recommended that graphics objects should be drawn to a
format window created using %gr, %pl or %og.
A ClearWin window (that is not embedded in a format window) can be created by
calling RaTPcTNfX]S^f/ (this function returns a standard Windows handle).
STbca^hNfX]S^f/ is used to kill the window and R[TPaNfX]S^f/ clears any I/O
text that appears in the window. However, it does not clear graphics that have been
drawn to the associated device context. d_SPcTNfX]S^f/ is called to “invalidate” a
ClearWin window and hence redraw it. Various other routines can be used to control
the font of the text and to get and set the handle for default I/O, whilst
^_T]Nc^NfX]S^f/ can be used to attach a Fortran unit number to a particular
ClearWin window.
299
ClearWin+ User’s Guide Fortran
Simple programs
Using ClearWin+, simple programs can be compiled unchanged. As soon as standard
output is generated which would have gone to the screen, or the program attempts to
read from the keyboard, a ClearWin window is set up by the ClearWin+ system.
Successive lines of output are written to this window (entitled >dc_dc), which scrolls
when necessary. The window acts like a terminal, so keyboard input is echoed in the
window. The window can be scrolled, moved, or resized by the user. The system
retains the information output to the window so that F<N?08=C messages can be
handled without any special programmer action. As an example, here is a complete
application program to calculate square roots:
F8=0??
3>D1;4 ?A428B8>= S
3> F78;4CAD4
A403 S
?A8=C B@ACS
4=33>
4=3
Notice that this program does not require an explicit exit path. Each time it pauses for
input, the system will be prepared to accept a window close request (Alt-F4). When
your program exits, its window will remain open until closed by the user in order to
ensure that the user has time to read the output.
Because ClearWin+ must store away every line that you send to a window - to cater
for possible repaint requests or user scroll operations - it is important to limit the
amount of output to manageable proportions. Store is consumed from the heap and is
reclaimed when the ClearWin window is closed or cleared. It is recommended that
the routine bTcNP[[N\PgN[X]Tb/ (or bTcN\PgN[X]Tb/) be used to limit the
amount of store that is consumed.
In a similar way, DOS applications that contain calls to the Salford graphics library
can also be compiled unchanged. In this case ClearWin+ will automatically create a
simple format window for the drawing.
300
Chapter 23 ClearWin windows
301
ClearWin+ User’s Guide Fortran
appropriate Windows API routines to create one or more fonts and then attach them to
a window.
In order to create a new font, it is usually best to start with the parameters defining the
system font and modify them to obtain what you require.
For example:
F8=0??
8=2;D34 +fX]S^fbX]b-
8=C464A [UWTXVWc[UfXScW[UTbRP_T\T]c
[U^aXT]cPcX^][UfTXVWc[UXcP[XR[Ud]STa[X]T
[UbcaXZT^dc[URWPabTc[U^dc_aTRXbX^]
[UR[X__aTRXbX^][U`dP[Xch[U_XcRWP]SUP\X[h
270A02C4A' [UUPRT]P\T
8=C464A ]TfU^]c
20;; VTcNbhbcT\NU^]c/[UWTXVWc[UfXScW[UTbRP_T\T]c
[U^aXT]cPcX^][UfTXVWc[UXcP[XR[Ud]STa[X]T
[UbcaXZT^dc[URWPabTc[U^dc_aTRXbX^]
[UR[X__aTRXbX^][U`dP[Xch[U_XcRWP]SUP\X[h[UUPRT]P\T
R 0[cTa cWT STUPd[c _PaP\TcTab c^ S^dQ[T cWT bXiT
R P]S b_TRXUh XcP[XR
[UWTXVWc,![UWTXVWc
[UfXScW ,![UfXScW
[UXcP[XR,
R 2aTPcT5^]c Xb P FX]S^fb 0?8 Ud]RcX^]
]TfU^]c,2aTPcT5^]c[UWTXVWc[UfXScW[UTbRP_T\T]c
[U^aXT]cPcX^][UfTXVWc[UXcP[XR[Ud]STa[X]T
[UbcaXZT^dc[URWPabTc[U^dc_aTRXbX^]
[UR[X__aTRXbX^][U`dP[Xch[U_XcRWP]SUP\X[h[UUPRT]P\T
20;; bTcNSTUPd[cNU^]c/]TfU^]c
The default font used by a ClearWin window (BHBC4<N58G43N5>=C) can be changed
by a call to either bTcNSTUPd[cN_a^_^acX^]P[NU^]c/ or to
bTcNSTUPd[cNU^]c/. These routines will alter the default font used by ClearWin+
on all ClearWin windows created subsequent to the call. The original default can be
restored by a call to bTcNSTUPd[cNc^NUXgTSNU^]c/.
302
Chapter 23 ClearWin windows
303
ClearWin+ User’s Guide Fortran
304
24.
305
ClearWin+ User’s Guide Fortran
306
Chapter 24 Using the Windows API
307
ClearWin+ User’s Guide Fortran
Some Windows API functions allow a particular argument to take two different types
in different circumstances. For example, an LPSTR in some circumstances and an
integer in others. This is outside the scope of the STDCALL mechanism. If this
feature affects you then you should copy the STDCALL statement for the relevant API
and modify it to have a different Fortran name and argument list, but keeping the
same called name.
A common example is the Windows API function LoadCursor which is used to load
either a cursor defined in the program resource or a predefined system cursor. This
has the following definition:
72DAB>A F8=0?8 ;^PS2dab^a070=3;4 W8]bcP]RT;?BCA [_2dab^a=P\T
When used to load a cursor from the program resource, hInstance is the instance
handle of the application. lpCursorName is a character string containing the name of
the cursor in the program resource. This form of the function will have the
STDCALL declaration :
BC320;; ;>032DAB>A ;^PS2dab^a0 E0; 8=BCA8=6)8=C464A#
When used to load a predefined system cursor, the first argument hInstance is set to
zero and the second argument lpCursorName is an integer containing one of a number
of predefined values which specifies the cursor to be loaded. This form of the function
will have the STDCALL declaration :
BC320;; ;>032DAB>A ;^PS2dab^a0 E0; E0;)8=C464A#
However, having two differing STDCALL statements for the same Fortran function is
not allowed. The solution is to change the Fortran name. For example
BC320;; ;>032DAB>A ;^PS2dab^a0 E0; 8=BCA8=6)8=C464A#
BC320;; ;>032DAB>A! ;^PS2dab^a0 E0; E0;)8=C464A#
The same situation arises with some other functions that have the form as
LoadCursor, for example LoadBitmap and LoadIcon.
A further example is given by the Windows API printer Escape function which can
take many different forms. One of these has the following form:
X]c F8=0?8 4bRP_TWSR 64CC427=>;>6H =D;; =D;;[_CTRW]^[^Vh
lpTechnology is an LPSTR (long pointers to strings) so the STDCALL declaration for
this form of the function for use in a Fortran program would be:
BC320;; 4B20?4 4bRP_T E0; E0; E0;8=BCA8=6
>DCBCA8=6)8=C464A#
A second form of this Escape function is:
X]c 4bRP_TWSR B4C2>?H2>D=C bXiT^UX]c
[_=d\2^_XTb [_0RcdP[2^_XTb
308
Chapter 24 Using the Windows API
lpNumCopies, and lpActualCopies are both LPINT (long pointers to integers) so the
STDCALL declaration for this form of the function would be:
BC320;; 4B20?4 4bRP_T E0; E0; E0; A45 A45)8=C464A#
As before, having two differing STDCALL statements for the same Fortran function is
not allowed and the solution is to change the Fortran name. For example
BC320;; 4B20?4 4bRP_T E0; E0; E0;8=BCA8=6
>DCBCA8=6)8=C464A#
BC320;; 4B20?4! 4bRP_T E0; E0; E0; A45A45)8=C464A#
309
ClearWin+ User’s Guide Fortran
A routine called 01>AC/ is available for use when the program needs to terminate
because of an error condition.
310
25.
Programming tips
311
ClearWin+ User’s Guide Fortran
312
Chapter 25 Programming tips
313
ClearWin+ User’s Guide Fortran
These routines will generate incorrect results if they are given bad arguments.
The subroutine BC0ACN2;40AF8=N?;0H102:/ can be used to play back a recorded
file. This subroutine takes one 270A02C4A variable specifying the name of the file
that holds the recording. When play back is completed, normal mouse and keyboard
input is resumed.
It is vital that the playback does not deviate from the recording in any way. For
example, if your application displays an extra window if some file is present, then that
file must be either present for both the recording and playback, or absent for both.
The problem of mouse actions being sensitive to the screen resolution and font sizes is
ameliorated somewhat by the following:
a) Menus, edit boxes, and text arrays store additional information that stores the data
in a resolution-insensitive form. This facility may be extended to cover more
controls in future.
b) Mouse co-ordinates are always stored relative to the control in which they occur.
This means that, for example, a mouse click at point (40,50) in a graphics area of
some fixed resolution will be recorded correctly.
314
26.
Library overview
315
ClearWin+ User’s Guide Fortran
Clipboard functions
CLIPBOARD_TO_SCREEN_BLOCK@ Copies a bitmap on the clipboard to a DIB.
COPY_FROM_CLIPBOARD@ Copies data from the clipboard.
COPY_TO_CLIPBOARD@ Copies data to the clipboard.
GRAPHICS_TO_CLIPBOARD@ Copies a drawing surface to the clipboard.
METAFILE_TO_CLIPBOARD@ Sends a metafile to the clipboard.
PLAY_CLIPBOARD_METAFILE@ Plays a clipboard metafile on the current
drawing surface.
SIZEOF_CLIPBOARD_TEXT@ Gets the size of text on the clipboard.
316
Chapter 26 Library overview
317
ClearWin+ User’s Guide Fortran
General functions
ABORT@ Used to terminate a program in the event of an
error.
HIBYTE@ To get the top 8 bits of a 16 bit integer.
HIWORD@ To get the top 16 bits of a 32 bit integer.
LOBYTE@ To get the bottom 8 bits of a 16 bit integer.
LOWORD@ To get the bottom 16 bits of a 32 bit integer.
START_PROCESS@ To start a new process.
TEMPORARY_YIELD@ Yields program control.
WINDOWS_95_FUNCTIONALITY@ Tests if Windows 95 is in use.
YIELD_PROGRAM_CONTROL@ Yields program control.
318
Chapter 26 Library overview
319
ClearWin+ User’s Guide Fortran
Using a handle
CLIPBOARD_TO_SCREEN_BLOCK@ Copies a bitmap on the clipboard to a DIB.
DIB_PAINT@ Displays a DIB.
EXPORT_BMP@ Exports a DIB to a BMP file.
EXPORT_PCX@ Exports a DIB to a PCX file.
GET_SCREEN_DIB@ Copies part of a graphics area.
IMPORT_BMP@ Reads in a BMP file.
IMPORT_PCX@ Reads in a .PCX file.
PRINT_DIB@ Prints a device independent bitmap.
RELEASE_SCREEN_DIB@ Releases memory for a DIB.
320
Chapter 26 Library overview
321
ClearWin+ User’s Guide Fortran
The following functions access an intenal ClearWin+ palette - a logical palette that is
attached to the device context of each drawing surface. Palettes are redundant if the
322
Chapter 26 Library overview
graphics device is a high colour device (i.e. has more than 8 bits per pixel). These
functions are documented in the ClearWin+ User’s Supplement.
323
ClearWin+ User’s Guide Fortran
These are used together with the DIB functions listed on page 319. An alternative set
of routines uses the concept of a virtual screen (a legacy from DOS programming).
The alternative set is described in the ClearWin+ User’s Supplement.
Other routines
GET_GRAPHICAL_RESOLUTION@ Gets the width and height of the current
drawing surface.
GRAPHICS_WRITE_MODE@ Selects replace/XOR mode before writing to
a drawing surface.
PERFORM_GRAPHICS_UPDATE@ Refreshes a drawing surface’s display.
Hypertext functions
The following routines can be used in association with the %ht format described in
Chapter 19.
324
Chapter 26 Library overview
Information functions
The following routines can be used in association with the F8=8>/ function.
Mouse functions
GET_MOUSE_INFO@ Gets the mouse position, mouse state and
keyboard state.
SET_MOUSE_CURSOR_POSITION@ Sets the mouse position relative to a given
window.
Movie functions
SHOW_MOVIE@ To show a video.
MOVIE_PLAYING@ To test if a video is still playing.
325
ClearWin+ User’s Guide Fortran
Sound functions
These functions require a sound card such as Sound Blaster. Note that simple WAV
resources can be played using the ‘SOUND’ standard call-back function.
326
Chapter 26 Library overview
327
ClearWin+ User’s Guide Fortran
328
27.
Library reference
ABORT@
Purpose To terminate a program in the event of an error.
Syntax BD1A>DC8=4 01>AC/
Description Normally when a program terminates - e.g. by executing a STOP statement, or by
encountering the END statement in the main program - any windows that are open are
left open until the user closes them and call-back functions continue to be called to
service the open windows.
Sometimes, if for example a serious error is detected, it may be necessary to terminate
the program immediately in which case the subroutine 01>AC/ should be called.
ACTIVATE_BITMAP_PALETTE@
Purpose To ensure that the palette is set correctly for the current window.
Syntax BD1A>DC8=4 02C8E0C4N18C<0?N?0;4CC4/ 32
8=C464A 32
Description This subroutine restores the current palette that the device context is using. This is
usually handled by Clearwin+.
See also 0CC027N18C<0?N?0;4CC4/ 2;40AN18C<0?/ 2A40C4N18C<0?/
64CN18C<0?N32/
329
ClearWin+ User’s Guide Fortran
ADD_ACCELERATOR@
Purpose To associate an accelerator key with a given window.
Syntax BD1A>DC8=4 033N0224;4A0C>A/ F :4HN=0<4 5
8=C464A F
270A02C4A :4HN=0<4
4GC4A=0; 5
Description This associates the callback function 5 with the named key (see the definition of %ac
on page 88 for details of the names of keys). F is the handle of the window which you
can obtain using %hw when the window is created. If a previous accelerator definition
for this key in this window exists then it is removed.
Notes You could use this routine if you were writing a configurable editor and you wished to
change the accelerator definitions of the surounding window dynamically.
The call-back function cannot be a string representing a standard call-back.
See also %ac, A4<>E4N0224;4A0C>A/
ADD_CURSOR_MONITOR@
Purpose To name a call-back function that monitors which window or control has the cursor.
Syntax BD1A>DC8=4 033N2DAB>AN<>=8C>A/ 21N5D=2
4GC4A=0; 21N5D=2
Description A general mechanism is available to enable programmers to monitor the
window/control that has the cursor (or the focus, see 033N5>2DBN<>=8C>A/).
330
Chapter 27 Library reference
ADD_FOCUS_MONITOR@
Purpose To name a call-back function that monitors which control has the focus.
Syntax BD1A>DC8=4 033N5>2DBN<>=8C>A/ 21N5D=2
4GC4A=0; 21N5D=2
Description See 033N2DAB>AN<>=8C>A/. Focus call-back functions use the 2;40AF8=N8=5>/
parameter 5>2DBB43NF8=3>F.
Notes The 2;40AF8=N8=5>/ parameter used here is not the same as 5>2DBNF8=3>F
which returns the handle of the F8=8>/ window which has focus rather than the
control within the window that has the focus.
See also A4<>E4N5>2DBN<>=8C>A/
ADD_GRAPHICS_ICON@
Purpose To place a movable icon or bitmap in a %gr graphics region.
Syntax 8=C464A 5D=2C8>= 033N6A0?782BN82>=/=0<4 G H
F83C7 34?C7
270A02C4A =0<4
8=C464A G H F83C7 34?C7
Description A %gr graphics region may have an icon resource ‘attached’ to it. The icon can be
moved freely around the graphics window with the mouse. Control of the icon is
maintained by the call-back function attached to the %gr window with the caret
modifier (^).
The =0<4 argument is that used for the resource that is included in your program. The
G and H values, initially hold the location the image is draw to. They also hold the new
position when the image is moved. The 2;40AF8=N8=5>/ parameter
3A06643N82>= is set to the value of the handle of the moved icon. The handle is
initially obtained as the returned from the function. The call-back function may
modify the G and H values if required. The purpose of this may be to ‘lock’ the image
onto the horizontal or vertical plane by continuously setting either the G or H variables
to a constant value.
When the icon is dropped 2;40AF8=N8=5>/ parameter 3A>??43N82>= is set to
the handle of the icon. A graphics icon can be removed with a call to
A4<>E4N6A0?782BN82>=/.
331
ClearWin+ User’s Guide Fortran
The F83C7 and 74867C parameters should be set at zero except when the icon image
occupies less than the possible 32x32 icon area e.g. 16x16. A small icon can be
constructed by starting at the top-left corner and filling the remaining unused area with
the ‘transparent’ colour. If you do not specify the correct size of the icon then the
unused area will be detected by the mouse.
Return value Returns a non-zero value for success or zero for failure.
See also A4<>E4N6A0?782BN82>=/
ADD_HYPERTEXT@
Purpose To add text to the hypertext system.
Syntax BD1A>DC8=4 033N7H?4AC4GC/ 1D554A B8I4 7C4GC=0<4
270A02C4A 1D554A 7C4GC=0<4
8=C464A B8I4
Description 033N7H?4AC4GC/ adds, to the hypertext resource base, a hypertext document
containing one or more hypertext topics. Note that this routine does not take a copy of
the hypertext data so you must ensure that the memory is not changed or discarded
before any hypertext processing is complete. The format code %ht is used to display
the hypertext resource. Resources may be included in the resource section of your
program/resource script.
See also 033N7H?4AC4GCNA4B>DA24/
ADD_HYPERTEXT_RESOURCE@
Purpose To open a hypertext resource that is included in a resource file.
Syntax BD1A>DC8=4 033N7H?4AC4GCNA4B>DA24/ =0<4
270A02C4A =0<4
Description The resource file must be added to combine the hypertext document with the program
using it. The resource filename should be placed on the F8=0?? line after the stack
and heap size declarations.
See %ht format and the browse example code included with the ClearWin+ release.
See also 033N7H?4ACC4GC/
332
Chapter 27 Library reference
Example
F8=0?? $ $ ³<H?A>6A2´
Where myprog.rc is a list of resources.
For example:
7H?B><48=5> 7H?4AC4GC X]U^ Wc\
ADD_KEYBOARD_MONITOR@
Purpose To name a call-back function that monitors the use of the keyboard.
Syntax BD1A>DC8=4 033N:4H1>0A3N<>=8C>A/ 21N5D=2
4GC4A=0; 21N5D=2
Description See 033N2DAB>AN<>=8C>A/. Keyboard call-back functions use the
2;40AF8=N8=5>/ parameter :4H1>0A3N:4H.
Notes This routine replaces 64CNF:4H/ and 64CNF:4H / and should be used in preference
to these routines. Calls to these routines will fail if 033N:4H1>0A3N<>=8C>A/ has
been called.
See also A4<>E4N:4H1>0A3N<>=8C>A/
ADD_MENU_ITEM@
Purpose To create a dynamic menu using %mn.
Syntax BD1A>DC8=4 033N<4=DN8C4</ 70=3;4 =0<4 4=01;4
2742: 20;;102:N5D=2C8>=
8=C464A 70=3;4 4=01;4 2742: 20;;102:N5D=2C8>=
270A02C4A =0<4
Description By using %mn, menu items can be added at run time. This is of greatest use when you
wish to show a file history or a list of open windows. Items are added one at a time to
the end of the pop down menu that contains the handle.
In %mn (see page 81) an asterisk (*) must be added where a text description would
previously have been placed and a integer argument, instead of a call-back, must be
provided to hold the 70=3;4.
For example:
333
ClearWin+ User’s Guide Fortran
X,fX]X^/³\]JFX]S^fJLL´70=3;4
70=3;4 can then be passed to 033N<4=DN8C4</.
=0<4 is the new string to put into the menu i.e. the new menu item. 4=01;4 controls
the enabling of the item (1 for enabled, zero for disabled, i.e. greyed) and the 2742:
will add or remove a tick character (1 for checked, zero for unchecked). A call-back
function must be provided so that ClearWin+ can act upon a menu selection. A
separator is obtained if =0<4 is input as 270A.
Example See page 83.
See also A4<>E4N<4=DN8C4</ %mn
ATTACH_BITMAP_PALETTE@
Purpose To attach a palette to a DC.
Syntax 8=C464A 0CC027N18C<0?N?0;4CC4/ 732 ?
8=C464A 732 ?
Description To attach a colour palette to a device context. This should not normally be needed as
B4CN2>;>DAB/ provides sufficient flexibility.
Return value On success 1 will be returned. -1 indicates that the screen type cannot provide the
palette requested due to too few palette entries available. A zero indicates that the
display is in full colour mode and therefore does not use a palette.
See also 02C8E0C4N18C<0?N?0;4CC4/
BOLD_FONT@
Purpose To change the current drawing surface text to/from bold.
Syntax BD1A>DC8=4 1>;3N5>=C/ 02C8E4
8=C464A 02C8E4
Description When using the function 3A0FN270A02C4AB/ on a drawing surface with any font
selected (other than a Hershey font), a call to this routine with a value of one will
make any further text output bold. A further call with a value of zero will reverse the
effect.
334
Chapter 27 Library reference
CHANGE_HYPERTEXT@
Purpose To change the topic in a hypertext control.
Syntax BD1A>DC8=4 270=64N7H?4AC4GC/ 7F=3 C>?82=0<4
8=C464A 7F=3
270A02C4A C>?82=0<4
Description C>?82=0<4 is the name of the topic to select (as in <DOC name = "doc_name">) and
7F=3 is the handle of the main window returned by %hw.
CHANGE_PEN@
Purpose To change the pen in a device context acquired through 64CN18C<0?N32/.
Syntax 8=C464A 5D=2C8>= 270=64N?4=/732?4=NBCH;4F83C72>;>DA
8=C464A 732?4=NBCH;4F83C72>;>DA
Description The pen associated with a device context acquired through 64CN18C<0?N32/ can be
changed using the Windows API function SelectObject. However, when using the
270=64N?4=/ function, ClearWin+ keeps track of which pens have been created, re-
uses them where possible and finally deletes them automatically. The style, width, and
colour arguments are as supplied to the Windows API function CreatePen.
Return value Always returns 1.
CHOOSE_COLOUR@
Purpose To display a standard Windows dialog box so that the user can select a colour.
Syntax 8=C464A 27>>B4N2>;>DA/
Return value This function returns the RGB value of the colour selected by the user or -1 if the
operation is cancelled. The user can use the dialog to define custom colours that are
available if the dialog is opened again before the program terminates (default values
are restored when the program restarts).
335
ClearWin+ User’s Guide Fortran
CHOOSE_FONT@
Purpose To display a standard Windows dialog box so that the user can select a font, its
attributes and its colour.
Syntax BD1A>DC8=4 27>>B4N5>=C/ A162>;>DA
8=C464A A612>;>DA
Description This function displays a dialog box that allows the user to select a font, its attributes
(bold, italic, underline, strikeout) and its colour. This becomes the font for the current
drawing surface. A162>;>DA is used for both input and output. On input it is the
colour that is initially selected in the dialog box. On output it is the RGB value
selected by the user.
If this font is to be restored after a change of font then you should call 64CN5>=CN83/
before the change and then B4;42CN5>=CN83/ to restore the font.
See also 64CN5>=CN83/, B4;42CN5>=CN83/, 27>>B4N2>;>DA/
CLEAR_BITMAP@
Purpose To clear a bitmap device context acquired by 64CN18C<0?N32/.
Syntax BD1A>DC8=4 2;40AN18C<0?/ 732
8=C464A 732
Description The bitmap associated with the given device context is cleared to the current Windows
background
See also 64CN18C<0?N32/ A4;40B4N18C<0?N32/ %dw
CLEAR_SCREEN@
Purpose To clear the drawing surface.
Syntax BD1A>DC8=4 2;40ANB2A44=/
Description 2;40ANB2A44=/ clears the current drawing surface to the default background.
336
Chapter 27 Library reference
CLEAR_WINDOW@
Purpose To clear a given ClearWin window to its given background colour.
Syntax BD1A>DC8=4 2;40ANF8=3>F/F
8=C464A F
Description All text written to the window will be cleared and all call-back requests deleted. This
is effectively ‘clear screen’ and leaves the window in a state as if it had just been
created. W is the window handle returned by 2A40C4NF8=3>F/.
CLEARWIN_FLOAT@
Purpose To access ClearWin+ parameters.
Syntax 3>D1;4 ?A428B8>= 5D=2C8>= 2;40AF8=N5;>0C/ ?0A0<
270A02C4A ?0A0<
Description Parameters are specified as case insensitive character strings. They may be system or
user-defined values.
Return value Returns the value of the specified floating point parameter.
See also B4CN2;40AF8=N5;>0C/
CLEARWIN_INFO@
Purpose To access ClearWin+ parameters.
Syntax 8=C464A 5D=2C8>= 2;40AF8=N8=5>/ ?0A0<
270A02C4A ?0A0<
Description Parameters are specified as case insensitive character strings. They may be system or
user-defined values.
The following parameters are defined:
02C8>=NG
Provides the X value of the control that has generated the call-back.
337
ClearWin+ User’s Guide Fortran
02C8>=NH
Provides the Y value of the control that has generated the call-back.
02C8E4N438CN1>G
Returns the address of the 438CN8=5> array of the currently active %eb box.
20;;N102:NF8=3>F
This option provides the call-back routine with the handle of the window generating
the call-back.
2DAB>ANF8=3>F
Used with 033N2DAB>AN<>=8C>A/ Gives the handle of the control which currently
has the cursor.
3A06643N82>=
Is set to the value of the handle for the dragged icon, indicating that a icon is currently
being dragged (see 033N6A0?782BN82>=/).
3A>??43N2>D=C
Used with the %dr call-back function to return the number of files dropped.
3A>??43N2DAA4=C
Used with the %dr call-back function to return the number of the current file being
processed (in the range from 1 to the value supplied by 3A>??43N2>D=C.
3A>??43N82>=
Is set to the value of the handle for the recently dropped icon (see
033N6A0?782BN82>=/).
438CN:4H
Used with %eb to get the ASCII value of the last key pressed.
5>2DBNF8=3>F
This parameter will return the Window handle of the window with focus, or zero if no
window of the application has the focus ( see %hw page 121).
5>2DBB43NF8=3>F
Used with 033N5>2DBN<>=8C>A/. Gives the handle of the control which currently
has the keyboard focus.
608=8=6N5>2DB
Returns 1 when an (%eb) edit box gains the focus.
685N<>DB4NG
Returns the pixel co-ordinate of a mouse click in a %gi image relative to the top left
corner of the image.
338
Chapter 27 Library reference
685N<>DB4NH
Returns the pixel co-ordinate of a mouse click in a %gi image relative to the top left
corner of the image.
6A0?782BN34?C7
Provides the ‘Y axis’ value for the graphics window, vital if the window is resized at
any point.
6A0?782BN32
Set during the call-back when a %dw[user_resize] graphics area is re-sized (or when it
is first created). The call-back can use this to re-draw the image.
6A0?782BN732
This provides the device context of the drawing surface. It will return zero if there is
no current drawing surface. Using this handle you can write additional information to
a drawing surface using API functions. The handle points to a bitmap so it is also
possible to extract information form this area. Do not use this handle with %gr if
\TcPUX[TNaTbXiT has been specified. If you use H84;3N?A>6A0<N2>=CA>;/, or if
you return from a call-back there is a possibility that the drawing surface will be re-
sized (replacing its handle) or closed. It is therefore important to obtain the handle
again in such circumstances. In general, obtain the handle, perform the actions you
require, and discard the handle.
6A0?782BNA4B8I8=6
This returns the value one if the window has been resized making it necessary to
interrogate 6A0?782BN34?C7 and 6A0?782BNF83C7.
6A0?782BNF83C7
Provides the ‘X axis’ value for the graphics window, vital if the window is resized at
any point.
6A0?782BN<>DB4N5;06B
Provides the flags associated with a mouse event in a graphics (%gr) or owner-draw
(%dw) control.
The flags should be considered as a set of bits thus:
<:N;1DCC>= 1 Left mouse button depressed
<:N;1DCC>= 2 Right mouse button depressed
<:NB785C 4 Keyboard shift key depressed
<:N2>=CA>; 8 Keyboard control key depressed
<:N<1DCC>= 16 Middle mouse button depressed
6A0?782BN<>DB4NG
Provide the X co-ordinate of a mouse event in a graphics (%gr) or owner-draw (%dw)
control.
339
ClearWin+ User’s Guide Fortran
6A0?782BN<>DB4NH
Provides the Y co-ordinate of a mouse event in a graphics (%gr) or owner-draw (%dw)
control.
8=C4A<4380C4NB2A>;;
Used with %hx and %vx to determine if the callback was called whilst the thumb is
moving or after its release. Returns the value 1 if the thumb is moving, otherwise zero.
;0C4BCN5>A<0CC43NF8=3>F
This is set to the Window handle of the most recently created formatted window. This
handle should be used with care. In particular, if you make explicit Windows API calls
using this handle, these may interfere with the action of fX]X^/.
;0C4BCNE0A801;4
Holds the address of a variable in a call-back attached to %rd, %rf or %rs.
;0C4BCNF8=3>F
Same as ;0C4BCN5>A<0CC43NF8=3>F
;8BC1>GN8C4<NB4;42C43
Used in a call-back function for a list box. Returns 1 if the item was “selected” by
double clicking on an item in the extended list; returns zero if the item was “moved to”
by using a single click.
;>B8=6N5>2DB
Returns 1 when an edit box (%eb) loses its focus.
<4BB064N7F=3
This is set to the HWND parameter in a call-back from the %mg format.
<4BB064N;?0A0<
This is set to the ;?0A0< parameter in a call-back from the %mg format.
<4BB064NF?0A0<
This is set to the F?0A0< parameter in a call-back from the %mg format.
>?4=6;N34?C7
Returns the handle of the device context for the current %og region.
>?4=6;N34E824N2>=C4GC
Returns the pixel depth of a resized OpenGL (%og) region.
>?4=6;NF83C7
Returns the pixel width of a resized OpenGL (%og) region.
?8G4;BN?4AN7ND=8C
Translates from device dependant units used by %aw etc. to absolute pixel values
340
Chapter 27 Library reference
?8G4;BN?4ANEND=8C
Translates from device dependant units used by %aw etc. to absolute pixel values
?A8=C4AN2>;;0C4 etc.
For printer parameters see page 192.
B2A44=N34?C7
Returns the vertical screen resolution. Note that the available area of the largest
possible window (the client area) will be normally be a little smaller than this because
of the caption, border, etc..
B2A44=NF83C7
Returns the horizontal screen resolution.
B744CN=>
Holds the value of the current top-most property sheet (%ps). Initially it is 1.
B?8=N2>=CA>;NDB43
This is set whilst in a call-back for a variable modified using a spin control.
C4GCN0AA0HN270A etc.
Parameters used with %tx are detailed on page 103.
CA44E84FN8C4<NB4;42C43
Returns the value one when an item has been selected from a treeview control (%tv) by
means of a double mouse click.
Return value Returns the value of the specified integer parameter.
See also B4CN2;40AF8=N8=5>/
CLEARWIN_STRING@
Purpose To obtain string information from ClearWin+.
Syntax 270A02C4A 5D=2C8>= 2;40AF8=NBCA8=6/ BCA
270A02C4A BCA
Description Parameters are specified as case insensitive character strings. They may be system or
user-defined values.
ClearWin+ maintains a set of system strings that contain information from the system.
The following have been defined:
20;;102:NA40B>=
See the end of this list.
341
ClearWin+ User’s Guide Fortran
2DAA4=CNC4GCN8C4< etc.
See Chapter 19.
2DAA4=CN<4=DN8C4<
This option will return a string containing the current menu item selected. It is
employed when using dynamic menus that have a shared call-back (see page 81).
3A>??43N58;4
Is a string containing the full path and filename of the object dropped into a format
window using %dr.
20;;102:NA40B>=
Whenever a call-back function is invoked, this string can be used to determine the
reason for the call. The following list of reasons (upper case letters only) may be
extended in the future, so programs should be designed to ignore reasons which they
do not recognise.
30C0N0;C4A0C8>= The contents of %eb, %rd (etc.) box have been altered.
342
Chapter 27 Library reference
CLEARWIN_VERSION@
Purpose Gets the current ClearWin+ version information.
Syntax 8=C464A 5D=2C8>= 2;40AF8=NE4AB8>=/
Return value The minor version number is stored in the lower byte of the returned value and the
major version number is stored in the second byte.
Example
F8=0??
8=2;D34 +fX]S^fbX]b-
343
ClearWin+ User’s Guide Fortran
8=C464A eTabX^] X
eTabX^],R[TPafX]NeTabX^]/
X,fX]X^/RPJETabX^] X]U^a\PcX^]L
X,fX]X^/][<PY^a fS \X]^afS][
eTabX^]!$%0=3eTabX^]!$$
4=3
CLIPBOARD_TO_SCREEN_BLOCK@
Purpose To copy a bitmap on the clipboard to a DIB.
Syntax 8=C464A 5D=2C8>= 2;8?1>0A3NC>NB2A44=N1;>2:/ 7381
8=C464A 7381
Description This function copies a bitmap from the clipboard and returns a handle to the device
independent bitmap that it creates. This handle can then be used, for example, with
381N?08=C/, ?A8=CN381/ and 4G?>ACN1<?/.
Return value A return value of zero indicates a failure (e.g. the current clipboard data is of the
wrong type).
See also 64CNB2A44=N181/, A4;40B4NB2A44=N381/, 8<?>ACN1<?/
CLOSE_CD_TRAY@
Purpose To close an open CD-drive tray.
Syntax BD1A>DC8=4 2;>B4N23NCA0H/
Description Simply by calling this routine any open CD drive with a mechanical drawer will close.
See also >?4=N23NCA0H/ ?;0HN0D38>N23/ B4CN23N?>B8C8>=/ BC>?N0D38>N23/
Example
F8=0??
8=C464A XRca[fX]X^/
4GC4A=0; RQN^_T]RQNR[^bT
Rca[,
X,fX]X^/RPJ23 CaPh 2^]ca^[L][
X,fX]X^/MQcJ>?4=L MQcJ2;>B4L[fRQN^_T]RQNR[^bTRca[
4=3
8=C464A 5D=2C8>= RQN^_T]
X]R[dST +fX]S^fbX]b-
344
Chapter 27 Library reference
20;; ^_T]NRSNcaPh/
RQN^_T],!
4=3
8=C464A 5D=2C8>= RQNR[^bT
8=2;D34 +fX]S^fbX]b-
20;; R[^bTNRSNcaPh/
RQNR[^bT,!
4=3
CLOSE_METAFILE@
Purpose To close a previously opened metafile.
Syntax 8=C464A 2;>B4N<4C058;4/ 70=3;4
8=C464A 70=3;4
Description If 70=3;4 is zero then the current drawing surface is used otherwise a handle to an
existing drawing surface should be supplied.
See also >?4=N<4C058;4/ <4C058;4NC>N2;8?1>0A3/ ?;0HN2;8?1>0A3N<4C058;4/
CLOSE_PRINTER@
Purpose To output to a graphics printer or plotter.
Syntax 8=C464A 5D=2C8>= 2;>B4N?A8=C4A/ 70=3;4
8=C464A 70=3;4
Description See >?4=N?A8=C4A/. If 70=3;4 is zero, the current printer is closed.
Return value Returns 1 for success or zero for failure.
See also 3>N2>?84B/ >?4=N?A8=C4A/ B4;42CN?A8=C4A/
CLOSE_PRINTER_ONLY@
Purpose To close a graphics printer or plotter without output.
Syntax 8=C464A 5D=2C8>= 2;>B4N?A8=C4AN>=;H/ 70=3;4
8=C464A 70=3;4
345
ClearWin+ User’s Guide Fortran
Description Use this function instead of 2;>B4N?A8=C4A/ if you what to abort a printing process
without output. See >?4=N?A8=C4A/.
Return value Returns 1 for success or zero for failure.
See also 2;>B4N?A8=C4A/
CLOSE_WAV_FILE@
Purpose To close a WAV file opened by >?4=NF0EN58;4NA403/ or
>?4=NF0EN58;4NFA8C4/.
Syntax BD1A>DC8=4 2;>B4NF0EN58;4/70=3;4
8=C464A 70=3;4
Description This routine closes a WAV file opened for reading or writing. It is particularly
important to call this routine to close a file open for writing before the program
terminates.
COPY_FROM_CLIPBOARD@
Purpose To copy data from the clipboard.
Syntax 8=C464A 5D=2C8>= 2>?HN5A><N2;8?1>0A3/ 1D554A =D< CH?4
270A02C4A 1D554A
8=C464A =D< CH?4
Description Use this routine to copy anything from the clipboard. The following data types can
exist in the clipboard, though not all are directly supported by Clearwin+:
25N18C<0? Bitmap data
25N381 A 18C<0?8=5> structure followed by a bitmap
25N385 Data interchange format
25N3B?18C<0? Private data stored in a bitmap format
25N3B?<4C058;4?82C Private data stored in metafile format
25N3B?C4GC Private data stored in text format
25N<4C058;4?82C The data is in metafile format
25N>4<C4GC The data is in OEM text format
25N>F=4A38B?;0H The data is a private format
25N?0;4CC4 A palette
346
Chapter 27 Library reference
8=C464A PSSa[T]X
270A02C4A QdUUTa !#
[T],bXiT^UNR[X_Q^PaSNcTgc/
85[T]6CC74=
20;; VTcNbc^aPVT/PSSa[T]
85PSSa6CC74=
X,R^_hNUa^\NR[X_Q^PaS/PSSa[T] 25NC4GC
20;; \^eT/QdUUTa22>A4 PSSa[T]
4=385
4=385
COPY_GRAPHICS_REGION@
Purpose To copy screen blocks in drawing surfaces defined by %gr etc..
Syntax 8=C464A 5D=2C8>= 2>?HN6A0?782BNA468>=/
34BCN6A 3G 3H 3F83C7 374867C
BA2N6A BG BH BF83C7 B74867C 2>?HN<>34
8=C464A 34BCN6A 3G 3H 3F83C7 374867C
BA2N6A BG BH BF83C7 B74867C 2>?HN<>34
Description You must have at least one drawing surface open (see for example %`gr on page 136).
34BCN6A is the handle of the destination drawing surface and BA2N6A is the source
drawing surface, however, the handles specified can be the same. If you set either or
both to zero then the current drawing surface is assumed for the source and/or
destination.
347
ClearWin+ User’s Guide Fortran
3G 3H 3F83C7 and 374867C specify the destination rectangular region.
BG BH BF83C7 and B74867C specify the source rectangular region.
If 3F83C7 = BF83C7 and 374867C = B74867C then a normal copy will occur. If
there are any differences then the image will be ‘stretched’ accordingly.
2>?HN<>34 defines the method of copying. Windows defines 255 different copy
methods (ROPS). The most useful are described below:
COPY_TO_CLIPBOARD@
Purpose To copy data to the clipboard.
Syntax 8=C464A 5D=2C8>= 2>?HNC>N2;8?1>0A3/ 1D554A =D< CH?4
348
Chapter 27 Library reference
270A02C4A 1D554A
8=C464A =D< CH?4
Description =D< contents of 1D554A will be placed into the Windows clipboard and will be of the
CH?4 specified. For a list of the available data types see the
2>?HN5A><N2;8?1>0A3/ function.
Return value Returns 1 on success or zero on failure.
See also 2>?HN5A><N2;8?1>0A3/2;8?1>0A3NC>NB2A44=N1;>2:/
6A0?782BNC>N2;8?1>0A3/ B8I4>5N2;8?1>0A3NC4GC/
CREATE_BITMAP@
Purpose To create a bitmap from bitmap data.
Syntax 8=C464A 5D=2C8>= 2A40C4N18C<0?/ ?CA
8=C464A ?CA
Description Creates a bitmap from a pointer to data that is in the same format as a .BMP file.
When the program is terminated the bitmap will be deleted. The function returns a
handle that can be used with %`bm or in Windows API functions that require a
HBITMAP handle.
Return value Returns a handle to the new bitmap. A zero return indicates failure.
See also <0:4N18C<0?/
CREATE_CURSOR@
Purpose To create a cursor from data in a .CUR file.
Syntax 8=C464A 5D=2C8>= 2A40C4N2DAB>A/ ?CA
8=C464A ?CA
Description Creates a cursor from a pointer to data that is in the same format as a .CUR file. When
the program is terminated the cursor will be deleted. The function returns a handle
that can be used, for example, with %`cu or in Windows API functions that require a
HCURSOR handle.
Return value Returns a handle to the new cursor. A zero return indicates failure.
349
ClearWin+ User’s Guide Fortran
CREATE_GRAPHICS_REGION@
Purpose To create an internal (off-screen) drawing surface.
Syntax 8=C464A 5D=2C8>= 2A40C4N6A0?782BNA468>=/ 70=3;4
F83C7 74867C
8=C464A 70=3;4 F83C7 74867C
Description This routine is used to create internal drawing surfaces. For example, it can be used to
display part of a large bitmap. Areas of the buffer can be copied into a %gr region (for
example) using 2>?HN6A0?782BNA468>=/. If you make extensive use of this
function it is recommended that you delete unwanted surfaces with a call to
34;4C4N6A0?782BNA468>=/.
70=3;4 is an input value, chosen by the programmer, that must be unique. It is used
to identify the surface in calls to related functions. F83C7 74867C specify the size
in pixels of the region.
The colour mode for the surface will be determined by the default colour mode or by
the colour mode of the current %gr drawing surface.
Return value Returns 1 for success, otherwise zero.
See also 34;4C4N6A0?782BNA468>=/ 2>?HN6A0?782BNA468>=/ B2A>;;N6A0?782B/
CREATE_WINDOW@
Purpose To create and display a ClearWin window.
Syntax 8=C464A 5D=2C8>= 2A40C4NF8=3>F/C8C;4GHGFHF
8=C464A GHGFHF
270A02C4A C8C;4
Description Creates a window of width GF, height HF and title C8C;4 at position (GH).
Do not confuse this function with the similarly named routine in the Windows API
called CreateWindow.
Return value Returns a standard Windows handle.
350
Chapter 27 Library reference
DEFINE_FILE_EXTENSION@
Purpose Allows application registry under Windows 95.
Syntax BD1A>DC8=4 3458=4N58;4N4GC4=B8>=/4GC=0<4 ?0C7
34B2A 82>=N83G =4F
270A02C4A !( =0<4 ?0C7 34B2A8?C8>=
8=C464A 82>=N8=34G =4F >?C8>=
Description Under Windows 95 it is possible to register an application with the system so that if a
data file is opened via Explorer your application will be called to process it.
The 4GC=0<4 variable is a string that contains the extension, the ?0C7 must contain
the full path and program name. A text description should be supplied in
34B2A8?C8>=. The 82>=N8=34G selects the icon to be used by Windows. If you
specify -1 no icon is used otherwise the relevant icon is used. i.e. if you have four
icons in your resource, by placing a value of 2 in 82>=N8=34G the second icon
resource will be used. =4F >?C8>= option should be set to a non zero value to activate
the file type addition to Windows 95.
For example:
270A02C4A !( _]P\T
20;; VTcN_a^VaP\N]P\T/_]P\T
Z,STUX]TNUX[TNTgcT]bX^]/³82>´_]P\T
³8R^] UX[T TSXc^a´
You can obtain the file name passed to your program, by Windows 95 as if you were
examining the arguments on the command line.
For example:
...
270A02C4A !( R\]P\/UX[Tc^^_T]
UX[Tc^^_T],R\]P\/
...
351
ClearWin+ User’s Guide Fortran
DELETE_GRAPHICS_REGION@
Purpose To remove an internal drawing surface.
Syntax 8=C464A 5D=2C8>= 34;4C4N6A0?782BNA468>=/ 70=3;4
8=C464A 70=3;4
Description This routine will remove from memory a drawing surface that has previously been
defined by 2A40C4N6A0?782BNA468>=/. 70=3;4 is the value used in an earlier
call to 2A40C4N6A0?782BNA468>=/.
Return value Returns 1 for success, otherwise zero.
See also 2A40C4N6A0?782BNA468>=/ 2>?HN6A0?782BNA468>=/ B2A>;;N6A0?782B/
DESTROY_WINDOW@
Purpose To close and destroy a displayed ClearWin window.
Syntax BD1A>DC8=4 34BCA>HNF8=3>F/F
8=C464A F
Description Destroys a window specified by F and any child windows that may be owned by it.
Fonts owned by the window are not destroyed. W is the window handle returned by
2A40C4NF8=3>F/.
DIB_PAINT@
Purpose To display a device independent bitmap (DIB).
Syntax 8=C464A 5D=2C8>= 381N?08=C/ 7>A8I E4AC 7381
5D=2C8>= <>34
8=C464A 7>A8I E4AC 7381 5D=2C8>= <>34
Description Displays the DIB with handle 7381 on the current device with 7>A8I and E4AC
relative displacement (they may be negative). 5D=2C8>= selects the type of logical
restore operation with respect to the previous screen :
0 REPLACE former pixel
1 AND with former pixel
2 OR with former pixel
352
Chapter 27 Library reference
DISPLAY_DIB_BLOCK@
Purpose To display a device independent bitmap.
Syntax BD1A>DC8=4 38B?;0HN381N1;>2:/ GH?0AA0H0F070G0HF7
5D=2C8>=<>344A2>34
270A02C4A ?0AA0H"0F07
8=C464A GH0F070G0HF75D=2C8>=<>344A2>34
Description All of the arguments are input values except for 4A2>34 which returns the error status.
This routine transfers a rectangular block of size F × 7 from the array ?0AA0H at
position (0G, 0H) to the position (G, H) on the current graphics device (e.g. a %gr
window or a printer). 5D=2C8>= and <>34 are the same as in 381N?08=C/ and will
normally be set to zero. The variable 4A2>34 is returned as zero if the process is
successful.
See also 64CN8<N8=5>/ 64CN381NB8I4/ 64CN381N1;>2:/ ?DCN381N1;>2:/
?A8=CN381/
Example See page 145.
DISPLAY_POPUP_MENU@
Purpose To activate a popup menu defined using %pm.
Syntax BD1A>DC8=4 38B?;0HN?>?D?N<4=D/
353
ClearWin+ User’s Guide Fortran
Description This subroutine will activate a pre-defined popup menu. It can be used when the right
mouse button is pressed over a %gr drawing surface that has 5D;;N<>DB4N8=?DC
activated (see page 136).
DO_COPIES@
Purpose To produce multiple printer copies of a graphics image using metafiles.
Syntax 8=C464A 3>N2>?84B/ 70=3;4 =D<
8=C464A 70=3;4 =D<
Description Sends =D< copies to the printer. A metafile must have been created with a call to
>?4=N<4C058;4/ and also closed by 2;>B4N<4C058;4/ before 3>N2>?84B/ can be
used. The 2;40AF8=N8=5>/ parameter ?A8=C4AN2>?84B will return the number of
copies the user has selected.
The call to 2;>B4N?A8=C4A/ will have automatically sent one copy to the printer.
See also >?4=N?A8=C4A/ 2;>B4N?A8=C4A/
Example See page 195.
DRAW_BEZIER@
Purpose To draw a Bezier spline.
Syntax BD1A>DC8=4 3A0FN14I84A/ G H = 2>;>DA
8=C464A G=H==2>;>DA
Description G and H are arrays giving the co-ordinates of the = knots and 2>;>DA is the colour
value using the current colour mode.
DRAW_CHARACTERS@
Purpose To draw text on the current drawing surface.
Syntax BD1A>DC8=4 3A0FN270A02C4AB/BCA878E82>;
270A02C4A BCA
8=C464A 878E82>;
354
Chapter 27 Library reference
Description 3A0FN270A02C4AB/ draws text, using the current font and attributes, at the point (87,
8E). These co-ordinates represent the bottom left-hand corner of the first character.
BCA contains the character string to be drawn. The text is positioned to the nearest
pixel. 82>; provides the colour for the text that appears on the existing background
using the current colour mode.
See also B4;42CN5>=C/ B20;4N5>=C/ D=34A;8=4N5>=C/ 8C0;82N5>=C/
1>;3N5>=C/ B8I4N8=N?8G4;B/ B8I4N8=N?>8=CB/ A>C0C4N5>=C/
64CN5>=CN=0<4/ 27>>B4N5>=C/.
DRAW_ELLIPSE@
Purpose To draw an ellipse on the current drawing surface.
Syntax BD1A>DC8=4 3A0FN4;;8?B4/8G28H2808182>;
8=C464A 8G28H2808182>;
Description 3A0FN4;;8?B4/ draws an ellipse with centre at (8G2, 8H2), with horizontal semi-
axis 80, vertical semi-axis 81 and colour 82>; using the current colour mode. This
routine can be used to produce a circle on the drawing surface if the axes are scaled
appropriately.
See also 3A0FN58;;43N4;;8?B4/
DRAW_FILLED_ELLIPSE@
Purpose To fill an ellipse on the current drawing surface.
Syntax BD1A>DC8=4 3A0FN58;;43N4;;8?B4/8G28H2808182>;
8=C464A 8G28H2808182>;
Description 3A0FN58;;43N4;;8?B4/ fills an ellipse with centre at (8G2, 8H2), with horizontal
semi-axis 80, vertical semi-axis 81 and colour 82>; using the current colour mode.
This routine can be used to fill a circle if the axes are scaled appropriately.
See also 3A0FN4;;8?B4/
355
ClearWin+ User’s Guide Fortran
DRAW_FILLED_POLYGON@
Purpose To fill a polygon on the current drawing surface.
Syntax BD1A>DC8=4 3A0FN58;;43N?>;H6>=/8G8H=82>;
8=C464A 8G=8H=
8=C464A =82>;
Description 3A0FN58;;43N?>;H6>=4/ draws a straight line from (8G(1), 8H(1)) to (8G(2),
8H(2)), and continues until (8G(=), 8H(=)) and fills the enclosed region. 82>;
specifies the fill colour value using the current colour mode.
See also 3A0FN?>;H;8=4/
DRAW_FILLED_RECTANGLE@
Purpose To fill a rectangle on the current drawing surface.
Syntax BD1A>DC8=4 3A0FN58;;43NA42C0=6;4/8G 8H 8G!8H!82>;
8=C464A 8G 8H 8G!8H!82>;
Description 3A0FN58;;43NA42C0=6;4/ fills a rectangle in colour 82>; using the current colour
mode. (8G , 8H ) and (8G!,8H!) are opposite corners.
See also 3A0FNA42C0=6;4/
DRAW_LINE_BETWEEN@
Purpose To draw a straight line on the current drawing surface.
Syntax BD1A>DC8=4 3A0FN;8=4N14CF44=/8G 8H 8G!8H!82>;
8=C464A 8G 8H 8G!8H!82>;
Description 3A0FN;8=4N14CF44=/ draws a line with colour value 82>; using the current
colour mode) from (8G , 8H ) to (8G!, 8H!). The coordinates are pixel numbers
relative to the top left of the drawing surface.
See also 3A0FN?>;H;8=4/
356
Chapter 27 Library reference
DRAW_POINT@
Purpose To set a single pixel colour on the current drawing surface.
Syntax BD1A>DC8=4 3A0FN?>8=C/878E82>;
8=C464A 878E82>;
Description 3A0FN?>8=C/ sets the pixel at (87,8E) on the current drawing surface to colour value
82>; using the current colour mode.
See also 64CN?>8=C/, 64CNA61NE0;D4/
DRAW_POLYLINE@
Purpose To draw a number of connected straight lines.
Syntax BD1A>DC8=4 3A0FN?>;H;8=4/8G8H=82>;
8=C464A 8G=8H=
8=C464A =82>;
Description 3A0FN?>;H;8=4/ draws a straight line from (8G(1), 8H(1)) to (8G(2), 8H(2)), and
continues until (8G(=), 8H(=)). That is, it joins = points with straight lines. 82>;
specifies the colour value using the current colour mode. For a closed polygon, simply
set the last pair of coordinates equal to the first pair.
See also 3A0FN;8=4N14CF44=/, 3A0FN58;;43N?>;H6>=/
DRAW_RECTANGLE@
Purpose To draw a rectangle on the current drawing surface.
Syntax BD1A>DC8=4 3A0FNA42C0=6;4/8G 8H 8G!8H!82>;
8=C464A 8G 8H 8G!8H!82>;
Description 3A0FNA42C0=6;4/ draws a rectangle in colour 82>; using the current colour mode.
(8G , 8H ) and (8G!, 8H!) are opposite corners.
357
ClearWin+ User’s Guide Fortran
EXPORT_BMP@
Purpose To exports a device independent bitmap to a .BMP file.
Syntax BD1A>DC8=4 4G?>ACN1<?/ 7381 58;4=0<4 4AA>A
8=C464A 381N70=3;44AA>A
270A02C4A 58;4=0<4
Description Writes a DIB to a bitmap file specified by 58;4=0<4. 7381 is a handle returned for
example by 64CNB2A44=N381/, 2;8?1>0A3NC>NB2A44=N1;>2:/ or
8<?>ACN1<?/.
EXPORT_PCX@
Purpose To export a device independent bitmap to a .PCX file.
Syntax BD1A>DC8=4 4G?>ACN?2G/ 7381 58;4=0<4 4AA>A
8=C464A 381N70=3;44AA>A
270A02C4A 58;4=0<4
Description Writes a DIB to a PCX file specified by 58;4=0<4. 7381 is a handle returned for
example by 64CNB2A44=N381/, 2;8?1>0A3NC>NB2A44=N1;>2:/ or
8<?>ACN?2G/.
4AA>A returns one of the following:
success
unable to open file
" unable to write to file
See also 8<?>ACN?2G/ FA8C4N6A0?782BNC>N?2G/ 381N?08=C/ ?A8=CN381/
358
Chapter 27 Library reference
FEED_WKEYBOARD@
Purpose To insert a key into a ClearWin window keyboard buffer.
Syntax BD1A>DC8=4 5443NF:4H1>0A3/:4H4AA>A
8=C464A :4H4AA>A
Description This routine is only for use in a ClearWin window (e.g. with %cw). :4H is the ASCII
code for the key to be inserted. Currently 4AA>A always returns zero for success.
See also 5;DB7NF:4H1>0A3/ 64CNF:4H/ 64CNF:4H / F:4HNF08C8=6/
FILL_SURFACE@
Purpose To fill an area of the current drawing surface with a given colour.
Syntax BD1A>DC8=4 58;;NBDA5024/ GBC0AC HBC0AC BDA5N2>;
58;;N2>;
8=C464A GBC0AC HBC0AC BDA5N2>; 58;;N2>;
Description GBC0AC, HBC0AC are the co-ordinates of the focus, 58;;N2>; is the colour to fill with
and BDA5N2>; is the current colour of the region to fill. The colour values relate to
the current colour mode.
See also 58;;NC>N1>A34A/
FILL_TO_BORDER@
Purpose To fill an area of the current drawing surface with a given colour.
Syntax BD1A>DC8=4 58;;NC>N1>A34A/ GBC0AC HBC0AC 58;;N2>;
BC>?N2>;
8=C464A GBC0AC HBC0AC 58;;N2>; BC>?N2>;
Description GBC0AC, HBC0AC are the co-ordinates of the focus, 58;;N2>; is the colour to fill with
and BC>?N2>; is the colour of the closed boundary of the area to fill. The colour
values relate to the current colour mode
See also 58;;NBDA5024/
359
ClearWin+ User’s Guide Fortran
FLUSH_WKEYBOARD@
Purpose To empty a ClearWin window keyboard buffer.
Syntax BD1A>DC8=4 5;DB7NF:4H1>0A3/
Description This routine is only for use in a ClearWin window (e.g. with %cw).
See also 5443NF:4H1>0A3/ 64CNF:4H/ 64CNF:4H / F:4HNF08C8=6/
FONT_METRICS@
Purpose To get the system metrics for the default font and the current drawing surface.
Syntax BD1A>DC8=4 5>=CN<4CA82B/ <4CA82B
8=C464A <4CA82B!
Description The array is returned with values for the following 20 system metrics:
Height, Ascent, Descent, InternalLeading, ExternalLeading, AveCharWidth,
MaxCharWidth, Weight, Overhang, DigitizedAspectX, DigitizedAspectY,
FirstChar, LastChar, DefaultChar, BreakChar, Italic, Underlined, StruckOut,
PitchAndFamily, CharSet.
GET_BITMAP_DC@
Purpose To obtain the device context of a bitmap which may be written to using the Windows
API graphics functions and used in a %dw format.
Syntax 8=C464A 5D=2C8>= 64CN18C<0?N32/ 7N18CB EN18CB
8=C464A 7N18CBEN18CB
Description The bitmap is created of size 7N18CB × EN18CB pixels. The device context can be
destroyed by A4;40B4N18C<0?N32/ but will be returned to the system at normal
program termination.
A4;40B4N18C<0?N32/ should be used when multiple bitmaps are created and when
they need not be saved.
Return value The function returns a handle to the device context.
See also 2;40AN18C<0?/ A4;40B4N18C<0?N32/ %dw
360
Chapter 27 Library reference
GET_CLEARWIN_TEXT@
Purpose To get text from a ClearWin window.
Syntax 8=C464A 5D=2C8>= 64CN2;40AF8=NC4GC/ F8=1D554A2>?H
8=C464A F8=2>?H
270A02C4A 1D554A
Description F8= is the handle of ClearWin window in question. To obtain the handle of the default
window use:
F8=,64CN3450D;CNF8=3>F/
Return value If 2>?H is zero, the function returns the length of the required buffer but no data is
copied. If 2>?H is 1, the data is also copied to the buffer.
GET_CURRENT_DC@
Purpose To get the device context of the current drawing surface.
Syntax BD1A>DC8=4 64CN2DAA4=CN32/ 32
8=C464A 32
See also B4;42CN6A0?782BN>1942C/
GET_DEFAULT_WINDOW@
Purpose To return the handle of the current default ClearWin window for standard Fortran I/O.
Syntax 8=C464A 5D=2C8>= 64CN3450D;CNF8=3>F/
GET_DIB_BLOCK@
Purpose To read a BMP format file into a character array.
Syntax BD1A>DC8=4 64CN381N1;>2:/ 58;4=0<4 ?0AA0H 0F 07 03G
03H F 7 3G 3H 4A2>34
270A02C4A 58;4=0<4
270A02C4A ?0AA0H"0F07
361
ClearWin+ User’s Guide Fortran
8=C464A 0F0703G03HF73G3H4A2>34
Description All of the arguments are input values except for ?0AA0H which contains the returned
data and 4A2>34 which returns the error status.
The first dimension of ?0AA0H is used to store the red, green and blue values for each
pixel. 4A2>34 will return:
BD224BB
! A403 4AA>A
# <4<>AH 4AA>A
$ =>C 0 1<? 58;4
103 58;4
" 103 =D<14A
% >C74A 4AA>A
See also 64CN381NB8I4/ ?DCN381N1;>2:/ 381N1;>2:N?08=C/
Example See page 145.
GET_DIB_SIZE@
Purpose To get information from a BMP data file.
Syntax BD1A>DC8=4 64CN381NB8I4/ 58;4=0<4 F83C7 74867C =11?
4A2>34
270A02C4A 58;4=0<4
8=C464A F83C7 74867C =11? 4A2>34
Description This routine is similar to 64CN8<N8=5>/ but returns the number of bits per pixel
=11? as follows:
362
Chapter 27 Library reference
GET_FILTERED_FILE@
Purpose To access the standard ‘open’ dialog box.
Syntax BD1A>DC8=4 64CN58;C4A43N58;4/C8C;4 58;4 ?0C7
58;C4A=0<4B 58;C4AB?42B =58;C4AB <DBC4G8BC
270A02C4A C8C;4 58;4 ?0C7 58;C4A=0<4B
58;C4AB?42B
8=C464A =58;C4AB <DBC4G8BC
Description This function can be used instead of %fs and %ft in cases where the filters need to be
set dynamically. The arguments are as follows.
363
ClearWin+ User’s Guide Fortran
Example
F8=0??
8=C464A XfX]X^/^_T]NUd]R
4GC4A=0; ^_T]NUd]R
X,fX]X^/RPJ8\PVT X]U^L
X,fX]X^/\]J5X[TJ>_T]4gXcLL^_T]NUd]R4G8C
4=3
R
8=C464A 5D=2C8>= ^_T]NUd]R
8=2;D34 +fX]S^fbX]b-
270A02C4A UX[T !(U^a\Pc !cXc[T!_PcW !(
8=C464A =58;C4AB
?0A0<4C4A=58;C4AB,!
270A02C4A! UX[c]P\T=58;C4ABUX[cb_TR=58;C4AB
cXc[T,>_T] 1Xc\P_ 5X[T
UX[T,
_PcW,R)KfX]S^fb
UX[c]P\T ,1Xc\P_ UX[Tb
UX[cb_TR ,Q\_
UX[c]P\T!,0[[ UX[Tb
UX[cb_TR!,
20;; VTcNUX[cTaTSNUX[T/cXc[TUX[T_PcWUX[c]P\TUX[cb_TR
=58;C4AB
^_T]NUd]R,
4=3
GET_FONT_ID@
Purpose To get the current font identifier.
Syntax BD1A>DC8=4 64CN5>=CN83/ 83
8=C464A 83
Description 83 is returned as the identifier of the font for the current drawing surface.
See also 27>>B4N5>=C/, B4;42CN5>=CN83/
364
Chapter 27 Library reference
GET_FONT_NAME@
Purpose To return the name of the loaded font.
Syntax BD1A>DC8=4 64CN5>=CN=0<4/ =0<4 =D<
270A02C4A =0<4
8=C464A =D<
Description The name of an installed font is returned in the =0<4 parameter. =D< references the
installed fonts and should start at 1. If a call is made and there is no associated font to
the number supplied an empty string will be returned.
Example 8=2;D34 +fX]S^fbX]b-
270A02C4A! ]P\T
3> Z, "
20;; VTcNU^]cN]P\T/]P\TZ
85]P\T4@ BC>?
?A8=C ]P\T
4=33>
4=3
GET_GRAPHICAL_RESOLUTION@
Purpose To determine the width and height of the current drawing surface.
Syntax BD1A>DC8=4 64CN6A0?7820;NA4B>;DC8>=/ F83C7 74867C
8=C464A F83C7 74867C
Description F83C7 and 74867C are set to the values for the current drawing surface.
GET_GRAPHICS_SELECTED_AREA@
Purpose To get the current %gr ‘rubber-band’ selection.
Syntax BD1A>DC8=4 64CN6A0?782BNB4;42C43N0A40/G H G!H!
8=C464A G H G! H!
Description The four parameters are set to the values of the current graphics selection which is
defined by the ‘rubber-band’ line activated with a call to
B4CN6A0?782BNB4;42C8>=/. The selection mode must be set to either 1 or 2 before
365
ClearWin+ User’s Guide Fortran
GET_IM_INFO@
Purpose To obtain information from a graphics file.
Syntax BD1A>DC8=4 64CN8<N8=5>/ 58;4=0<4 F83C7 74867C
=1N2>;>DAB =1N8<064B 5>A<0C 4AA>A
270A02C4A 58;4=0<45>A<0C
8=C464A F83C7] 74867C] =1N2>;>DAB]
8=C464A =1N8<064B 4AA>A
Description This subroutine accesses the information that is contained within a .1<? or .?2G file
supplied in 58;4=0<4. The relevant data is returned in the supplied parameters. The
F83C7 and 74867C will contain the dimension of the image. F83C7, 74867C and
=1N2>;>DAB are arrays. =1N8<064B is returned as the number of images and ]
should set at a value which is always greater than or equal to =1N8<064B. 5>A<0C
will be returned as a single character string, either ‘BMP’ or ‘PCX’.
4AA>A will return:
BD224BB
! A403 4AA>A
$ =>C 0 1<? 58;4
103 58;4
$ D=:=>F= 5>A<0C
See also 64CN381NB8I4/
GET_MATCHED_COLOUR@
Purpose To find the closest RGB colour match for the current drawing surface.
Syntax 8=C464A 5D=2C8>= 64CN<0C2743N2>;>DA/2>;>DA
8=C464A 2>;>DA
Description 64CN<0C2743N2>;>DA/ selects the RGB palette colour that is the best match to the
366
Chapter 27 Library reference
supplied RGB 2>;>DA on the current drawing surface. An error condition arises if
RGB colour mode is not selected on the current drawing surface. If there is no current
drawing surface then the function returns its input value. Likewise, the function
returns its input value if the region is a printer or if the graphics device is a high colour
device (i.e. more than 8 bits per pixel).
Return value Returns the closest match for the current drawing surface.
See also 64CN=40A4BCNB2A44=N2>;>DA/ DB4NA61N2>;>DAB/
Example See page 155.
GET_MOUSE_INFO@
Purpose To obtain the position of the mouse, the mouse buttons, and the keyboard shift keys at
the time when the last owner-draw (%^dw) or graphics region (%^gr) call-back
function was called.
Syntax BD1A>DC8=4 64CN<>DB4N8=5>/ G H 5;06B
8=C464A GH5;06B
Description This routine should be called immediately on entry to the call-back function. It does
not make sense to call this function in other contexts. The G and H values are pixel
positions relating to the bitmap associated with the format code (%gr or %dw). Pixel
co-ordinates are measures from (0,0) at the top left corner of the area. 5;06B contains
the following flags (the parameters will be found in windows.ins):
<:N;1DCC>= 1 Left mouse button depressed
<:NA1DCC>= 2 Right mouse button depressed
<:NB785C 4 Keyboard shift key depressed
<:N2>=CA>; 8 Keyboard control key depressed
<:N<1DCC>= 16 Middle mouse button depressed
Notes 2;40AF8=N8=5>/ can be used instead. These values are returned using
6A0?782BN<>DB4N5;06B, 6A0?782BN<>DB4NG and 6A0?782BN<>DB4NH.
367
ClearWin+ User’s Guide Fortran
GET_NEAREST_SCREEN_COLOUR@
Purpose To find the closest colour match for the screen from the system palette.
Syntax 8=C464A 5D=2C8>= 64CN=40A4BCNB2A44=N2>;>DA/2>;>DA
8=C464A 2>;>DA
Return value Returns the RGB colour from the Windows system palette that will be displayed when
the specified colour value is used on the screen (the value returned by the Windows
API function GetNearestColor).
Notes You can use this function to provide a colour for a drawing surface if you want to over-
ride the colour matching carried out automatically by ClearWin+. See page 156 for
further details.
See also 64CN<0C2743N2>;>DA/
GET_POINT@
Purpose To get a pixel colour on the current drawing surface.
Syntax BD1A>DC8=4 64CN?>8=C/878E82>;
8=C464A 878E82>;
Description 64CN?>8=C/ gets the colour value 82>; using the current colour mode of the pixel at
(87, 8E) on the current drawing surface. The colour value is given in terms of the
current colour mode of the surface.
See also 64CNA61NE0;D4/, 3A0FN?>8=C/
GET_PRINTER_ORIENTATION@
Purpose To get the printer orientation as portrait or landscape.
Syntax 8=C464A 64CN ?A8=C4AN>A84=C0C8>=/
Return vlaue Returns 0 for portrait and 1 for landscape.
368
Chapter 27 Library reference
GET_RGB_VALUE@
Purpose To get the RGB value of the colour of a pixel on the current drawing surface.
Syntax BD1A>DC8=4 64CNA61NE0;D4/ 7>A E4A E0;D4
8=C464A 7>AE4AE0;D4
Description The horizontal and vertical co-ordinates locate the pixel on the current drawing
surface. An RGB value is always returned irrespective of the current colour mode for
the surface.
See also 64CN=40A4BCNB2A44=N2>;>DA/ B4CN2>;>DAB/ DB4NA61N2>;>DAB/
GET_SCREEN_DIB@
Purpose To copy part of a graphics area.
Syntax BD1A>DC8=4 64CNB2A44=N381/ 7381 G H G! H!
8=C464A 7381 G H G! H!
Description 7381 is returned as the handle of a new device context that contains a copy of part of
the current graphics area. G , H are input as the pixel co-ordinates of the top left
hand corner of the area to copy whilst G!, H! are the corresponding co-ordinates of the
bottom right hand corner.
See also 381N?08=C/, ?A8=CN381/, 4G?>ACN1<?/, A4;40B4NB2A44=N381/
GET_SYSTEM_FONT@
Purpose To get the attributes of the system font.
Syntax BD1A>DC8=4 64CNBHBC4<N5>=C/;574867C;5F83C7
;54B20?4<4=C;5>A84=C0C8>=;5F4867C
;58C0;82;5D=34A;8=4;5BCA8:4>DC;5270AB4C
;5>DC?A428B8>=;52;8??A428B8>=;5@D0;8CH
;5?8C270=350<8;H;?5024=0<4
8=C464A ;574867C;5F83C7 ;54B20?4<4=C
;5>A84=C0C8>=;5F4867C;58C0;82
;5D=34A;8=4;5BCA8:4>DC;5270AB4C
;5>DC?A428B8>=;52;8??A428B8>=;5@D0;8CH
369
ClearWin+ User’s Guide Fortran
;5?8C270=350<8;H
270A02C4A ;?5024=0<4
Description These attributes may be used to build new fonts by modification. i.e. scaling,
italicisation etc.. Modified parameters can then be supplied to the Windows API
function CreateFont. See the Windows API documentation of CreateFont for further
details.
GET_TEXT_SIZE@
Purpose To get the dimensions of a graphics character string.
Syntax BD1A>DC8=4 64CNC4GCNB8I4/ BCA F83C7 34?C7
270A02C4A BCA
8=C464A F83C734?C7
Description This routine returns the pixel F83C7 and 34?C7 of a given character string BCA when
drawn on the current drawing surface. Trailing spaces will be included so either use a
substring notation or terminate the significant characters by 270A.
GET_TRACK_LENGTH@
Purpose To get the length of a CD track.
Syntax 8=C464A 5D=2C8>= 64CNCA02:N;4=6C7/ CA02:
8=C464A CA02:
Description Call this routine to obtain the length of an audio CD’s track in milliseconds. If the
track length returned is zero then this track does not exist. This result can be used to
determine the number of audio tracks available. The first track number is 1 rather than
zero.
Return value Returns the required track length or zero on failure.
See also 2;>B4N23NCA0H/ B4CN23N?>B8C8>=/ ?;0HN0D38>N23/ BC>?N0D38>N23/
370
Chapter 27 Library reference
GET_WINDOW_LOCATION@
Purpose To get the location and size of a given window.
Syntax BD1A>DC8=4 64CNF8=3>FN;>20C8>=/ 70=3;4 G H F83C7
74867C
8=C464A 70=3;4 G H F83C7 74867C
Description 70=3;4 is a window handle obtained, for example, by using %hw or %lc. Other
arguments are returned with the pixel coordinates and dimensions of the window.
Notes For main windows the G,H location is in absolute screen coordinates. For child
windows attached by %aw to a frame, the coordinates are relative to the top left corner
of the frame. For controls and other child (%ch) windows G and H are relative to the
parent window.
This routine (together with the associated move and resize routines) can be used on
windows created using F8=8>/ or on other windows if the window handle is available.
They are particularly useful to control the placement of MDI child windows.
Moving individual controls and un-framed child windows may be unwise as it can
cause controls to overlap on the screen.
Windows will be partially or totally concealed if they are moved outside the area of the
screen or the enclosing window or frame (in the case of child windows). This is
normal and can be used if desired.
Some interesting effects can be obtained by using these functions. For example,
suppose that a child window (which might contain a large graphics region) were
attached to a frame that was too small to contain it. By calling <>E4NF8=3>F/ (e.g.
in response to a scroll call-back function) with negative values of G and/or H, the
contents of the window could be scrolled within the frame.
GET_WKEY@
Purpose To get a key from a ClearWin window keyboard buffer.
Syntax 8=C464A 5D=2C8>= 64CNF:4H/
Description This routine is only for use in a ClearWin window (e.g. with %cw). If necessary, it
371
ClearWin+ User’s Guide Fortran
waits for the user to press a key on the keyboard. However, the routine will yield to
other processes.
Notes 033N:4H1>0A3N<>=8C>A/ provides a better mechanism for handling keyboard input.
Return value Returns the ASCII code for the first key and removes it from the buffer.
See also 5443NF:4H1>0A3/5;DB7NF:4H1>0A3/64CNF:4H /F:4HNF08C8=6/
GET_WKEY1@
Purpose To get a key from a ClearWin window keyboard buffer.
Syntax 8=C464A 5D=2C8>= 64CNF:4H /
Description This routine is only for use in a ClearWin window (e.g. with %cw). It is like
64CNF:4H/ but immediately returns zero if the buffer is empty.
Notes 033N:4H1>0A3N<>=8C>A/ provides a better mechanism for handling keyboard input.
Return value Returns the ASCII code for the first key and removes it from the buffer. If the buffer is
empty it returns zero.
See also 5443NF:4H1>0A3/ 5;DB7NF:4H1>0A3/ 64CNF:4H/ F:4HNF08C8=6/
GRAPHICS_TO_CLIPBOARD@
Purpose To allow the interchange of graphics between drawing surfaces and other Windows
applications.
Syntax 8=C464A 5D=2C8>= 6A0?782BNC>N2;8?1>0A3/G H G!H!
8=C464A G H G! H!
Description Places a rectangular area of a drawing surface on to the clipboard so that other
Windows programs can use the image.
G H is the top left corner of the area.
G! H! is the lower right corner of the area.
Return value Returns 1 for success and zero on failure.
See also 2>?HN5A><N2;8?1>0A3/ 2>?HNC>N2;8?1>0A3/
372
Chapter 27 Library reference
2;8?1>0A3NC>NB2A44=N1;>2:/
GRAPHICS_WRITE_MODE@
Purpose To select replace/XOR mode before writing to the current drawing surface.
Syntax BD1A>DC8=4 6A0?782BNFA8C4N<>34/<>34
8=C464A <>34
Description This routine sets the graphics write mode for the current drawing surface depending on
the value of <>34. Any value other than 3 will force all subsequent graphics output to
replace existing pixels. A value of 3 will cause the output to be G>Aed with existing
pixels.
HIBYTE@
Purpose To get the top 8 bits of a 16 bit integer.
HIGH_COLOUR_MODE@
Purpose To test if the screen is a high colour device.
Syntax ;>6820; 5D=2C8>= 7867N2>;>DAN<>34/
Description A high colour device is one that has more than 8 bits per pixel (i.e. more than 256
colours). A high colour device does not make use of colour palettes. If you want to use
a wide range of colours whilst avoiding the complexities of managing a palette, one
solution is to restrict the usage to desktops operating in high colour mode. Thus you
can use this function to test if the desktop is set to operate with more than 256 colours
per pixel and to send a error message and close down on failure.
Return value Returns .TRUE. for success.
373
ClearWin+ User’s Guide Fortran
HIWORD@
Purpose To get the top 16 bits of a 32 bit integer.
IMPORT_BMP@
Purpose To read in a BMP file.
Syntax 8=C464A 5D=2C8>= 8<?>ACN1<?/ 58;4=0<4 4AA>A
270A02C4A 58;4=0<4
8=C464A 4AA>A
Description Reads in a BMP file and returns a DIB handle to the image. The handle can then be
used with 381N?08=C/, ?A8=CN381/ and 4G?>ACN1<?/. 4AA>A returns one of the
following:
0 success
2 unable to read file
4 insufficient memory
5 not a BMP file
10 unable to open file
Return value Returns a handle to the image or zero on failure.
See also 64CNB2A44=N181/, A4;40B4NB2A44=N381/, 8<?>ACN?2G/
2;8?1>0A3NC>NB2A44=N1;>2:/
374
Chapter 27 Library reference
IMPORT_PCX@
Purpose To read in a .PCX file.
Syntax 8=C464A 5D=2C8>= 8<?>ACN?2G/ 58;4=0<4 4AA>A
270A02C4A 58;4=0<4
8=C464A 4AA>A
Description Reads in a PCX file and returns a DIB handle to the image that is compatible with
windows bitmaps allowing it be used with 381N?08=C/ ?A8=CN381/ and
4G?>ACN1<?/. 4AA>A returns one of the following:
0 success
2 unable to read file
4 insufficient memory
6 not a PCX file
10 unable to open file
Return value Returns a handle to the image or zero on failure.
See also 64CNB2A44=N181/, A4;40B4NB2A44=N381/, 8<?>ACN1<?/
2;8?1>0A3NC>NB2A44=N1;>2:/
ITALIC_FONT@
Purpose To set/unset italic font style for text on the current drawing surface.
Syntax BD1A>DC8=4 8C0;82N5>=C/ 8C0;
8=C464A 8C0;
Description This routine sets or resets the italic property of the current drawing surface. Any
subsequent calls to the 3A0FN270A02C4AB/ routine will reflect the change.
See also A>C0C4N5>=C/ B20;4N5>=C/ B4;42CN5>=C/ D=34A;8=4N5>=C/
1>;3N5>=C/
LOBYTE@
Purpose To get the bottom 8 bits of a 16 bit integer.
375
ClearWin+ User’s Guide Fortran
Notes This is the ClearWin+ Fortran equivalent of the Microsoft C macro with the same
name.
LOWORD@
Purpose To get the bottom 16 bits of a 32 bit integer.
MAKE_BITMAP@
Purpose To embed a bitmap in program code.
Syntax 8=C464A 5D=2C8>= <0:4N18C<0?/1<?N30C0 GA4B HA4B
270A02C4AHA4B 1<?N30C0 GA4B
8=C464A GA4B HA4B
?0A0<4C4A GA4BHA4B
Description Bitmaps are usually included in a program statically via resources or dynamically with
Windows API calls. This routine is provided so that bitmaps may be included in the
source code as text data and then translated into bitmap format. A (HBITMAP) handle
to a bitmap is returned that can be used for example with %`bm. This provides a
speedy method of designing simple graphics that would otherwise require image
editing software.
The character arrays may include the following characters:
- (minus) Black
b Dark blue
r Dark red
g Dark green
y Dark yellow (brown)
m Dark magenta
c Dark cyan
w Grey
l Light grey
B Blue
R Red
G Green
376
Chapter 27 Library reference
Y Yellow
M Magenta
C Cyan
W White
Return value Returns a bitmap handle to the new bitmap.
See also <0:4N82>=/
MAKE_ICON@
Purpose To embed an icon in program code.
Syntax 8=C464A 5D=2C8>= <0:4N82>=/ 82>=N30C0
270A02C4A"! 82>=N30C0"!
Description This routine allows an icon to be embedded in the program code. A 32x32 character
array must be defined to accommodate the icon data. The characters can be defined as
any of the following:
- (minus) Black
b Dark blue
r Dark red
g Dark green
y Dark yellow (brown)
m Dark magenta
c Dark cyan
w Grey
B Blue
R Red
G Green
Y Yellow
M Magenta
C Cyan
W White
If any other character is used then a transparent colour is assumed which will allow the
background to show through. A (HICON) handle to the icon is returned which may be
used for example with %`ic. The icon is automatically discarded at program
termination.
Return value Returns a handle to the new icon.
See also <0:4N18C<0?/
377
ClearWin+ User’s Guide Fortran
Example
8=2;D34 +fX]S^fbX]b-
270A02C4A"! XR^]"!
8=C464A WXR^]
WXR^],\PZTNXR^]/82>=
30C0 XR^] AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
30C0 XR^]!AHH11HH11HH11HH11HH11HH11HH11HHA
30C0 XR^]"AHH11HH11HH11HH11HH11HH11HH11HHA
30C0 XR^]" AHH11HH11HH11HH11HH11HH11HH11HHA
30C0 XR^]"!AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Z,fX]X^/RPJ<PZT XR^]L][OXR782>=
4=3
MAP_FILE_FOR_READ_WRITE@
Purpose To map a file to memory (Win32 only).
Syntax 8=C464A 5D=2C8>= <0?N58;4N5>ANA403NFA8C4/ 58;4=0<4 B8I4
270A02C4A 58;4=0<4
8=C464A B8I4
Description See <0?N58;4N5>ANA4038=6/
In <0?N58;4N5>ANA403NFA8C4/ the variable B8I4 can be input as zero, in which
case it will be returned as the original size of the file. Otherwise, the mapped memory
region will be set to B8I4 bytes and the file will be extended if necessary. If the file
does not exist it will be created. In this routine the contents of the file can be changed.
Return value Returns the starting address of the mapped view or zero on failure.
See also <0?N58;4N5>ANA4038=6/, D=<0?N58;4/
MAP_FILE_FOR_READING@
Purpose To map a file to memory (Win32 only).
Syntax 8=C464A 5D=2C8>= <0?N58;4N5>ANA4038=6/ 58;4=0<4 B8I4
270A02C4A 58;4=0<4
8=C464A B8I4
378
Chapter 27 Library reference
Description When a file is memory mapped, a region of memory is defined so that accesses to that
memory effectively access the disk file. A file may be opened for reading using
<0?N58;4N5>ANA4038=6/.
58;4=0<4 is the name of the file to be opened and B8I4 is returned as the size of the
file.
Use the various Salford 2>A4 intrinsic functions to access the contents of the file. Any
attempt to alter the contents of the file will cause an error.
Return value Returns the starting address of the mapped view or zero on failure
Notes To call a routine with a mapped file as an argument use the form
<HBD122>A4 ?CA where ?CA is the value returned by
<0?N58;4N5>ANA4038=6/.
See also <0?N58;4N5>ANA403NFA8C4/, D=<0?N58;4/
METAFILE_TO_CLIPBOARD@
Purpose To send a metafile to the clipboard.
Syntax 8=C464A 5D=2C8>= <4C058;4NC>N2;8?1>0A3/
Description This function can be used after a call to >?4=N<4C058;4/ followed by calls to
graphics drawing routines. It causes the image to be stored on the clipboard in
metafile format. Alternatively, if the %gr option \TcPUX[TNaTbXiT is used, this
function can be used to send the resulting metafile to the clipboard.
Return value Returns 1 for success or zero for failure.
Notes If a background colour is specified for %gr (e.g. %gr[black]), this information is not
recorded in the metafile.
See also >?4=N<4C058;4/ 2;>B4N<4C058;4/ ?;0HN2;8?1>0A3N<4C058;4/
MOVE_WINDOW@
Purpose To move a window.
Syntax BD1A>DC8=4 <>E4NF8=3>F/ 70=3;4 G H
8=C464A 70=3;4 G H
379
ClearWin+ User’s Guide Fortran
Description 70=3;4 is typically a value obtained by using %hw or %lc. G and H are input as the
new location of the window in pixel coordinates.
MOVIE_PLAYING@
Purpose To test if a video is still playing.
Syntax 8=C464A 5D=2C8>= <>E84N?;0H8=6/
Return value <>E84N?;0H8=6/ returns an integer that is the Window handle of the movie window
(or zero if no movie is playing). This handle can be passed to the standard API
function DestroyWindow to force the movie to end.
NEW_PAGE@
Purpose To provide a new page on the current drawing surface.
Syntax BD1A>DC8=4 =4FN?064/
Description The effect of this routine depends on the type of the current drawing surface:
Device Effect
screen clears the screen area (identical to 2;40ANB2A44=/)
printer prints the image and then blanks the bitmap (an alternative to 2;>B4N?A8=C4A/)
OPEN_CD_TRAY@
Purpose To open a CD-drive tray.
Syntax BD1A>DC8=4 >?4=N23NCA0H/
Description Simply by calling this routine any closed CD drive with a mechanical drawer will
open.
See also 2;>B4N23NCA0H/ B4CN23N?>B8C8>=/ ?;0HN0D38>N23/ BC>?N0D38>N23/
380
Chapter 27 Library reference
OPEN_GL_PRINTER@
Purpose To display the Open Printer dialog box and attach it to OpenGL.
Syntax 8=C464A 5D=2C8>= >?4=N6;N?A8=C4A/830CCA81F83C774867C
8=C464A 830CCA81F83C774867C
Description 83 is the user assigned printer identification number.
0CCA81 is a variable that describes the buffering that is required and is a combination
of the following flags.
GL_DOUBLE_BIT
GL_STENCIL_BIT
GL_ACCUM_BIT
GL_DEPTH16_BIT
GL_DEPTH32_BIT
These flags may be added together.
When the function returns, F83C7 and 74867C provide the width and height of the
printer page in pixels.
Note that 83 and 0CCA81 are input values whilst F83C7 and 74867C are output
values.
Return value This function returns 1 if the user selected a device or zero if the “CANCEL” button
was selected.
See also >?4=N6;N?A8=C4A / ?A8=CN>?4=6;N8<064/
OPEN_GL_PRINTER1@
Purpose To attach a printer to OpenGL.
Syntax 8=C464A 5D=2C8>= >?4=N6;N?A8=C4A /830CCA81F83C774867C
8=C464A 830CCA81F83C774867C
Description This function is similar to >?4=N6;N?A8=C4A/ but it does not display the Open
Printer dialog box. Instead it uses either the default printer or the printer selected in an
earlier call to >?4=N6;N?A8=C4A/.
83 is the user assigned printer identification number.
0CCA81 is a variable that describes the buffering that is required and is a combination
of the following flags.
GL_DOUBLE_BIT
381
ClearWin+ User’s Guide Fortran
GL_STENCIL_BIT
GL_ACCUM_BIT
GL_DEPTH16_BIT
GL_DEPTH32_BIT
These flags may be added together.
When the function returns, F83C7 and 74867C provide the width and height of the
printer page in pixels.
Note that 83 and 0CCA81 are input values whilst F83C7 and 74867C are output
values.
Return value This function returns 1 for success, otherwise zero.
See also >?4=N6;N?A8=C4A/ ?A8=CN>?4=6;N8<064/
OPEN_METAFILE@
Purpose To record graphics sequences.
Syntax 8=C464A 5D=2C8>= >?4=N<4C058;4/ 7
8=C464A 7
Description Opens a metafile for the current graphics area. A metafile is used to store graphics
information using a device independent format that can be printed, replayed or copied
to the clipboard.
Return value Returns 1 for success or zero on failure.
See also 2;>B4N<4C058;4/ <4C058;4NC>N2;8?1>0A3/
?;0HN2;8?1>0A3N<4C058;4/ 3>N2>?84B ?A8=CN6A0?782BN?064/
OPEN_PRINTER@
Purpose To begin output to a graphics printer or plotter.
Syntax 8=C464A 5D=2C8>= >?4=N?A8=C4A/ 70=3;4
8=C464A 70=3;4
Description >?4=N?A8=C4A/ generates a standard “Open Printer” dialog box from which the user
can select a graphics printer or plotter device for subsequent output. If a device is
successfully selected then subsequent calls to Salford graphics routines are be written
382
Chapter 27 Library reference
to this device. The printer or plotter is activated when 2;>B4N?A8=C4A/ (see page
345) or the Salford graphics routine =4FN?064/ is called (after calling this routine, it
may be necessary to reset the text attributes).
The handle is supplied by the programmer and is used in conjunction with
B4;42CN6A0?782BN>1942C/.
Return value This function returns 1 if the user selected a device or zero if the “CANCEL” button
was selected.
Notes This routine can be used in conjunction with the %gr format code that is used to draw
to the screen using Salford graphics routines (see page 136). It can also be used
independently of F8=8>/.
The standard call-back function 6?A8=C4AN>?4= can also be used to produce graphics
output.
See also 2;>B4N?A8=C4A/ 3>N2>?84B/ B4;42CN?A8=C4A/ >?4=N?A8=C4A /
OPEN_PRINTER_TO_FILE@
Purpose To cause the Windows printer device driver to begin graphics output to a file instead of
a physical printer.
Syntax 8=C464A 5D=2C8>= >?4=N?A8=C4ANC>N58;4/70=3;4 58;4=0<4
270A02C4A 58;4=0<4
8=C464A 70=3;4
Description This function is similar to >?4=N?A8=C4A/ but the output is sent to the specified file.
Return value Returns 1 if the user selected a device or zero if the “CANCEL” button was selected.
OPEN_PRINTER1@
Purpose To begin output to a graphics printer or plotter.
Syntax 8=C464A 5D=2C8>= >?4=N?A8=C4A / 70=3;4
8=C464A 70=3;4
Description >?4=N?A8=C4A / does not generate a standard “Open Printer” dialog box which
means that printing can resume to the current printer after calls to >?4=N?A8=C4A/
and 2;>B4N?A8=C4A/. This avoids the need to repeatedly select the same printer.
383
ClearWin+ User’s Guide Fortran
Subsequent calls to Salford graphics routines are written to this device. The printer or
plotter is activated when 2;>B4N?A8=C4A/ (see page 345) or the routine =4FN?064/
is called (after calling this routine, it may be necessary to reset the text attributes).
The handle is supplied by the programmer and is used in conjunction with
B4;42CN6A0?782BN>1942C/.
Return value This function returns 1 for success, otherwise zero.
Notes This routine can be used in conjunction with the %gr format code that is used to draw
to the screen using Salford graphics routines (see page 136). It can also be used
independently of F8=8>/.
The standard call-back function 6?A8=C4AN>?4= can also be used to produce graphics
output.
See also 2;>B4N?A8=C4A/ 3>N2>?84B/ B4;42CN?A8=C4A/
OPEN_PRINTER1_TO_FILE@
Purpose To cause the Windows printer device driver to begin graphics output to a file instead of
a physical printer.
Syntax 8=C464A 5D=2C8>= >?4=N?A8=C4A NC>N58;4/70=3;4 58;4=0<4
270A02C4A 58;4=0<4
8=C464A 70=3;4
Description This function is similar to >?4=N?A8=C4A / but the output is sent to the specified
file.
Return value Returns 1 for success, otherwise zero.
OPEN_TO_WINDOW@
Purpose To attach a ClearWin window to a Fortran unit.
Syntax BD1A>DC8=4 >?4=NC>NF8=3>F/D=8CF
8=C464A D=8CF
Description Attaches a previously created ClearWin window with handle F to Fortran unit D=8C.
This routine enables Fortran I/O requests (for example A403, FA8C4 and ?A8=C) to be
directed to the specified window.
384
Chapter 27 Library reference
OPEN_WAV_FILE_READ@
Purpose To open a WAV file for reading in sections.
Syntax 8=C464A 5D=2C8>= >?4=NF0EN58;4NA403/58;4=NB0<?;4B
B0<?;4NA0C4
270A02C4A 58;4
8=C464A =NB0<?;4BB0<?;4NA0C4
Description This routine opens a simple (uncompressed) .WAV file so that its contents can be read
with a series of calls to F0EN58;4NA403/. The number of samples and the sample
rate are returned by the function.
Return value The return value is the handle to be passed to subsequent sound function calls.
OPEN_WAV_FILE_WRITE@
Purpose To open a WAV file for reading in sections.
Syntax 8=C464A 5D=2C8>= >?4=NF0EN58;4NA403/58;4=N270==4;B
B0<?;4NA0C4
270A02C4A 58;4
8=C464A =N270==4;BB0<?;4NA0C4
Description This routine clears and opens a .WAV file to receive sound output as a series of calls to
F0EN58;4NFA8C4/. The number of channels and the sample rate must be supplied
to this function. The file will contain sound stored at 16 bits per sample.
Unlike FA8C4NF0EN58;4/, files written in this way can be written in sections, and
may therefore be of effectively unlimitted size.
Return value The return value is the handle to be passed to subsequent sound function calls.
PERFORM_GRAPHICS_UPDATE@
Purpose To refresh the current drawing surface display.
Syntax BD1A>DC8=4 ?4A5>A<N6A0?782BND?30C4/
Description The current drawing surface, defined by %gr, will be refreshed with every call to this
routine. Under normal operations a call to a graphics function will not produce an
385
ClearWin+ User’s Guide Fortran
immediate update, rather ClearWin+ will wait until you have finished your current
sequence of graphics calls from within your call-back. This is not usually a problem as
it ensures that only the final results are displayed.
See also B4;42CN6A0?782BN>1942C/
PERMIT_ANOTHER_CALLBACK@
Purpose To allow another call-back function to be called.
Syntax BD1A>DC8=4 ?4A<8CN0=>C74AN20;;102:/
Description Usually if a window invokes a call-back function (in response to a menu, say) most of
the standard controls are inhibited from raising further call-backs. This action is
normally desirable as it prevents unfortunate complications if the user’s mouse
‘bounces’ on a button.
PLAY_AUDIO_CD@
Purpose To play the audio CD from the current position.
Syntax 8=C464A 5D=2C8>= ?;0HN0D38>N23 3DA0C8>=
8=C464A 3DA0C8>=
Description Plays an audio CD starting at the current location which can be set with a call to
B4CN23N?>B8C8>=/. If duration is any valid number greater than 0 it will play for
that amount of time in milliseconds. If the duration is less than 0 it will play that
number of tracks i.e. a value of -4 will play the next four tracks.
386
Chapter 27 Library reference
PLAY_CLIPBOARD_METAFILE@
Purpose To play a clipboard metafile on the current drawing surface.
Syntax 8=C464A ?;0HN2;8?1>0A3N<4C058;4/ 2>;
8=C464A 2>;
Description This can be used after a call to <4C058;4NC>N2;8?1>0A3/ 2>; is used to set the
background colour using the current colour mode.
Return value The value 1 is returned for success and zero for failure.
See also >?4=N<4C058;4/ 2;>B4N<4C058;4/
PLAY_SOUND@
Purpose To send a sample to the audio output device.
Syntax 8=C464A 5D=2C8>= ?;0HNB>D=3/ ;45C A867C B0<?;4B
8=C464A! ;45CB0<?;4B A867CB0<?;4B
8=C464A B0<?;4B
?0A0<4C4A B0<?;4B
Description ;45C and A867C are arrays that contain the 16 bit sample data. The number of
samples is B0<?;4B. You should check the values returned by B>D=3N?;0H8=6/ and
B>D=3NA42>A38=6/ so that a call is not made to this routine until the sound device is
idle.
Return value Returns 1 for success and a zero on failure
See also FA8C4NF0E4N58;4/ ?;0HNB>D=3NA4B>DA24/ A42>A3NB>D=3/
B>D=3N?;0H8=6/ B>D=3NA42>A38=6/ B4;42CNB0<?;8=6NA0C4/
387
ClearWin+ User’s Guide Fortran
PLAY_SOUND_RESOURCE@
Purpose To send a resource B>D=3 to the current audio device.
Syntax 8=C464A 5D=2C8>= ?;0HNB>D=3NA4B>DA24/ =0<4
270A02C4A' =0<4
Description This routine plays any resource that is of type B>D=3. Care should be taken not to
include samples (.WAV files) that are more than a few seconds for two reasons. 1) the
sample occupies memory and 2) the routine is synchronous and will halt all other
output until the sample has completed playback. It is necessary to supply a valid
resource name to this routine.
For example:
Include in the resource section of your program:
<HF0E4 B>D=3 ±S^VQPaZfPe²
In the code section:
aTb,?;0HNB>D=3NA4B>DA24/ ³<HF0E4´
Return value Returns 0 for success, otherwise -1.
See also FA8C4NF0E4N58;4/ ?;0HNB>D=3/ A42>A3NB>D=3/ B>D=3N?;0H8=6/
B>D=3NA42>A38=6/ B4;42CNB0<?;8=6NA0C4/
PRINT_DIB@
Purpose To print a device independent bitmap.
Syntax 8=C464A 5D=2C8>= ?A8=CN381/ 83 ?ANG ?ANH
?ANF83C7 ?AN74867C 7381 G H F83C7 74867C
8=C464A 83 ?ANG ?ANH
?ANF83C7 ?AN74867C 7381 G H F83C7 74867C
Description 83 is the handle of the printer as supplied to >?4=N?A8=C4A/.
?ANG ?ANH is the printer offset position to start printing (using the printer
resolution).
?ANF83C7 ?AN74867C represent the size of the area to print (using the printer
resolution).
388
Chapter 27 Library reference
PRINT_GRAPHICS_PAGE@
Purpose To print a metafile graphics page.
Syntax BD1A>DC8=4 ?A8=CN6A0?782BN?064/
Description The current metafile image is printed to the graphics printer destination. The page is
not cleared and can still be drawn to.
See also >?4=N<4C058;4/, 3>N2>?84B/
PRINT_OPENGL_IMAGE@
Purpose To print an OpenGL image.
Syntax 8=C464A ?A8=CN>?4=6;N8<064/83;40E4N>?4=
8=C464A 83
;>6820; ;40E4N>?4=
Description 83 is the user-defined identification number previously used with
>?4=N6;N?A8=C4A/ or >?4=N6;N?A8=C4A /.
;40E4N>?4= = .TRUE. specifies that the current print job is to be left open as there
are more drawings to be sent. ;40E4N>?4= = .FALSE. specifies that the printer
connection with this 83 is to be closed.
See also >?4=N6;N?A8=C4A/ >?4=N6;N?A8=C4A /
389
ClearWin+ User’s Guide Fortran
PRINTER_DIALOG_OPTIONS@
Purpose To configure the standard printer dialog box.
Syntax BD1A>DC8=4 ?A8=C4AN380;>6N>?C8>=B/
=>N?A8=CNC>N58;4 =>N?064N=D<14AB =>NB4;42C8>=
=>N3450D;CNF0A=8=6 B4CNB><4N?064B B4CNB4;42C8>=
B4CN2>;;0C4 B4CN0;;N?064B B4CN?A8=CNC>N58;4
8=C464A
=>N?A8=CNC>N58;4 =>N?064N=D<14AB =>NB4;42C8>=
=>N3450D;CNF0A=8=6 B4CNB><4N?064B B4CNB4;42C8>=
B4CN2>;;0C4 B4CN0;;N?064B B4CN?A8=CNC>N58;4
Description The following table describes the effect of setting an argument value to 1 rather than
zero.
The following 2;40AF8=N8=5>/ strings hold some of the selected options after the
printer dialog box has closed.
³?A8=C4ANB4;42C8>=´ ‘Print selection’ was set.
³?A8=C4AN2>;;0C4´ ‘Print collate copies’ was checked.
³?A8=C4AN?064=D<14AB´ ‘Print page numbers’ was set.
These values will be either 1 or zero.
Note You can deduce the ‘print all pages’ radio button selection by
³?A8=C4ANB4;42C8>=´ and ³?A8=C4AN?064=D<14AB´ both being equal to zero.
See also Selecting a Printer, page 190.
390
Chapter 27 Library reference
PUT_DIB_BLOCK@
Purpose To save a DIB block in a BMP file (24 bits per pixel).
Syntax BD1A>DC8=4 ?DCN381N1;>2:/ 58;4=0<4 ?0AA0H 0F 07 03G
03H F 7 =1?? 4A2>34
270A02C4A 58;4=0<4
270A02C4A ?0AA0H"0F07
8=C464A 0F0703G03HF7=11?4A2>34
Description All of the arguments are input values except for 4A2>34 which returns the error status.
58;4=0<4 is the name of the BMP file.
0F and 07 are dimensions of ?0AA0H.
03G and 03H are offsets used when reading the data from ?0AA0H.
F and 7 are the width and height of the image data to be copied.
?0AA0H is the same as in 64CN381N1;>2:/.
=1?? is currently not used but should be set to 24 because currently this routine always
writes out BMP files with 24 bits per pixel.
4AA>A will return:
BD224BB
4AA>A >= 58;4 >?4=
" 4AA>A >= FA8C4
" 103 =D<14A
See also 64CN381NB8I4/ 64CN381N1;>2:/ 381N1;>2:N?08=C/
Example See page 145.
RECORD_SOUND@
Purpose To record sound from the sound input device.
Syntax 8=C464A A42>A3NB>D=3/ ;45C A867C B0<?;4B 5;06
8=C464A! ;45CB0<?;4B A867CB0<?;4B
8=C464A B0<?;4B 5;06
?0A0<4C4A B0<?;4B
Description ;45C and A867C are arrays of 8=C464A! 16 bit data . They will be filled with sound
data so enough memory should be allocated to them which should be the same value as
391
ClearWin+ User’s Guide Fortran
B0<?;4B. 5;06 is a return value that is currently unused. You should check the
B>D=3N?;0H8=6/ and B>D=3NA42>A38=6/ results so that a call is not made to this
routine until the sound device is idle.
Return value Returns 1 for success or zero on failure.
See also FA8C4NF0E4N58;4/ ?;0HNB>D=3/ B>D=3N?;0H8=6/ B>D=3NA42>A38=6/
B4;42CNB0<?;8=6NA0C4/ ?;0HNB>D=3NA4B>DA24/
RELEASE_BITMAP_DC@
Purpose To release a bitmap device context acquired by 64CN18C<0?N32/.
Syntax BD1A>DC8=4 A4;40B4N18C<0?N32/732
8=C464A 732
Description The device context and its associated bitmap are released. This function must not be
called whilst a window that uses the device context is still active. 732 is the value
returned by a previous call to 64CN18C<0?N32/.
See also 64CN18C<0?N32/, 2;40AN18C<0?/, %dw
RELEASE_SCREEN_DIB@
Purpose To release the memory for a DIB.
Syntax BD1A>DC8=4 A4;40B4NB2A44=N381/ 7381
8=C464A 7381
Description 7381 is input as the handle of a device independent bitmap created for example by
64CNB2A44=N381/., 8<?>ACN1<?/, or 2;8?1>0A3NC>NB2A44=N1;>2:/.
REMOVE_ACCELERATOR@
Purpose To remove an accelerator key created using %ac or 033N0224;4A0C>A/.
Syntax BD1A>DC8=4 A4<>E4N0224;4A0C>A/ F :4HN=0<4
8=C464A F
270A02C4A :4HN=0<4
392
Chapter 27 Library reference
Description Removes the key with name :4HN=0<4 from the window with handle F. See
033N0224;4A0C>A/ for further details.
See also %ac, 033N0224;4A0C>A/
REMOVE_CURSOR_MONITOR@
Purpose To release a call-back function that monitors which window or control has the cursor.
Syntax BD1A>DC8=4 A4<>E4N2DAB>AN<>=8C>A/ 21N5D=2
4GC4A=0; 21N5D=2
Description See 033N2DAB>AN<>=8C>A/.
REMOVE_FOCUS_MONITOR@
Purpose To release a call-back function that monitors which window or control has the focus.
Syntax BD1A>DC8=4 A4<>E4N5>2DBN<>=8C>A/ 21N5D=2
4GC4A=0; 21N5D=2
Description See 033N5>2DBN<>=8C>A/.
REMOVE_GRAPHICS_ICON@
Purpose To remove an icon from a %gr drawing surface.
Syntax BD1A>DC8=4 A4<>E4N6A0?782BN82>= 70=3;4
8=C464A 70=3;4
Description 70=3;4 is the value returned by an earlier call to 033N6A0?782BN82>=/.
See also 033N6A0?782BN82>=/
393
ClearWin+ User’s Guide Fortran
REMOVE_KEYBOARD_MONITOR@
Purpose To release a call-back function that monitors the use of the keyboard.
Syntax BD1A>DC8=4 A4<>E4N:4H1>0A3N<>=8C>A/ 21N5D=2
4GC4A=0; 21N5D=2
Description See 033N:4H1>0A3N<>=8C>A/
REMOVE_MENU_ITEM@
Purpose Removes a dynamically attached %mn menu item.
Syntax BD1A>DC8=4 A4<>E4N<4=DN8C4</ 70=3;4
8=C464A 70=3;4
Description Use this routine to remove the last menu item that was previously been attached with a
call to 033N<4=DN8C4</ (see page 333).
See also 033N<4=DN8C4</
REPLY_TO_TEXT_MESSAGE@
Purpose To reply to a message from an application that uses B4=3NC4GCN<4BB064/.
Syntax BD1A>DC8=4 A4?;HNC>NC4GCN<4BB064/ A4?;H
270A02C4A A4?;H
Description This routine can be used within a call-back function associated with %rm. The
message and reply can be up to 255 characters long.
See also %nc, %rm, B4=3NC4GCN<4BB064/
RESIZE_WINDOW@
Purpose To resize a window given its window handle.
Syntax BD1A>DC8=4 A4B8I4NF8=3>F/ 70=3;4 F83C7 74867C
8=C464A 70=3;4 F83C7 74867C
394
Chapter 27 Library reference
Description 70=3;4 is typically a value obtained by using %hw or %lc. F83C7 and 74867C are
input as the new size of the window in pixels.
RGB@
Purpose To pack 8-bit colour values into a 32-bit integer.
Syntax 8=C464A 5D=2C8>= A61/A436A44=1;D4
8=C464A A436A44=1;D4
Description This function is equivalent to the Windows API macro called RGB. It takes colour
values in the range 0 to 255 and packs them into the 24 least significant bits of a 32 bit
integer. 6A44= is shifted left 8 bits and 1;D4 is shifted left 16 bits. RGB values are
used in drawing routines when RGB colour mode is adopted.
Return value Returns the packed RGB values.
ROTATE_FONT@
Purpose To rotate the font being used on the current drawing surface.
Syntax BD1A>DC8=4 A>C0C4N5>=C/ A>C
3>D1;4 ?A428B8>= A>C
Description This routine will rotate the selected font about the bottom left-hand corner of the text.
The rotation is anti-clockwise and A>C is specified in degrees.
See also 8C0;82N5>=C/ B20;4N5>=C/ B4;42CN5>=C/ D=34A;8=4N5>=C/
1>;3N5>=C/
SCALE_FONT@
Purpose To scale the font being used on the current drawing surface.
Syntax BD1A>DC8=4 B20;4N5>=C/ B8I4
3>D1;4 ?A428B8>= B8I4
395
ClearWin+ User’s Guide Fortran
Description Rescales the font being used on the current drawing surface.
See also A>C0C4N5>=C/ B4;42CN5>=C/ D=34A;8=4N5>=C/ 8C0;82N5>=C/
1>;3N5>=C/
SCROLL_GRAPHICS@
Purpose To scroll an area of the current drawing surface.
Syntax BD1A>DC8=4 B2A>;;N6A0?782B/ 3G 3H ;45C C>?
A867C 1>CC>< BF8C27 2>;>DA
8=C464A 3G 3H ;45C C>? A867C 1>CC>< BF8C27
2>;>DA
Description This routine allows you to scroll an area the drawing surface. The direction of
scrolling is set by the two variables 3G and 3H They represent the displacement the
image will be copied to. For 3G, values less than 0 will move the image left and values
greater than 0 will move the image right by the relevant number of pixels. For 3H,
values less than 0 will move the image up and values greater then 0 will move the
image down by the relevant number of pixels.
The ;45C C>? A867C 1>CC>< arguments define the area to be moved. This can
be the whole surface or a sub region within the whole.
BF8C27 can either be set to 0 or 1. If it is set to 1 then the area that becomes invalid is
set to the 2>;>DA specified by the final argument (using the current colour mode). If
it is 0 then the invalid region is left unchanged. You should note that this is a copy
routine not a move and the region of the screen that is not copied will not be
automatically modified.
See also B4;42CN6A0?782BN>1942C/ 2>?HN6A0?782BNA468>=/
2A40C4N6A0?782BNA468>=/ 34;4C4N6A0?782BNA468>=/
SEE_PROPERTYSHEET_PAGE@
Purpose To set the sheet number for %ps.
Syntax BD1A>DC8=4 B44N?A>?4ACHB744CN?064/ B744CN=
8=C464A B744CN=
Description See page 265.
396
Chapter 27 Library reference
SEE_TREEVIEW_SELECTION@
Purpose To ensure that the current %tv item is visible.
Syntax BD1A>DC8=4 B44NCA44E8FNB4;42C8>=/ ?>8=C
8=C464A ?>8=C
Description This routine ensures that the treeview (defined by %tv page 68) is opened showing the
current selection. The argument is the current selection integer (not the array of
descriptions). This function may be of most use if called via a call-back attached to
%sc, thus providing a once only update.
Note that you should ensure that all the appropriate nodes in the hierarchy are marked
as expanded (‘E’) in order to make the selected item visible.
SELECT_FONT@
Purpose To select a new font for a drawing surface.
Syntax BD1A>DC8=4 B4;42CN5>=C/ 5>=C=0<4
270A02C4A 5>=C=0<4
Description 5>=C=0<4 becomes the font for the current drawing surface. The default size is not
changed. The font can be set to any currently enabled Windows fonts (see the relevant
Windows font manager). Care should be taken when selecting fonts since fonts that
are available on one machine may not be available on another.
5>=C=0<4 could be a user-added Windows font or ‘SYSTEM FIXED FONT’ (this
font is used for output to a ClearWin window) or ‘SYSTEM FONT’ (this is the
Windows SYSTEM_FONT parameter or, under Windows 95, the
DEFAULT_GUI_FONT parameter and is used in some ClearWin+ controls).
Notes The default Charset value (see 5>=CN<4CA82B/) for Courier New is
ANSI_CHARSET. By using /OEM after the name of the font ('Courier New/OEM') it
is possible to choose OEM_CHARSET.
See also A>C0C4N5>=C/ B20;4N5>=C/ 8C0;82N5>=C/ D=34A;8=4N5>=C/
1>;3N5>=C/
397
ClearWin+ User’s Guide Fortran
SELECT_FONT_ID@
Purpose To set the font for the current drawing surface.
Syntax 8=C464A 5D=2C8>= B4;42CN5>=CN83/ 83
8=C464A 83
Description 83 is a value returned by an earlier call to 64CN5>=CN83/.
Return value Returns 1 for success or zero on failure.
See also 27>>B4N5>=C/, 64CN5>=CN83/
SELECT_GRAPHICS_OBJECT@
Purpose To select the current drawing surface.
Syntax 8=C464A 5D=2C8>= B4;42CN6A0?782BN>1942C/ 70=3;4
8=C464A 70=3;4
Description Drawing surfaces are created by %gr, >?4=N?A8=C4A/. etc and
2A40C4N6A0?782BNA468>=/. 70=3;4 is a value that you supply to %`gr, or
>?4=N?A8=C4A/ etc.. ClearWin+ drawing routines are applied to the current
drawing surface. Use this function if you have created more than one drawing surface
and you want to draw on a surface that is not the current one.
Return value The value 1 is returned for success or zero for failure (invalid handle).
SELECT_PRINTER@
Purpose To configure and select the active printer.
Syntax 8=C464A 5D=2C8>= B4;42CN?A8=C4A/ 34E ?>AC
270A02C4A 34E ?>AC
Description A call to B4;42CN?A8=C4A/ will provide a standard Windows dialog box from which
the user is able to select and configure any of the attached printer devices.
On return 34E will contain the name of the printer device that has been selected and
?>AC will contain the name of the port it is connected to.
A character array of size 20, in each case, should be sufficient to hold the returned
398
Chapter 27 Library reference
data.
Return value Returns 1 for success or zero if the user clicked on the CANCEL button.
See also >?4=N?A8=C4A/ 2;>B4N?A8=C4A/
Example PORT LPT1: , COM3: , FAX: ...
SEND_TEXT_MESSAGE@
Purpose To send a message to an application that uses %rm.
Syntax 8=C464A 5D=2C8>= B4=3NC4GCN<4BB064/ 2;0BBN=0<4
<4BB064 A4?;H
270A02C4A 2;0BBN=0<4<4BB064A4?;H
Description This function sends a text string of up to 255 characters to a window with the given
class name. The recipient window will normally use the %nc format to give its class a
specific name. The recipient will also use the %rm format (which takes one call-back
argument) to supply a call-back function to handle the message. The call-back
function can call 2;40AF8=NBCA8=6/<4BB064NC4GC to obtain the message.
To send a reply, the call-back function should call A4?;HNC>NC4GCN<4BB064/.
Since the message and reply can be up to 255 characters long, they can hold
considerable amounts of information.
Notes a) Every message requires by its very nature a context switch from the transmitter
application to the receiver. Under Win32 this is quite slow (particularly under
Windows 95), therefore large amounts of information are best transmitted in a file,
sending just a short message to transmit the file name. Bearing in mind that file
accesses are normally cached, this method can be quite efficient.
b) One use for inter-process communication is particularly common under Win32.
Applications written to run in 16-bit Windows can only have one copy executing at
once. However, it is possible to start several copies of a Win32 application. Often
the user does not really want several independent copies of your application
running simultaneously. Suppose, for example that a MDI editor MYEDIT is
already running and the user issues the command:
MYEDIT filename
What is probably required is to open the file in the editor that is already running.
To achieve this it is first necessary to uniquely identify the main window of your
application. This is done using the %nc format to give the window a distinctive
class name. The window should also use the %rm format to supply a routine to
handle messages. Before the main window is created the program should call
399
ClearWin+ User’s Guide Fortran
B4=3NC4GCN<4BB064/ to send the name of the file to another copy of the editor if
one is running. If this function returns 1 for success the current program can be
terminated in the knowledge that the file has been transmitted to another active
version of the application.
Return value Returns 1 for success, otherwise zero if no window with the given class name was
found.
SET_ALL_MAX_LINES@
Purpose To set the maximum number of lines to be stored for all ClearWin windows.
Syntax BD1A>DC8=4 B4CN0;;N<0GN;8=4B/=
8=C464A =
Description This routine is the same as B4CN<0GN;8=4B/ but applies to all ClearWin windows.
SET_CD_POSITION@
Purpose To set the position of the CD read head to CA02: + <8;;8B42>=3B (offset).
Syntax 8=C464A B4CN23N?>B8C8>=/ CA02: <8;;8B42>=3B
8=C464A CA02: <8;;8B42>=3B
Description The CD read head will be moved to the track plus the number of specified milliseconds
into that track. The first track number is 1 rather than 0.
Return value Returns 1 for success or zero on failure.
See also 2;>B4N23NCA0H/ >?4=N23NCA0H/ ?;0HN0D38>N23/ BC>?N0D38>N23/
64CNCA02:N;4=6C7
SET_CLEARWIN_FLOAT@
Purpose To set or change a floating point value associated with a named string.
Syntax BD1A>DC8=4 B4CN2;40AF8=N5;>0C/ BCA8=6 E0;D4
270A02C4A BCA8=6
3>D1;4 ?A428B8>= E0;D4
Description This routine will create and assign a value to a private named parameter that can be
400
Chapter 27 Library reference
SET_CLEARWIN_INFO@
Purpose To set or change an integer value associated with a named string.
Syntax BD1A>DC8=4 B4CN2;40AF8=N8=5>/ BCA8=6 E0;D4
270A02C4A BCA8=6
8=C464A E0;D4 *
Description This function will create and assign a value to a private named parameter that can be
retrieved using 2;40AF8=N8=5>/. User defined parameters can be very useful to
communicate information between modules in a program (especially between DLL’s
under Win32). This function cannot be used to set system 2;40AF8=N8=5>/ values
except for the printer dialog parameters described on page 194.
See also 2;40AF8=N8=5>/
SET_CLEARWIN_STRING@
Purpose To set or change a string value associated with a named string.
Syntax BD1A>DC8=4 B4CN2;40AF8=NBCA8=6 BCA8=6 E0;D4
270A02C4A BCA8=6 E0;D4
Description This function will create and assign a value to a private named parameter that can be
retrieved using 2;40AF8=NBCA8=6/. User defined parameters can be very useful to
communicate information between modules in a program (especially between DLL’s
under Win32). This function should not be used to set system 2;40AF8=NBCA8=6/
values except for:
?A8=C4AN3>2D<4=C
This is the name of the document that is about to be printed. Its default value is
“ClearWin+ Output”.
See also 2;40AF8=NBCA8=6/
401
ClearWin+ User’s Guide Fortran
SET_CLEARWIN_STYLE@
Purpose Modifies the default styling controls for format (F8=8>/) windows.
Syntax 8=C464A 5D=2C8>= B4CN2;40AF8=NBCH;4/ =4FBCH;4
8=C464A =4FBCH;4
Description The default style for a format window is (FBN>E4A;0??43F8=3>F FBN7B2A>;;
FBNEB2A>;; This can be changed to any valid combination of Windows styles
contained in the windows.ins file so that any subsequent widows have a new style.
FBN>E4A;0??43 FBN?>?D?
FBN278;3 FBN2;8?B81;8=6B
FBN2;8?278;3A4= FBNE8B81;4
FBN38B01;43 FBN<8=8<8I4
FBN<0G8<8I4 FBN20?C8>=
FBN1>A34A FBN3;65A0<4
FBNEB2A>;; FBN7B2A>;;
FBNBHB<4=D FBNC782:5A0<4
FBN<8=8<8I41>G FBN<0G8<8I41>G
FBN6A>D? FBNC01BC>?
FBN>E4A;0??43F8=3>F FBN?>?D?F8=3>F
FBN278;3F8=3>F FBN4GN3;6<>30;5A0<4
FBN4GN=>?0A4=C=>C85H
Return value The previous settings are returned and should be stored if the effect you wish to
generate is only temporary.
SET_CONTROL_TEXT_COLOUR@
Purpose To change the text colour of a control after a window/dialog has been created.
Syntax BD1A>DC8=4 B4CN2>=CA>;NC4GCN2>;>DA/70=3;42>;>DA
8=C464A 70=3;42>;>DA
Description 70=3;4 is the window handle of the control obtained by using %lc. 2>;>DA is the
RGB colour value (see A61/).
Notes Unless the colour is to be varied you can set the text colour of a control using %tc
before the control when the window is created, possibly followed by another %tc to
reset it after the control has been specified.
402
Chapter 27 Library reference
SET_CONTROL_VISIBILITY@
Purpose To show or hide a control or window.
Syntax BD1A>DC8=4 B4CN2>=CA>;NE8B818;8CH/70=3;4B7>F
8=C464A 70=3;4B7>F
Description 70=3;4 is the window handle obtained by using %lc or %hw. B7>F is set to 1 to show
the window or 0 to hide it. This routine provides the same functionality as the API
function ShowWindow but also performs certain necessary housekeeping internal to
ClearWin+. It is therefore preferred to ShowWindow.
SET_CURSOR_WAITING@
Purpose To produce a temporary hour-glass cursor.
Syntax BD1A>DC8=4 B4CN2DAB>ANF08C8=6/ F08C
8=C464A F08C
Description If F08C is set to a non-zero value, the routine changes the cursor to an hour-glass with
immediate effect. A zero value then causes the previous cursor to be restored, again
with immediate effect.
SET_DEFAULT_FONT@
Purpose To set the default standard I/O font for ClearWin windows.
Syntax BD1A>DC8=4 B4CN3450D;CN5>=C/75>=C
8=C464A 75>=C
Description This routine is not suitable for format windows. It sets the default standard I/O font for
ClearWin windows to 75>=C. 75>=C must be the handle to an existing font which
can for example be obtained by calling the CreateFont Windows API function.
Note Any font changes will affect only those ClearWin windows subsequently created. If
you wish to change the default font for all ClearWin windows then this can only be
403
ClearWin+ User’s Guide Fortran
achieved by calling one of the ClearWin+ set-font functions before any windows are
created or any standard I/O is performed.
SET_DEFAULT_PROPORTIONAL_FONT@
Purpose To set the default standard I/O font for ClearWin windows to “System”.
Syntax BD1A>DC8=4 B4CN3450D;CN?A>?>AC8>=0;N5>=C/
Description This routine is not suitable for format windows. The font is proportionally spaced.
You can revert to a mono spaced font by using B4CN3450D;CNC>N58G43N5>=C/
SET_DEFAULT_TO_FIXED_FONT@
Purpose To reset the default standard I/O font for ClearWin windows to “System Fixed”.
Syntax BD1A>DC8=4 B4CN3450D;CNC>N58G43N5>=C/
Description This routine is not suitable for format windows. The font is mono-spaced.
SET_DEFAULT_WINDOW@
Purpose To set the default ClearWin window for standard I/O.
Syntax 8=C464A 5D=2C8>= B4CN3450D;CNF8=3>F/F
8=C464A F
Description All future standard I/O requests will be directed to this window. W is a handle created
by 2A40C4NF8=3>F/.
Return value Returns the handle of the previous default window.
SET_GRAPHICS_SELECTION@
Purpose To select a ‘rubber-band’ mode for a %gr region.
Syntax BD1A>DC8=4 B4CN6A0?782BNB4;42C8>=/ <>34
8=C464A <>34
404
Chapter 27 Library reference
SET_HIGHLIGHTED@
Purpose To select all of the text in a %rd, %rf or %rs edit box.
Syntax BD1A>DC8=4 B4CN7867;867C43/70=3;4
8=C464A 70=3;4
Description 70=3;4 is the window handle of the edit box obtained by using %lc.
See also %rd, %rf, %rs
405
ClearWin+ User’s Guide Fortran
SET_LINE_STYLE@
Purpose To set the style for a line on the current drawing surface.
Syntax BD1A>DC8=4 B4CN;8=4NBCH;4/ E0;D4
8=C464A E0;D4
Description This routine changes the line style on the current drawing surface. E0;D4 is one of the
following predefined Windows constants (available from the file windows.ins):
?BN=D;; can be used to remove the black border when printing a ‘filled polygon’, for
example, on a black and white printer.
See also B4CN;8=4NF83C7/
SET_LINE_WIDTH@
Purpose To set the line width on the current drawing surface.
Syntax BD1A>DC8=4 B4CN;8=4NF83C7/ E0;D4
8=C464A E0;D4
Description Changes the pixel thickness of a line when drawing on a drawing surface. The default
value is 1.
406
Chapter 27 Library reference
SET_MAX_LINES@
Purpose To set the maximum number of lines to be stored for a given ClearWin window.
Syntax BD1A>DC8=4 B4CN<0GN;8=4B/F=
8=C464A F=
Description Sets a maximum to the number of lines of output (= > 50) that is to be stored by the
ClearWin window with handle F. Before storing line = +1, line 1 is deleted etc..
SET_MOUSE_CURSOR_POSITION@
Purpose To set the position of the mouse with respect to a given window.
Syntax BD1A>DC8=4 B4CN<>DB4N2DAB>AN?>B8C8>=/ F G H
8=C464A F G H
Description F is the handle of window, G is the x position relative to the window, and H is the y
position relative to the window. If F is zero, the positioning is relative to the top left-
hand corner of the screen itself.
SET_OLD_RESIZE_MECHANISM@
Purpose To revert to the old ClearWin+ resizing strategy.
Syntax BD1A>DC8=4 B4CN>;3NA4B8I8=6N<4270=8B</
Description In the original ClearWin+ specification you could create windows which would re-size
without any control changing its dimensions. This happened if you used %ww but
either did not use a pivot (%pv), or applied a pivot to a control which could not use it.
To obtain the old specification you should call B4CN>;3NA4B8I4N<4270=8B</. The
new scheme is described on page 94.
407
ClearWin+ User’s Guide Fortran
SET_OPEN_DIALOG_PATH@
Purpose To set the initial directory before displaying the standard file open dialog box.
Syntax BD1A>DC8=4 B4CN>?4=N380;>6N?0C7/ ?0C7
See also %fs, %ft, 64CN58;C4A43N58;4/
SET_PRINTER_ORIENTATION@
Purpose To set the printer orientation to portrait or landscape.
Syntax BD1A>DC8=4 B4CN ?A8=C4AN>A84=C0C8>=/ E
8=C464A E
Description This routine can be called before >?4=N?A8=C4A/ and >?4=N?A8=C4A / or before
using one of the standard call-back functions '?A8=C4ANB4;42C', '?A8=C4AN>?4=',
or '?A8=C4AN>?4= '.
SET_RGB_COLOURS_DEFAULT@
Purpose To set the global default to RGB colour mode.
Syntax BD1A>DC8=4 B4CNA61N2>;>DABN3450D;C/ 1>>;
8=C464A 1>>;
Description Currently by default ClearWin+ operates in VGA colour mode in which colours are
represented by palette index values. RGB colour mode is recommended for new
programs and this routine can be used to change the default. DB4NA61N2>;>DAB/ is
similar but relates to a given drawing surface. See page 136 for further details.
Use an input value of 1 to change the default to RGB colour mode.
See also DB4NA61N2>;>DAB/, VaJaVQNR^[^dabL
408
Chapter 27 Library reference
SET_SOUND_SAMPLE_RATE@
Purpose To set the sampling speed.
Syntax BD1A>DC8=4 B4CNB>D=3NB0<?;4NA0C4/ A0C4
8=C464A A0C4
Description The sampling rate is the frequency at which the sound sample will be played back or
recorded. Do not change this value whilst B>D=3N?;0H8=6/ or B>D=3NA42>A38=6/
return a value of 1. The maximum value that is permissible is dependant of the sound
device being used and you should consult the relevant technical notes supplied with it.
Common Windows values are maximum 44100 (44.1KHz), midrange 22050
(22.05khz) and minimum 11025 (11.025khz) - also the default. It should also be noted
that there will be an absolute minimum. There is no sense in recording at anything
less than 8000 (Hz), which is approximately the same sample rate as a telephone
connection, as the recording quality would be too low for practical use.
When selecting a suitable value it should also be noted that the sample rate must be set
to twice that of the maximum frequency you wish to record, this is to preserve quality
and reduce alias distortion.
For example:
If the maximum frequency to be recorded is 10khz (10000) then the sample rate must
be set to 20Khz (20000).
Note that this will require a large of amount storage.
See also FA8C4NF0E4N58;4/ ?;0HNB>D=3/
B>D=3N?;0H8=6/?;0HNB>D=3NA4B>DA24/ B>D=3NA42>A38=6/
B>D=3NA42>A38=6/B>D=3NB0<?;4NA0C4/
SHOW_MOVIE@
Purpose To show a video.
Syntax BD1A>DC8=4 B7>FN<>E84/58;4>?C
8=C464A >?C
270A02C4A 58;4
Description B7>FN<>E84/ opens the given .AVI file and shows it in a window. If >?C is zero, the
user must click the play button to start the movie. If >?C is 1, the movie starts
immediately. Do not call this routine with a file which does not exist - if necessary
check in advance.
409
ClearWin+ User’s Guide Fortran
When B7>FN<>E84/ returns, the movie window will be displayed and will be under
the user’s control. The <>E84N?;0H8=6/ function can be used to determine when the
user finally closes the window. If a second call to B7>FN<>E84/ is made before a
previous movie has finished playing, Clearwin+ will wait until the first movie
completes.
Movie files can include a sound track, which will be played if a sound card us installed
in your PC.
SIZE_IN_PIXELS@
Purpose To set the font size in pixels.
Syntax BD1A>DC8=4 B8I4N8=N?8G4;B/ 74867C F83C7
8=C464A 74867C F83C7
Description This routine allows you to specify the height and width of a font in pixels.
See also B8I4N8=N?>8=CB/
SIZE_IN_POINTS@
Purpose To set the font size in points.
Syntax BD1A>DC8=4 B8I4N8=N?>8=CB/ 74867C F83C7
8=C464A 74867C F83C7
Description Sets the 74867C and F83C7 of a font that is being used on a drawing surface.
See also B8I4N8=N?8G4;B/ B4;42CN5>=C/
SIZEOF_CLIPBOARD_TEXT@
Purpose To get the size of the text held in the clipboard.
Syntax 8=C464A 5D=2C8>= B8I4>5N2;8?1>0A3NC4GC/
Description This routine returns the length of the Windows clipboard text array (25NC4GC or
25N>4<C4GC format). The returned length includes a null (270A) character that
terminates the string.
410
Chapter 27 Library reference
SOUND_PLAYING@
Purpose To test for ongoing sound output.
Syntax 8=C464A 5D=2C8>= B>D=3N?;0H8=6/
Description This function returns 1 while there is sound output and zero when there is none. It is
most useful when used to ‘join’ several sound samples together by detecting when one
has finished so that the next may be started.
Return value Returns 1 if sound is playing otherwise zero.
See also FA8C4NF0E4N58;4/ A42>A3NB>D=3/ ?;0HNB>D=3/
?;0HNB>D=3NA4B>DA24/ B>D=3NA42>A38=6/B>D=3NB0<?;4NA0C4/
B4;42CNB0<?;8=6NA0C4/
SOUND_RECORDING@
Purpose To test if a recording is being made.
Syntax 8=C464A 5D=2C8>= B>D=3NA42>A38=6/
Return value Returns 1 while the sound system is recording and 0 when it is idle.
See also FA8C4NF0E4N58;4/ A42>A3NB>D=3/ B>D=3N?;0H8=6/
B>D=3NB0<?;4NA0C4/ ?;0HNB>D=3/ B4;42CNB0<?;8=6NA0C4/
?;0HNB>D=3NA4B>DA24/
SOUND_SAMPLE_RATE@
Purpose To return the current sound sampling rate.
Syntax 8=C464A 5D=2C8>= B>D=3NB0<?;4NA0C4/
Return value Returns the value supplied to B4CNB>D=3NB0<?;4NA0C4/ or the default sample rate.
See also FA8C4NF0E4N58;4/ A42>A3NB>D=3/ ?;0HNB>D=3/
411
ClearWin+ User’s Guide Fortran
START_PROCESS@
Purpose To create a new process and wait for it to terminate.
Syntax 8=C464A 5D=2C8>= BC0ACN?A>24BB/ 2><<0=3 ?0A0<B
270A02C4A 2><<0=3?0A0<B
Description 2><<0=3 is the command line that is to be executed. ?0A0<B is a string of parameters
that is appended to the command line.
Return value Returns 0 or a positive value if successful. A return value of -1 indicates an error
condition.
Notes The new process is given the same ‘show’ state as that used when creating the calling
process. This will usually be ‘show normal’ or ‘show maximised’.
The alternative function BC0ACN??A>24BB/ takes the same form but returns
immediately (i.e. it does not wait for the created process to terminate).
Example 8=C464A BC0ACN?A>24BB/X
X,BC0ACN?A>24BB/ad]TgT
4=3
STOP_AUDIO_CD@
Purpose To stop audio playback from the CD.
Syntax BD1A>DC8=4 BC>?N0D38>N23/
See also 2;>B4N23NCA0H/ ?4=N23NCA0H/?;0HN0D38>N23/B4CN23N?>B8C8>=/
TEMPORARY_YIELD@
Purpose Provides an alternative to H84;3N?A>6A0<N2>=CA>;/HNC4<?>A0A8;H.
Syntax BD1A>DC8=4 C4<?>A0AHNH84;3/
412
Chapter 27 Library reference
UNDERLINE_FONT@
Purpose To add an underline to text on the current drawing surface.
Syntax BD1A>DC8=4 D=34A;8=4N5>=C/ 02C8E4
8=C464A 02C8E4
Description When using the function 3A0FN270A02C4AB/ ^n a drawing surface with any font
selected, a call to this routine with a value of 1 will make subsequent text underlined.
A further call with a value of 0 will switch off the effect.
See also A>C0C4N5>=C/ B20;4N5>=C/ B4;42CN5>=C/ 8C0;82N5>=C/ 1>;3N5>=C
UNMAP_FILE@
Purpose To close a file map (Win32 only).
Syntax BD1A>DC8=4 D=<0?N58;4/ ?CA
270A02C4A ?CA
Description File maps are closed automatically when the program terminates but can be closed
sooner by calling this routine. ?CA is a value returned by <0?N58;4N5>ANA4038=6/
or <0?N58;4N5>ANA403NFA8C4/
See also <0?N58;4N5>ANA4038=6/, <0?N58;4N5>ANA403NFA8C4/
UPDATE_WINDOW@
Purpose To redraw a ClearWin window.
Syntax BD1A>DC8=4 D?30C4NF8=3>F/F
8=C464A F
Description Causes the entire client area to be ‘invalidated’ and therefore re drawn. This should
not be confused with the ClearWin+ function F8=3>FND?30C4/ (see page 26) that is
used for format windows.
413
ClearWin+ User’s Guide Fortran
USE_APPROXIMATE_COLOURS@
Purpose To switch off colour matching for all drawing surfaces.
Syntax BD1A>DC8=4 DB4N0??A>G8<0C4N2>;>DAB/ 1>>;
8=C464A 1>>;
Description By default, routines that draw to a drawing surface use a colour matching algorithm
that selects an optimum colour match corresponding to the supplied colour value.
Colour matching can be switched off (for all drawing surfaces) by calling this routine
with the argument set to zero. A non-zero value switches on again.
If automatic colour matching is switched off, a matched colour can still be obtained
from 64CN<0C2743N2>;>DAB/. The result is used as an RGB value in any of the
drawing surface routines.
Using this routine may lead to a significant improvement in the performance of your
program since colour matching is often unnecessary. When colour matching is
desirable, it is only necessary to apply the matching algorithm once for each colour that
is used.
USE_RGB_COLOURS@
Purpose To switch between colour modes on a drawing surface.
Syntax 8=C464A 5D=2C8>= DB4NA61N2>;>DAB/ 70=3;4 1>>;
8=C464A 70=3;4 1>>;
Description 70=3;4 is the programmer’s handle for the drawing surface as used for example in
B4;42CN6A0?782BN>1942C/ and %`gr. If 70=3;4 is zero then the current drawing
surface is assumed. 1>>; can be either 1 or 0. If it is 1 then the A61 colour mode will
be used otherwise E60 colour mode (see page 136).
Return value Returns 1 for success or zero if the handle is not valid.
See also B4CNA61N2>;>DABN3450D;C/, VaJaVQNR^[^dabL
USE_WINDOWS95_FONT@
Purpose To set the default F8=8>/ font to Windows 95 font (Windows 95 only).
Syntax BD1A>DC8=4 DB4NF8=3>FB($N5>=C/
414
Chapter 27 Library reference
Description If this routine is called, by default all F8=8>/ dialogs will use the Windows 95 font
where available. This is equivalent to placing %`sf at the front of each F8=8>/ string
and adding a grave accent to every existing %sf format.
See also %sf
WAV_FILE_READ@
Purpose To read a WAV file as a samples wave-form.
Syntax 8=C464A 5D=2C8>= F0EN58;4NA403/ 70=3;4 ;45C
A867CB0<?;4B
8=C464A 70=3;4B0<?;4B
8=C464A! ;45CB0<?;4B A867CB0<?;4B
Description Samples sound data is read from the WAV file, returning at most B0<?;4B values.
70=3;4 should have been returned by a call to >?4=NF0EN58;4NA403/.
Return value Returns the number of samples read, which can be less than B0<?;4B if the end of the
file is reached.
See also >?4=NF0EN58;4NA403/
WAV_FILE_WRITE@
Purpose To store any recorded data.
Syntax BD1A>DC8=4 F0EN58;4NFA8C4/ 70=3;4 ;45C A867CB0<?;4B
8=C464A 70=3;4B0<?;4B
8=C464A! ;45CB0<?;4B A867CB0<?;4B
Description The data contained in ;45Cand A867C is written to disk in WAV file format. 70=3;4
should have been returned by a call to >?4=NF0EN58;4NFA8C4/.
See also >?4=NF0EN58;4NFA8C4/
415
ClearWin+ User’s Guide Fortran
WIN_COUA@
Purpose To output n characters from a string to a ClearWin window.
Syntax BD1A>DC8=4 F8=N2>D0/FBCA=
8=C464A F=
270A02C4A BCA
Description Outputs = characters from the string BCA to the ClearWin window with handle FThis
function provides an alternative to the standard Fortran routines FA8C4 and ?A8=C
that are normally used for text output to a ClearWin window.
WIN_GETCHAR@
Purpose To read a character from the keyboard.
Syntax 8=C464A F8=N64C270A/F
8=C464A F
Description Changes the input focus to the ClearWin window with handle F and reads a character
from the keyboard. This function provides an alternative to the standard A403 routine.
WIN_GETLINE@
Purpose To read a line of text from the keyboard.
Syntax BD1A>DC8=4 F8=N64C;8=4/F;8=4
8=C464A F
270A02C4A ;8=4
Description Changes the input focus to the ClearWin window with handle F and reads a line of text
from the keyboard. This function provides an alternative to the standard A403 routine.
WINDOWS_95_FUNCTIONALITY@
Purpose To test if Windows 95 is in use.
Syntax 8=C464A 5D=2C8>= F8=3>FBN($N5D=2C8>=0;8CH/
416
Chapter 27 Library reference
WKEY_WAITING@
Purpose To test if there are any keys in a ClearWin window keyboard buffer.
Syntax 8=C464A 5D=2C8>= F:4HNF08C8=6/
Description This routine is only for use in a ClearWin window (e.g. with %cw).
Return value Returns the number of keys in the keyboard buffer.
See also 5443NF:4H1>0A3/ 5;DB7NF:4H1>0A3/ 64CNF:4H/ 64CNF:4H /
WRITE_GRAPHICS_TO_BMP@
Purpose To write the current drawing surface to a BMP file.
Syntax BD1A>DC8=4 FA8C4N6A0?782BNC>N1<?/ 58;4=0<4 4AA>A
270A02C4A 58;4=0<4
8=C464A 4AA>A
Description Writes the current drawing surface to the file with name 58;4=0<4. 4AA>A returns
one of the following:
0 success
1 no current drawing surface or unable to open file
3 unable to write to file
See also 8<?>ACN1<?/ 4G?>ACN1<?/
WRITE_GRAPHICS_TO_PCX@
Purpose To write the current drawing surface to a PCX file.
Syntax BD1A>DC8=4 FA8C4N6A0?782BNC>N?2G/ 58;4=0<4 4AA>A
270A02C4A 58;4=0<4
8=C464A 4AA>A
Description Writes the current drawing surface to the file with name 58;4=0<4. 4AA>A returns
one of the following:
417
ClearWin+ User’s Guide Fortran
0 success
1 no current drawing surface or unable to open file
3 unable to write to file
See also 8<?>ACN?2G/ 4G?>ACN?2G/
WRITE_WAV_FILE@
Purpose To store any recorded data.
Syntax BD1A>DC8=4 FA8C4NF0EN58;4/ 58;4=0<4 270= B0<?;4B
;45C A867C
270A02C4A 58;4=0<4
8=C464A 270= B0<?;4B
8=C464A! ;45CB0<?;4B A867CB0<?;4B
?0A0<4C4A B0<?;4B
Description The data contained in ;45Cand A867C is written to disk in wave file format.
58;4=0<4 should be set to the desired file name. 270= can be either 1 (mono) or 2
(stereo). B0<?;4B is the length of both the ;45Cand A867C data arrays (they should
be identical).
This routine writes a whole WAV file in one go, so it must be of a size that can fit into
memory.
See also B>D=3NA42>A38=6/ A42>A3NB>D=3/
B>D=3N?;0H8=6/?;0HNB>D=3NA4B>DA24/ ?;0HNB>D=3/
B4CNB>D=3NB0<?;4NA0C4/
YIELD_PROGRAM_CONTROL@
Purpose To process Windows messages.
Syntax BD1A>DC8=4 H84;3N?A>6A0<N2>=CA>;/>?C8>=
8=C464A >?C8>=
Description This routine contains a Windows message loop. It is called automatically by
ClearWin+ so that the programmer does not need to include a message loop in a
program. It can be used within a program to ensure that a process does not totally take
over the CPU. >?C8>= may be either HN?4A<0=4=C;H or HNC4<?>A0A8;H.
You may need to call this routine using HNC4<?>A0A8;H, if the program makes
418
Chapter 27 Library reference
protracted use of the CPU and you want to allow it to respond to events (such as mouse
events) whilst the processing continues. Call this routine at suitable points during the
process to enable the message queue for the current application to be processed.
(Message queues for other applications that are running will automatically be
processed because Windows 95 and Windows NT are pre-emptive multi-tasking
operating systems.) C4<?>A0AHNH84;3/ is the same as
H84;3N?A>6A0<N2>=CA>;/HNC4<?>A0A8;H
Calling this routine using HN?4A<0=4=C;H is equivalent to reaching the END
statement of a ClearWin+ program.
419
ClearWin+ User’s Guide Fortran
420
28.
Glossary
Accelerator keys
An accelerator key is a key sequence, such as Alt-C that can directly activate some
process in a window (i.e. without popping up a menu). Accelerators can be defined
using %ac. A special case of an accelerator key is defined using %es, which causes a
window to respond to the ESC key by closing.
Bitmap
A rectangular image stored as binary data (see %bm). Bitmaps are stored in files with
the .BMP suffix.
Button
A button is a control that is designed to respond to a mouse click. Several types of
buttons are available. Simple 3-dimensional press and release buttons containing text
(and sometimes an icon as well) can be created using %bt. Radio buttons are created
with %rb. These are point like structures (with the name along side) that toggle when
pressed. Buttons containing a picture can be created with %tb.
Call-back function
A ClearWin+ call back function is a function passed to F8=8>/ (and certain other
functions) that is called when certain events occur. In ClearWin+, all such functions
take no arguments and return an integer result.
Caption
The distinctively coloured strip across the top of most windows that contains the title
together with some controls for manipulating the window. A window can be dragged
by its caption. See %ca.
Child window
A child window is a window that is contained within a larger window (which could be
a child of yet another window). The sub-windows of an MDI application (see %fr and
%aw) are children, as are the separate sheets of a property sheet (see %ps and %sh).
421
ClearWin+ User’s Guide Fortran
422
Chapter 28 Glossary
Edit box
This term is used to refer to boxes created with %eb to perform text editing. The term
may also include other boxes containing editable text, such as numeric input boxes
created with %rd, %rf, etc..
Focus
A control is said to have focus if it is the one that will respond to keyboard input.
Even buttons can have focus - a button with focus can be activated by pressing the
space bar. Usually the appearance of a control changes slightly when it acquires
focus.
Font
Information describing the graphical layout of a set of characters. Windows fonts can
be variable pitch (e.g. Times New Roman) or fixed pitch (e.g. Courier New). Variable
pitch fonts fit characters into different amounts of horizontal space depending on their
shape and the shapes of their neighbours (see %fn). Each font type comes in several
sizes (see %ts) and variants - italic (%it), bold (%bf) and underline (%ul).
Format
format window a window that has been created using F8=8>/.
format string the first argument of F8=8>/.
format code a format substring beginning with %.
format modifier one of the characters ^ ` ~ ? appearing in a format code.
GIF file
An image file format popular in World Wide Web documents. GIF files can be
partially transparent and/or animated. They can be incorporated into ClearWin+
programs as resources and accessed using the %gi format.
Greyed out
This expression refers to the process by which certain menu items, buttons, etc. can be
given a washed out appearance which is an indication to the user that they are not
available in current circumstances. Many controls and menus can be controllably
greyed using the ‘~’ format modifier together with an integer control variable that
specifies the current state.
GUI
This stands for Graphical User Interface, and refers to a program with a Windows
interface (or the equivalent on other platforms).
Handle
A handle is an integer supplied by Windows (in the context of Windows
programming) used to refer to an object. Thus a window handle is an integer used to
refer to a whole window or an individual control (most of which are treated as small
child windows). A bitmap handle is an integer used to refer to a bitmap, etc..
423
ClearWin+ User’s Guide Fortran
424
Chapter 28 Glossary
Resources
Microsoft jargon for non-program information (e.g. images or sounds) built into a
program. Resources are specified in resource scripts, and are compiled with the
resource compiler (SRC). ClearWin+ programs use resources to incorporate images,
sounds, and hypertext into the program.
RGB colours
The Windows API represents a colour in terms of the intensity (in the range 0 to 255)
of its red, green and blue components. Each component is thus an 8-bit value and the
three components are packed into a 32-bit integer with the least significant 8 bits
being red, the next 8 bits green and then blue. The most significant 8 bits are not
used. The packing process is done for you by the function A61/. For example
A61/!$$ represents pure red.
Screen resolution
The number of pixels horizontally and vertically on the entire screen. Typical values
are 640 x 480, 800 x 600, and 1024 x 768. The screen will also have a colour
resolution, typically 16, 256, 16k, or higher.
Screen saver
A program designed to run while the computer is idle. Usually such programs are
designed to stop as soon as mouse or keyboard input is received (see %ns and %sv).
Scroll bar
A scroll bar is a structure to the right of a window or control that can be used to shift
the contents vertically, or at the bottom of a window to shift the contents horizontally.
A scroll bar has an arrow structure at either end that will scroll the contents by one
unit (e.g. one line if the contents is text) and a moveable control (known as a thumb)
that can be dragged to make larger movements. Movements of one page (the exact
meaning of which depends on the window contents) can be made by clicking above or
below the thumb (see %hx and %vx).
Shortcut keys
A shortcut key represents a way of accessing a menu using the keyboard. Each item of
a menu can have a letter underlined, indicating that it can be selected by holding
down the Alt key and pressing the letter (or certain other keys). The components of
subsequent sub-menus can then be selected by pressing further keys corresponding to
underlined letters in the menus. The whole process of underlining the letters and
responding to the keyboard is controlled by merely prefixing the letter in the menu
item by an ‘&’ (see %mn and %sm).
Standard character string
This is the name given to text in a format string that is either placed in square
brackets or is replaced by an @ symbol and represented by an argument.
425
ClearWin+ User’s Guide Fortran
Status bar
This is a strip at the bottom of a window with a distinct colour (usually grey) in which
special information is placed. See the %ob format for details of how to create one.
Thumb
The name given to a blank box that appears on a scroll bar. One of the mechanisms
for scrolling involves dragging this box with the mouse.
Toolbar
A toolbar is a rectangular array of bitmap buttons, usually but not always located
under the window menu bar. Toolbars can be created as arrays of bitmap buttons
using %tb.
Win16
This refers to programs that interact with the 16-bit API of Windows 3.1. This is also
available under Windows 95. Salford compilers generate 32-bit code for Win16 that
operates using a 16/32 interface. Although the Win16 API is available under
Windows NT, there are certain restrictions that prevent the above 16/32 interface from
working - Win32 must be used for this operating system. The ClearWin+ User’s
Supplement provides additional information for writing Win16 applications.
Win32
This refers to programs that exploit the 32-bit mode of operation available in
Windows 95 and Windows NT. All Salford compilers are 32-bit, but the non-Win32
products execute in 32-bit mode but provide an interface to the 16-bit operating system
via DBOS and/or WDBOS.
Windows application
A Windows program - that is any program that opens at least one window. Non
Windows applications use DBOS and read and write to the screen or DOS box.
Under Win32 the difference is very slight, however under Win 3.1 non-Windows
applications created with Salford compilers use DBOS and operate from within a
DOS box.
Windows control
A windows control is any part of a window that operates as a distinctive entity. For
example, buttons, %rd integer input boxes, and toolbars are all controls.
Windows API
This is the set of routines supplied by Microsoft to access the features of Windows.
All Windows programs ultimately call these routines. For example, requests to
ClearWin+ are executed internally by making calls to the Windows API.
426
Chapter 28 Glossary
Windows message
Windows communicates information about events (such as key presses, mouse
movements, etc.) to the program by means of ‘messages’. These are small structures
that are stored in a queue and accessed by means of a call to the Windows API. This
process is handled automatically by ClearWin+. Specific Windows messages are
referred to by names such as WM_PAINT, WM_CREATE, etc.
WM_PAINT message
This is a message sent by Windows to an application to tell it to ‘re-paint’ one of its
windows (for example because another window has obscured it). ClearWin+
programmers do not need to be aware of the fact that a window’s contents may have to
be regenerated in this way. However some call-backs, such as the re-colour call back
from %eb edit boxes, may be activated in response to this message.
427
ClearWin+ User’s Guide Fortran
428
Appendix A.
This appendix contains information about functions that feature in the Salford DOS
(DBOS) graphics library. It describes the extent to which this library has been ported
to ClearWin+. The following classification of DBOS graphics functions can be made
in relation to ClearWin+.
1. Functions that are useful in new programs (marked 9). Some of these will have
identical usage under ClearWin+ to that under DBOS. For some the functionality
is slightly different. Details are given in Chapter 27.
2. Functions that can be used in new programs (marked ;) but for which there is a
suitable alternative. Details for these functions are given in the ClearWin+ User’s
Supplement. A table of the alternative routines is given at the end of this
appendix. The alternatives are documented in this guide.
3. Functions that could be ported from existing DBOS programs but which should
not be written into new programs because there is a better alternative under
ClearWin+ (marked Ö). A table of alternative routines is given at the end of this
appendix.
4. Functions which have no operation or are not useful under ClearWin+ but can be
left in old programs that have been ported from DBOS (marked |).
5. Functions which have not been implemented under ClearWin+ (marked 8).
Graphics
CLEAR_SCREEN@ Clears the drawing surface. 9
CLEAR_SCREEN_AREA@ Clears a rectangular area of the drawing surface. ;
COMBINE_POLYGONS@ Gets the handle for a combination of polygons. Ö
CREATE_POLYGON@ Gets a handle for a specified polygon. Ö
DELETE_POLYGON_DEFINITION@ Deletes a polygon definition. Ö
429
ClearWin+ User’s Guide Fortran
430
Appendix A Functions ported from DBOS
Graphics plotter/screen
CLOSE_PLOTTER@ Closes the plotter device or file. Ö
CLOSE_VSCREEN@ Closes the virtual screen. ;
CREATE_SCREEN_BLOCK@ Creates a screen block in memory. ;
GET_DACS_FROM_SCREEN_BLOCK@ Uses palette information from a PCX file. ;
GET_SCREEN_BLOCK@ Saves a rectangular area of the screen. ;
NEW_PAGE@ Provides a new page on the drawing surface. 9
OPEN_PLOT_DEVICE@ Opens the plotter. Ö
OPEN_PLOT_FILE@ Directs plotter output to a file. Ö
OPEN_VSCREEN@ Opens a screen block as the virtual screen. ;
PCX_TO_SCREEN_BLOCK@ Loads a file a screen block. ;
PLOTTER_SET_PEN_TYPE@ Selects a pen type for the plotter. |
RESTORE_SCREEN_BLOCK@ Displays a previously saved area of the screen. ;
SCREEN_BLOCK_TO_PCX@ Saves a screen block a file. ;
SCREEN_BLOCK_TO_VSCREEN@ Loads a screen block to the virtual screen. ;
SCREEN_TO_VSCREEN@ Loads the graphics screen to the virtual screen. ;
VSCREEN_TO_PCX@ Saves the virtual screen to a file. ;
VSCREEN_TO_SCREEN@ Loads the virtual screen to the graphics screen. ;
WRITE_TO_PLOTTER@ Writes a string to the plotter. |
431
ClearWin+ User’s Guide Fortran
Graphics printer
CLOSE_GRAPHICS_PRINTER@ Closes the graphics printer device or file. Ö
GET_PCL_PALETTE@ Gets the colour definitions for a given number of9
colours.
LOAD_PCL_COLOURS@ Loads the standard colour definitions. 9
OPEN_GPRINT_DEVICE@ Opens a graphics printer. Ö
OPEN_GPRINT_FILE@ Directs graphics printer output to a file. Ö
PRINT_GRAPHICS_PAGE@ Prints a graphics page. 9
SELECT_DOT_MATRIX@ Selects an Epson compatible dot matrix printer 8
SELECT_PCL_PRINTER@ Specifies attributes of a PCL printer. Ö
SET_PCL_BITPLANES@ Sets the number of colours in the image. |
SET_PCL_GAMMA_CORRECTION@ Alters the “gamma correction” for colours. |
SET_PCL_GRAPHICS_DEPLETION@ Improves the image quality. |
SET_PCL_GRAPHICS_SHINGLING@ Makes a number of print passes. |
SET_PCL_LANDSCAPE@ Sets LANDSCAPE or PORTRAIT orientation. ;
SET_PCL_PALETTE@ Loads the colour definitions. |
SET_PCL_RENDER@ Sets the “rendering algorithm”. |
Mouse
DISPLAY_MOUSE_CURSOR@ Shows the mouse cursor on the screen. |
GET_MOUSE_BUTTON_PRESS_COUNT@ Gets the number of times a button has been pressed. |
GET_MOUSE_EVENT_MASK@ Gets the mask for the most recent mouse interrupt. |
GET_MOUSE_PHYSICAL_MOVEMENT@ Gets the mouse pad distance from the last call. |
GET_MOUSE_POSITION@ Gets the present state of the mouse cursor. Ö
GET_MOUSE_SENSITIVITY@ Gets the values of the physical movement ratios and|
the double speed threshold.
HIDE_MOUSE_CURSOR@ Hides the mouse cursor on the screen. |
INITIALISE_MOUSE@ Initialises the mouse driver. |
MOUSE@ Performs a mouse interrupt. |
432
Appendix A Functions ported from DBOS
CLOSE_GRAPHICS_PRINTER@ CLOSE_PRINTER@
CLOSE_PLOTTER@ CLOSE_PRINTER@
COMBINE_POLYGONS@ DRAW_FILLED_POLYGON@
CREATE_POLYGON@ DRAW_FILLED_POLYGON@
DELETE_POLYGON_DEFINITION@ DRAW_FILLED_POLYGON@
DRAW_HERSHEY@ DRAW_CHARACTERS@
DRAW_LINE@ DRAW_LINE_BETWEEN@
DRAW_TEXT@ DRAW_CHARACTERS@
433
ClearWin+ User’s Guide Fortran
ELLIPSE@ DRAW_ELLIPSE@
FILL_ELLIPSE@ DRAW_FILLED_ELLIPSE@
FILL_POLYGON@ DRAW_FILLED_POLYGON@
FILL_RECTANGLE@ DRAW_FILLED_RECTANGLE@
GET_ALL_PALETTE_REGS@ GET_COLOURS@
GET_MOUSE_POSITION@ CLEARWIN_INFO@
GET_PIXEL@ GET_POINT@
GET_VIDEO_DAC_BLOCK@ GET_COLOURS@
GRAPHICS_MODE_SET@ LOAD_STANDARD_COLOURS@
HERSHEY_PRESENT@ DRAW_CHARACTERS@
MOUSE_SOFT_RESET@ SET_MOUSE_CURSOR_POSITION@
MOVE_POLYGON@ DRAW_FILLED_POLYGON@
OPEN_GPRINT_DEVICE@ OPEN_PRINTER@
OPEN_GPRINT_FILE@ OPEN_PRINTER_TO_FILE@
OPEN_PLOT_DEVICE@ OPEN_PRINTER@
OPEN_PLOT_FILE@ OPEN_PRINTER_TO_FILE@
POLYLINE@ DRAW_POLYLINE@
RECTANGLE@ DRAW_RECTANGLE@
SELECT_PCL_PRINTER@ OPEN_PRINTER@
SET_ALL_PALETTE_REGS@ SET_COLOURS@
SET_DEVICE_PIXEL@ DRAW_POINT@
SET_MOUSE_POSITION@ SET_MOUSE_CURSOR_POSITION@
SET_PALETTE@ SET_COLOURS@
SET_PCL_LANDSCAPE@ SET_PRINTER_ORIENTATION@
SET_PIXEL@ DRAW_POINT@
434
Appendix A Functions ported from DBOS
SET_VIDEO_DAC@ SET_COLOURS@
SET_VIDEO_DAC_BLOCK@ SET_COLOURS@
435
ClearWin+ User’s Guide Fortran
436
Index
Index-1
ClearWin+ User’s Guide Fortran
Index-2
Index
Index-3
ClearWin+ User’s Guide Fortran
Index-4
Index
P
I Parameter box, 42
Icons, 77, 424 PASTE, standard call-back, 206
IMPLICIT NONE, 295 PAUSE Fortran statement, 309
IMPORT_BMP@ routine, 374 PERFORM_GRAPHICS_UPDATE@ routine, 385
IMPORT_PCX@ routine, 375 PERMIT_ANOTHER_CALLBACK@ routine, 386
INC, standard call-back, 209 PLAY_AUDIO_CD@ routine, 386
INSERT_EDIT_STRING@ routine, 116 PLAY_CLIPBOARD_METAFILE@ routine, 387
INTERNET_HYPERLINK, standard call-back, 210 PLAY_SOUND@ routine, 387
Italic fonts, 97 PLAY_SOUND_RESOURCE@ routine, 388
ITALIC_FONT@ routine, 375 Popup menus, 84
PRINT_ABORT, standard call-back, 210
PRINT_DIB@ routine, 388
L PRINT_GRAPHICS_PAGE@ routine, 389
Line selection, 144 PRINT_OPENGL_IMAGE@ routine, 389
List box, 62 PRINTER_OPEN, standard call-back, 210
LOBYTE@ routine, 375 PRINTER_OPEN1, standard call-back, 210
LOWORD@ routine, 376 PRINTER_SELECT, standard call-back, 210
Property sheet, 129
Property sheet close, 130
M PUT_DIB_BLOCK@ routine, 391
MAKE_BITMAP@ routine, 376
MAKE_ICON@ routine, 377
MAP_FILE_FOR_READ_WRITE@, 378 R
MAP_FILE_FOR_READING@, 378 READ_URL@ routine, 204
Maximise, 424 RECORD_SOUND@ routine, 391
MDI frames, 123, 424 Recording events, 313
Menus, 81, 424 RELEASE_BITMAP_DC@ routine, 392
METAFILE_TO_CLIPBOARD@ routine, 379 RELEASE_SCREEN_DIB@ routine, 392
Minimise, 424 REMOVE_ACCELERATOR@ routine, 392
Minimise icon, 78 REMOVE_CURSOR_MONITOR@ routine, 393
MOVE_WINDOW@ routine, 379 REMOVE_FOCUS_MONITOR@ routine, 393
MOVIE_PLAYING@ routine, 380 REMOVE_GRAPHICS_ICON@ routine, 393
Multiple selection boxes, 64 REMOVE_KEYBOARD_MONITOR@ routine, 394
REMOVE_MENU_ITEM@ routine, 394
Index-5
ClearWin+ User’s Guide Fortran
Index-6
Index
Subscript font, 98
SUPER_MAXIMISE, standard call-back, 211
W
Superscript font, 98 Wallpaper, 131
System font, 98 WAV_FILE_READ@ routine, 415
System menu, 86 WAV_FILE_WRITE@ routine, 415
SYSTEM_FIXED_FONT, 301 Web links, 204
WIN_COUA@ routine, 416
WIN_GETCHAR@ routine, 416
T WIN_GETLINE@ routine, 416
Tabs, 90 Win16, 426
TEMPORARY_YIELD@ routine, 412 Win32, 426
Text array, 103 Window control types, 126
Text colour, 99 Window position, 126
Text size, 99 Window size, 126
TEXT, standard call-back, 212 WINDOW_UPDATE@, 27
TEXT_HISTORY, standard call-back, 212 Windows 95
Thumb, 426 Graphics region updates, 150
TOGGLE, standard call-back, 212 Scalable font, 98
Toolbar, 426 WINDOWS_95_FUNCTIONALITY, 98
Tree view selection box, 68 Windows API, 426
Windows application, 426
WINDOWS compiler option, 293
U Windows control, 426
Underline font, 97 Windows message, 427
UNDERLINE_FONT@ routine, 413 WINDOWS.INS, 294
UNDO_EDIT_CHANGE@ routine, 115 WINDOWS_95_FUNCTIONALITY @ routine, 416
UNMAP_FILE@ routine, 413 WINIO@ routine, 22
UPDATE_WINDOW@ routine, 413 WKEY_WAITING@ routine, 417
USE_APPROXIMATE_COLOURS@ routine, 414 WM_PAINT message, 427
USE_RESOURCE_LIBRARY@ routine, 294 WRITE_GRAPHICS_TO_BMP@ routine, 417
USE_RGB_COLOURS@ routine, 414 WRITE_GRAPHICS_TO_PCX@ routine, 417
USE_URL@ routine, 204 WRITE_WAV_FILE@ routine, 418
USE_WINDOWS95_FONT@ routine, 414
User defined child window, 131
Y
YIELD_PROGRAM_CONTROL@ routine, 418
V
Variable string, 100
Vertical scroll bar, 62
Index-7
ClearWin+ User’s Guide Fortran
Index-8