Using Fortran AppWizards to Help Add Modal Dialog Box Coding

Any Fortran project type can use a modal dialog box. Thus, when you create a project, you can use any of the Fortran Project AppWizards to help you create a project that uses a modal dialog box.

To create a "Hello World" Fortran Console application that uses a modal dialog box to display "Hello World!":

  1. Create a new project with the Fortran Console project type named HelloDlg. After you create the project, the Fortran Console AppWizard appears. Select the "A Hello World sample project" option. Your workspace and source file (HelloDlg.f90) will be created for you.

  2. In the Insert menu, select Resource... and select Dialog. Create the box using the dialog resource editor, as follows:
    1. Delete the Cancel button (click the Cancel button and press the Delete key).
    2. Add a new static text control to the dialog box.
    3. You can enlarge or resize the static text control if needed.
    4. Double click on the static text control to edit its properties. Change the Caption to "Hello World!." Under the Styles tab, you might change the Align text option to Center.
    5. Dismiss the dialog box by clicking the x in the upper-right corner of the window.

  3. In the File menu, select Save As... and save the resources to a file named HelloDlg.rc in the project directory.

  4. In the Project menu, select Add To Project -> Files. Select HelloDlg.rc and click OK.

  5. Edit (double-click its name in the FileView ) the file HelloDlg.f90:

    In the code above:

  6. Build the Hellodlg Fortran Console project application. When you execute the application, the dialog box you created appears in front of the Console window:

    displayed output from hellodlg project

  7. Click OK to dismiss the dialog box.

For 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 modeless dialog box.

For information about coding requirements for modal and modeless dialog boxes, see Initializing and Activating the Dialog Box.