Reference Manual

  • 15.0
  • 07/23/2021
  • Public Content

Using a Modeless Dialog Box

When an application displays a modeless dialog box, the application does not halt, waiting for user input, but continues executing. The user can freely switch between the modeless dialog box and the other windows in the application.
To display a modeless dialog box, call the
function. A modeless dialog box remains displayed until the
routine is called, either explicitly or by a default button callback. The application must provide a message loop to process Windows messages and must call the
function at the beginning of the message loop.
The variable of type
passed to
must remain in memory for the duration of the dialog box (from the
call through the
call). The variable can be declared as global data in a Fortran module, as a variable with the STATIC attribute (or statement), or in a calling procedure that is active for the duration on the dialog box. For more information, see the Syntax for
Modeless dialog boxes are typically used in a Fortran Windows project. A modeless dialog box can be used in a Fortran Console, Fortran DLL, or Fortran Static Library application as long as the requirements for using a modeless dialog box (discussed in the previous paragraphs) are met.
As an example of using a modeless dialog box, the following code is the WinMain function of an application that displays a modeless dialog box as its main window:
INTEGER(DWORD) function WinMain (hInstance, hPrevInstance, & & lpszCmdLine, nCmdShow) !DEC$ ATTRIBUTES STDCALL, DECORATE, ALIAS:”WinMain” :: WinMain use IFWIN use IFLOGM INTEGER(HANDLE), INTENT(IN) :: hInstance, hPrevInstance INTEGER(LPVOID), INTENT(IN) :: lpszCmdLine INTEGER(DWORD), INTENT(IN) :: nCmdShow ! Include the constants provided by the Resource Editor include 'resource.fd' ! A dialog box callback external ThermometerSub ! Variables type (dialog) dlg type (T_MSG) mesg integer ret logical lret ! Create the thermometer dialog box and set up the controls and callbacks lret = DlgInit(IDD_THERMOMETER, dlg_thermometer) lret = DlgSetSub(dlg_thermometer, IDD_THERMOMETER, ThermometerSub) lret = DlgSet(dlg_thermometer, IDC_PROGRESS1, 32, DLG_RANGEMIN) lret = DlgSet(dlg_thermometer, IDC_PROGRESS1, 212, DLG_RANGEMAX) lret = DlgSet(dlg_thermometer, IDC_PROGRESS1, 32) lret = DlgModeless(dlg_thermometer, nCmdShow) ! Read and process messages until GetMessage returns 0 because ! PostQuitMessage has been called do while( GetMessage (mesg, NULL, 0, 0) ) ! Note that DlgIsDlgMessage must be called in order to give ! the dialog box first chance at the message. if ( DlgIsDlgMessage(mesg) .EQV. .FALSE. ) then lret = TranslateMessage( mesg ) ret = DispatchMessage( mesg ) end if end do ! Cleanup dialog box memory call DlgUninit(dlg) ! The return value is the wParam of the Quit message WinMain = mesg.wParam return end function

Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at