Using Fortran AppWizards to Help Add Modal Dialog Box Coding
When an application displays a modal dialog box, the user must explicitly enter data and close the dialog box before the application resumes execution. Any Fortran project type can use a modal dialog box.
The following creates a "Hello World" Fortran Console application that uses a modal dialog box to display "Hello World!" The first step may vary, depending on your version of Visual Studio*.
- From the list of Fortran project types, selectConsole Application. In the right pane, selectMain Program Code. At the bottom of the window, specify a file name (HelloDlg) and location. Your project and source file (HelloDlg.f90) will be created for you.
- In theFilemenu, selectAdd New Item...and selectResource. Specify a name ofHelloDlg.rcand clickOpen. SelectEdit>Add Resource..., selectDialog, and clickNew. Create the box using the dialog resource editor, as follows:
- Delete theCancelbutton (click theCancelbutton and press theDeletekey).
- Add a new static text control to the dialog box.
- Enlarge or resize the static text control if needed.
- Select the static text control, then selectView>Properties Windowor (right-click and choose Properties) to edit its properties. Change the Caption to "Hello World!." You may also want to change theAlign Textoption to Center.
- Dismiss the dialog box by clicking the x in the upper-right corner of the window.
- In theFilemenu, selectSave All.
- In theProjectmenu, selectAdd Existing Item....Change theFiles of Type:selection toAll Filesand select Resource.h. ClickOpen.
- Select the Resource.h file in the Solution View and the selectView>Property Pages.
- Set the options as follows:
- Command Line: deftofd resource.h resource.fd.
- Description: Generating Fortran include file...
- Outputs: resource.fd.
- ClickOK.
- Edit the fileHelloDlg.f90as follows:
- After theprogram HELLODLGline, add the following line:USE IFLOGM
- Replace the line:print *, 'Hello World'With the following lines:include 'resource.fd' type (DIALOG) dlg logical lret integer iret lret = DlgInit(IDD_DIALOG1, dlg) iret = DlgModal(dlg) call DlgUninit(dlg)
In the code above:- TheUSE IFLOGMline includes the IFLOGM module interfaces to the Dialog routines.
- The lineinclude 'resource.fd'The Include (.FD and .H) Files.
- The function reference toDLGINITinitializes the dialog box.
- The function reference toDLGMODALdisplays the dialog box.
- The call toDLGUNINITfrees the dialog box resources.
- Build the Hellodlg Fortran Console project application. When you execute the application, the dialog box you created appears in front of the Console window:
- ClickOKto dismiss the dialog box.
For Intel Visual Fortran applications using the Fortran Windows project type, you can use the Fortran Windows Project AppWizard to help you add dialog coding for a
Using Fortran AppWizards to Help Add Modeless Dialog Box Coding.
For information about coding requirements for modal and modeless dialog boxes, see
Initializing and Activating the Dialog Box.