To display a modeless dialog box, call the DLGMODELESS function. A modeless dialog box remains displayed until the DLGEXIT 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 DLGISDLGMESSAGE function at the beginning of the message loop.
The variable of type DIALOG passed to DLGMODELESS must remain in memory for the duration of the dialog box (from the DLGINIT call through the DLGUNINIT 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 DLGMODELESS.
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. For example, see
the Visual Fortran sample ...\Df98\Samples\Dialog\Dllprgrs
.
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*4 function WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'WinMain' :: WinMain
!DEC$ ENDIF
use dfwin
use dflogm
integer(4) hInstance
integer(4) hPrevInstance
integer(4) lpszCmdLine
integer(4) 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(4) ret
logical(4) 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