Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Compaq Visual Fortran 6

joswart
Beginner
1,080 Views

I am new to visual programming in Fortran and my questions are very basic. I bought Compaq Visual Fortran some years ago and did very basic QuickWin applications, but would like to start using the visual capabilities of the software. I bought the book of Norman Laurence on CVF and although it is a very good book, explaining a lot of the funtionalities of the software, I still donot understand how to get a simple program like e.g. temperature conversions to read inputs from ascreen and display the answer in a screen and to make use of menus, drop down lists, etc.

If someone could just help me with someelementary examples I would be very grateful.

0 Kudos
2 Replies
anthonyrichards
New Contributor III
1,080 Views
If you have CVF 6.6 then you should have access to examples of most Windows functionality. If you look under C:\Program Files\Microsoft Visual Studio\DF98\SAMPLES\DIALOG\TEMP you should find Visual Studioworkspace file TEMP.DSW.
Open Developer Studio and then choose to open this workspace.
After loading, you can open the TEMP.F90 file by clicking it from the 'FileView tab in the left hand paneand, by selecting the 'Resources' tab you should be able to display the dialog box resource template identified as 'IDD_TEMP'.
Each control in the dialog is identified by an integer value stored in variables such as 'IDC_SCROLLBAR_TEMP'.
I have selected the scrollbar in the dialog template in order to show its Properties sheets, including where its identifier 'IDC_SCROLLBAR_TEMP' is inserted.
The dialog controlID'sare automatically stored by DevStudio in a project file 'RESOURCE.FD' which has to be INCLUDED in the project and into the program code to make their values available during compilation, as you see it is in the attached screen shot showing the TEMP.F90 file open.

If you want to respond to a change made to a control, such as a new temperature value being entered into the 'IDC_EDIT_CELSIUS' edit box, you have to assign a 'Callback' routine to it, which is a subroutine that is automatically called when Windows senses a change to that control. The assignment is done using the DlgSetSub function. In this way the three main dialog controls are assigned the callback UpdateTemp using

retlog = DlgSetSub( dlg, IDC_EDIT_CELSIUS, UpdateTemp ) ! An EDIT box control
retlog = DlgSetSub( dlg, IDC_EDIT_FAHRENHEIT, UpdateTemp ) ! An EDIT box control
retlog = DlgSetSub( dlg, IDC_SCROLLBAR_TEMPERATURE, UpdateTemp ) A SCROLLBAR control

Since the same routine is called by different controls, a means of distinguishing which control has caused the call is required. This is implemented in the Fortran code by using a SELECT CASE(control_name)...CASE structure which isolates unique code to be called, depending on the value of the control name (argument 'control_name' in the callback routine'sargument list).

The Dialog is/must beinitialised using the DlgInit function that takes the dialog resource identifier 'IDD_TEMP' as its argument. If the resource is found, the dialog is eventually displayed, after callbacks are assigned to controls, and after preparing initial values for the dialog controls (such as temperature values and scroll bar position and number of steps), by using the function DlgModal. The temperature dialog is closed by slecting 'OK' or 'Cancel' buttons or the 'X' button in the top right corner, after which the dialog resources are released using the DlgUnInit function.

If you do not assign callbacks to controls, then Windows can do nothing in response to changes made to those controls and you get no response to your mouse clicks or keyboard entries.

The above is a start. I would advise playing with this example, using Debug mode to follow values into callback routines so that you can follow exactly how Windows processes the user actions on the dialog controls. This should allow you to become more familiar and therefore more confident with building dialogs. After which you can start on a sample showing the use of Menus. You can try moving, resizing the edit boxes, scroll bar and so on, saving each time, recompiling and then rerunning the code.

(Note in the Temperature example, the dialog resources are held in a file 'TEMP.RC'. When a project is newly-created, the resources are usually saved into a default resource file named 'SCRIPT1.RC')

0 Kudos
joswart
Beginner
1,080 Views
Thank you very much! I will start working on this example.
0 Kudos
Reply