The information below is taken from the Pro Fortran for Windows User Guide.Windows Programming This page covers the broad topic of programming for Microsoft Windows using both MRWE and the Win32 API. It covers additional topics of interest such as interfacing with other languages. Where appropriate, sample programs in the C:\Absoft\Examples and C:\Absoft\Examples\Mrwe directories are referenced. USING MRWE The MRWE application framework is a special feature of Pro Fortran which can automatically give your program a Microsoft Windows interface with menus, a text window, and a graphics window. Usually, when you want to create applications with windows and menus, you need to know how to use the Win32 API and the Microsoft user-interface guidelines. When you create an application using MRWE, your program will automatically exhibit these features without the need for intensive Windows programming. MRWE is convenient and flexible to use, and can be easily modified to suit your needs. MRWE is a collection of pre-compiled FORTRAN routines contained in the library file mrwe.lib that you can link with your program. Applications generated by an Absoft compiler are linked with this library when you select MRWE Application as shown in the dialog box below. The FORTRAN source code for MRWE is in the Examples\Mrwe folder and can be used as an example of how to call Win32 API routines. The Absoft Developer Tools Interface allows you to select the format of the executable file. A Target Type setting of MRWE Application will cause your program to be built as a stand-alone, double-clickable application with MRWE providing a window and menus interface. If your FORTRAN code includes its own Windows message loop and Win32 API calls, you should disable MRWE by choosing Console Application for the Target Type of the executable file.
Examine the
The MRWE Window When you start a program that has been linked with the MRWE library, you will see a blank window on the screen and, above it, a menu bar, as shown below. This window is where MRWE displays standard output from FORTRAN programs and is where all standard input is typed. It looks like a terminal display, but allows you to see text that has scrolled off the screen.
Standard input and output are preconnected to the FORTRAN I/O units 5, 6, 9 and *. Any of these except * may be connected instead to a file by specifying the unit in an OPEN statement. After closing the file on that unit, the unit will be reconnected to standard input and output. How Your Program And MRWE Work Together When your program is started, control is first passed to MRWE, which sets up a Windows environment with menus and a window. After the text window appears, the application begins executing your FORTRAN program. By default, you cannot pull down menus, save the output window, or terminate the application until an I/O statement occurs. Your application is completely dedicated to executing your FORTRAN program at maximum speed. During any input
and output statements (i.e. The -N9 compiler option turns on the timer interval feature. Your program will be interrupted at timed intervals to check for Windows messages such as menu selections and mouse activities. The default interval is one-tenth second, which can be changed as described later in this chapter in the Modifying MRWE section. Without the Timer Interval option activated, checking for Windows messages will still occur, but only during FORTRAN input and output statements. If you did not
include the -N9 compiler option when compiling, and your
program is executing lengthy calculations that you want to stop,
you can regain control by typing the Working With Text in MRWE An MRWE application is an MDI (Multiple Document Interface) type of application. This means that there is application frame window which can support multiple document windows within that frame. MRWE currently supports two document windows-a text window and a graphics window. The application frame window that appears is named after the FORTRAN application. The text window is initially titled Input/Output, but changes when the text is saved to a file. You can only type into the window when a READ statement is currently active for standard input (i.e. one of the preconnected units), and only on the last line of the window. Any text that was already in the window when the READ statement began cannot be modified. You can, however, copy any text in the window to the clipboard. Also, when using the extended keyboard, the Home, End, Page Up, and Page Down keys can be used for scrolling. Tab characters (ASCII 9) are expanded into spaces, modulo 8. The MRWE window has a text limit of 262144 characters in 32768 lines. See the Modifying MRWE section for information changing these parameters. Working With Graphics in MRWE By default,
the graphics window is not displayed when an MRWE application begins.
You must explicitly open the graphics window by referencing the
A Windows Device Context provides a device independent graphics context for your program to draw in. When you draw into a device context, your program does need to be concerned with whether that device is a monitor, a printer, or a plotter the device context handles the necessary transformations. The mapping mode controls the conversion of logical units to device units (pixels on a monitor, "dots" on a printer). The origin is the upper left corner of the device and positive x is to the right the direction of positive y depends on the mapping mode. The following logical unit mapping modes are available:
In Windows,
you normally perform your drawing operations in response to a
Begin your
When the MRWE
message loop receives a
Adding Menu Commands to MRWE MRWE provides a number of functions for easily adding menu commands, providing routines that respond to user menu selections, and modifying menu items. New menus and menu commands are added to the MRWE default menu (described later). mrwe_InsertMenu function Use this function insert a new menu on the menu bar or insert a menu command in an existing menu:
flags may be any of the following:
mrwe_AppendMenu function To append a new command to the end of an existing menu, use the function:
mrwe_CheckMenuItem subroutine The
mrwe_EnableMenuItem subroutine The
mrwe_DeleteMenu function The mrwe_DeleteMenu function can be used to delete an entire menu or a single menu command. The function reference arguments are:
Using Timer Functions in MRWE Timers allow
you to execute sections of your program at timed intervals. With
timers, you can animate your program, you can save important data
to files at regular intervals, and so on. Timers work by sending
a To install a
timer, use the
To remove a time, use the subroutine:
Using The MRWE Default Menus An MRWE application automatically has several menus built-in. Following is a description of the commands performed by each item within these default menus.
Save This command saves the MRWE Input/Output window to a text file. The first time the text is saved, the window title is changed to the file name. Save As... This command saves the MRWE Input/Output window to a text file. It displays a standard file dialog prompting for a file name in which to save the text. If the file already exists, you will be prompted to overwrite it. After the text is saved, the window title is changed to the file name. Print... To print the contents of the window to the printer, use this menu item. A dialog box is displayed allowing you to choose the printer and set various other print options. About... This dialog box displays various parameters of the program execution environment including page size, minimum and maximum memory addresses, and CPU type. Exit This command is used to exit the application.
Undo (Ctrl+Z) This command is not used by MRWE and is always disabled (grayed). Cut (Ctrl+X) This command removes the selected text from the window and places it on the Clipboard. Text in the Clipboard may be pasted into other applications. Like other editing commands, this command is only available during a READ statement unless the program was compiled with -N9 option. Copy (Ctrl+C) The Copy command places the selected text from the window onto the Clipboard and leaves the text of the window unchanged. Text on the Clipboard may be pasted into other applications. Like other editing commands, this command is only available during a READ statement unless the program was compiled with -N9 option. Paste (Ctrl+V) This command replaces the selected text in the window with text from the Clipboard. If no text is selected in the window, the Clipboard text is inserted at the insertion point. Like other editing commands, this command is only available during a READ statement unless the program was compiled with -N9 option. Delete This command clears the selected text.
Cascade (Shift+F5) The Cascade command is used to arrange multiple open windows in a overlapped or cascaded manner. Tile (Shift+F6) Use this command to tile multiple windows within the MRWE frame. Arrange Icons Use the Arrange Icons command to order minimized MRWE window icons. Modifying MRWE MRWE is written entirely in FORTRAN and the source code is provided in the directory: C:\Absoft\Examples\Mrwe. There is also a readme file and a makefile supplied to assist you in rebuilding the library if you choose to modify it. To change the maximum number of characters or lines that MRWE can accommodate, edit the mrwe.inc include file and change the PARAMETER statements for the two symbolic constants MAX_CHARS and MAX_LINES. Then rebuild the library with the amake command. A program linked with the MRWE library normally only checks for Windows messages during Input/Output statements. If you compile your program with the -N9 option (the MRWE Events check box in the compiler graphical interface), the compiler inserts code throughout your program to check if a timer has gone off. If the timer has gone off, a Windows message loop is entered to process any pending messages and then control is returned to your program. You can fine tune the timer for your specific application by including the following COMMON block declaration in your program:
The flag is usually set by the timer interrupt routine, but you can force a check of the message queue by setting mrwe_flag to 1. The default delay is 1/10 of a second (100 milliseconds) and can be changed with the mrwe_delay variable. mrwe_resolution controls the resolution of the interrupt timer.
|