Visible to Intel only — GUID: GUID-065A0FC6-3024-49A6-B455-EA74362E69AB
Visible to Intel only — GUID: GUID-065A0FC6-3024-49A6-B455-EA74362E69AB
Using Fortran AppWizards to Help Add Modeless Dialog Box Coding
To use a Using 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 by selecting Fortran Windows Application>Windowing Application, a number of wizards are available. However, only two allow creation of a dialog box that serves as the main window of the application. These are:
Sample SDI (Single Document Interface) code
To create an application where a dialog box is the main window of the application with a menu bar, choose the SDI Code wizard or ActiveX SDI Code wizard.
This also creates the skeleton of an entire application that you can immediately build and run. You can add a dialog box to the client area of the main window (as explained later).
Sample Dialog Code
To create an application where a dialog box is the main window of the application, without a menu bar, choose the Dialog Code wizard or ActiveX Dialog Code wizard.
This creates the skeleton of an entire application that you can immediately build and run to display a sample dialog box. You can add controls to the dialog box and add dialog procedure calls to manipulate the controls and handle dialog callbacks.
Single Document Interface Sample Code
In the template-like code generated when you select the SDI Code or ActiveX SDI Code option, do the following to add the dialog box to the client area of the main window:
Double-click the .rc file, select Edit>Add Resource... and create a new Dialog box. Edit the Dialog Properties. Set Style to Child, Border to Thin, and Title Bar to False .
In the main source file, add the following USE statement:
USE iflogm
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.
In the main source file, add a call to DlgIsDlgMessage to the message loop, before the call to the Windows API routine TranslateAccelerator, as shown in the following:
! 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
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.
Dialog-Based Sample Code
In the template-like code generated when you select the Dialog code or ActiveX Dialog code option, do the following:
Build the project and execute it. The following dialog box is displayed:
Some of the code specific to the dialog routine interfaces and data declarations follows. For this example, the project name is FWin. The project name is used in some of the data declarations:
use iflogm use FWin_dialogGlobals . . . include 'resource.fd' external FWin_dialogSub external FWin_dialogApply ! Variables type (T_MSG) mesg integer ret logical lret
The FWin_dialogGlobals module is defined in a separate source file in that project. The FWin_dialogSub and FWin_dialogApply are subroutines defined later in the main source file that are callback routines for different controls for the dialog box.
The code specific to creating the dialog follows:
lret = DlgInit(IDD_FWIN_DIALOG_DIALOG, gdlg) 1 if (lret == .FALSE.) goto 99999 lret = DlgSetSub(gdlg, IDD_FWIN_DIALOG_DIALOG, FWin_dialogSub) 2 lret = DlgSetSub(gdlg, IDM_APPLY, FWin_dialogApply) 3 lret = DlgModeless(gdlg, nCmdShow) 4 if (lret == .FALSE.) goto 99999
Notes for this example:
1DlgInit initializes the dialog box.
2 The first call to DlgSetSub assigns a callback subroutine to the Exit button. It associates the FWin_dialogSub subroutine with the dialog box identifier IDD_FWIN_DIALOG_DIALOG (project name is FWin_Dialog). The FWin_dialogSub routine contains code to terminate the program.
3 The second call to DlgSetSub associates FWin_dialogApply with the Apply button identifier IDM_APPLY. The user should add code in the FWin_dialogApply subroutine to take appropriate action.
4DlgModeless displays the initialized modeless dialog box, which is ready for user input.
The code specific to processing messages (message loop) to react to user input follows:
! Read and process messages do while( GetMessage (mesg, NULL, 0, 0) ) 1 if ( DlgIsDlgMessage(mesg) .EQV. .FALSE. ) then 2 lret = TranslateMessage( mesg ) 3 ret = DispatchMessage( mesg ) 4 end if end do
Notes for this example:
1 The GetMessage Windows API call inside a DO WHILE loop returns a message from the calling thread's message queue.
2DlgIsDlgMessage determines whether the specified message is intended for one of the currently displayed modeless dialog boxes, or a specific dialog box.
3 The TranslateMessage Windows API call translates virtual-key messages into character messages.
4 The DispatchMessage Windows API call dispatches a message to a window procedure.
The dialog box is terminated and its resources are released by calling DlgUninit:
call DlgUninit(gdlg)