Using Fortran AppWizards to Help Add Modeless Dialog Box Coding

To use a modeless dialog box, you typically use a Fortran Windows project type. The Fortran Windows Project AppWizard helps you add coding for using a modeless dialog box.

When you create a project and specify the Fortran Windows project, the Fortran Windows Project AppWizard displays four options (press the F1 key to view an explanation of these options).

Select one of the following to help learn about dialog coding where a dialog box is the primary window of the application:

In the template-like code generated when you select A simple Dialog Based Application option:

In the template-like code generated when you select A simple Single Document Interface (SDI) AppWizard option, to add the dialog box to the client area of the main window:

  1. In the Insert menu, select Resource... and create a new Dialog box. Edit the Dialog Properties. Select the Styles tab and set Styles to Child and Border to Thin.

  2. In the main source file, add the following USE statement:
      USE dflogm
  3. In the main source file, in the function MainWndProc, add a case to handle the WM_CREATE message. In this case, initialize the dialog box in the normal manner. To display the dialog box, call:
       lret = DlgModeless(dlg, SW_SHOWNA, hwndParent)

    In this call, hwndParent is the window handle of the application's main window.

  4. In the main source file, add a call to DlgIsDlgMessage to the message loop, before the call to the Win32 routine TranslateAccelerator. It should look like:
       ! Read and process messages
       do while( GetMessage (mesg, NULL, 0, 0) )
         if ( DlgIsDlgMessage(mesg, dlg) .EQV. .FALSE. ) then
           if ( TranslateAccelerator (mesg%hwnd, haccel, mesg) == 0) then
              lret = TranslateMessage( mesg )
              ret  = DispatchMessage( mesg )
           end if
         end if
       end do 
  5. Optionally, if you want to allow the user to resize the main window, add a case to handle the WM_RESIZE message and change the layout of the dialog box based upon its size.

See the FXPLORER Visual Fortran Sample in ...\SAMPLES\DIALOG for an example of this type of application.