Visible to Intel only — GUID: GUID-9970726C-ABEF-44F6-8137-2418BB74B001
Visible to Intel only — GUID: GUID-9970726C-ABEF-44F6-8137-2418BB74B001
Understanding Coding Requirements for Fortran Windowing Applications
This topic covers the following:
General Coding Requirements: WinMain Function and USE Statements
Code Generation Options Using the Fortran Windows Application Wizard
Single Document Interface (SDI) or Multiple Document Interface (MDI) Sample Code
General Coding Requirements: WinMain Function and USE Statements
Coding requirements for Fortran Windowing applications include (in the following order):
WinMain function declaration and interface
The WinMain function declaration and interface are required for Windows Graphical User Interface (GUI) applications (typically use at least the GDI and USER32 Windows API routines). An interface block for the function declaration can be provided. The following function must be defined by the user:
INTEGER(DWORD) function WinMain (hInstance, hPrevInstance, & & lpszCmdLine, nCmdShow) use IFWIN !DEC$ ATTRIBUTES STDCALL, DECORATE, ALIAS:”WinMain” :: WinMain INTEGER(HANDLE), INTENT(IN) :: hInstance, hPrevInstance INTEGER(LPVOID), INTENT(IN) :: lpszCmdLine INTEGER(DWORD), INTENT(IN) :: nCmdShow
In a program that includes a WinMain function, no program unit can be identified as the main program with the PROGRAM statement.
The statement USE IFWIN or other appropriate USE statements
The USE IFWINstatement makes available declarations of constants, derived types and procedure interfaces for much of the Windows Application Programming Interface (API) routines, also referred to as the Windows API. The Intel® Visual Fortran Compiler also provides individual modules for the various libraries that make up the Windows API, such as KERNEL32 and USER32. Any Fortran program or subprogram that references declarations from the Windows API must include a USE statement for either IFWIN, which collects all the available modules, or the appropriate subset modules for the Windows API libraries that are used.
If you want to limit the type of parameters and interfaces for Windows applications or if unresolved references occur when linking your Fortran Windowing application, see the Intel® Visual Fortran Compiler User and Reference Guides for information on calling Windows API routines.
Data declarations for the WinMain function arguments.
Application-dependent code (other USE statements, variable declarations, and then executable code).
For example, consider the first lines of this sample, which uses free-form source code:
INTEGER(DWORD) function WinMain (hInstance, hPrevInstance, & & lpszCmdLine, nCmdShow) use IFWIN !DEC$ ATTRIBUTES STDCALL, DECORATE, ALIAS:”WinMain” :: WinMain INTEGER(HANDLE), INTENT(IN) :: hInstance, hPrevInstance INTEGER(LPVOID), INTENT(IN) :: lpszCmdLine INTEGER(DWORD), INTENT(IN) :: nCmdShow . . .
IFWIN.F90 includes a Fortran version (a subset) of the Windows WINDOWS.H header file.
Code Generation Options Using the Fortran Windowing Application Wizard
When you choose the Fortran Windowing Application project type, you will need to select the type of project.
The following choices are available:
Empty project
Single Document Interface (SDI) sample code
Multiple Document Interface (MDI) sample code
Dialog-based sample code
Single Document Interface (SDI) ActiveX* sample code
Multiple Document Interface (MDI) ActiveX sample code
Dialog-based ActiveX sample code
The ActiveX AppWizards will add additional template code for supporting ActiveX controls in your dialog boxes.
Single Document Interface (SDI) or Multiple Document Interface (MDI) Sample Code
Creating these types of application requires advanced programming expertise and knowledge of the Windows routines API. Such applications call certain library routines and require the statement USE IFWIN. SDI applications display a single window, whereas MDI application can display multiple windows (a main frame window with one or more child windows that appear within the frame window).
For example, select the MDI option from the Fortran AppWizard screen. After you build and run the application (without changing the source files), the following screen might appear after you create two child window by clicking New from the File menu twice:
If you selected the SDI option from the Fortran AppWizard screen and built and ran the application, you could not create child windows within the main window.
For more information:
On using menus and dialogs from SDI and MDI Fortran Windowing applications, see Using Menus and Dialogs in SDI and MDI Fortran Windowing Applications
About SDI and MDI Samples that use the Fortran Windowing project type, see Sample Fortran Windows Applications.
Dialog-Based Sample Code
Dialog applications use a dialog box for the application's main window. Creating these applications requires some knowledge of the Windows routines API, but considerably less than for a SDI or MDI application. These applications call certain Intel Visual Fortran library routines and require the statement USE IFLOGM. Dialog-based applications usually do not have menus.
For example, select the Dialog-based applications from the Fortran AppWizard screen. After you build and run the application (without changing the source files), the following dialog box appears:
You can use dialogs in any project type. Dialogs don’t require the use of a windowing application if you are using the module IFLOGM.
For more information:
On using dialog boxes, see Using Dialog Boxes for Application Controls Overview