Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

dlgmodal vs. dlgmodeless

hargy
Beginner
586 Views

Can someone tell me what is happening here? I have a dialog
that the user must make an initial selection. Depending on
various status's after this there can be other dialogs that
display for a response. After these are finished, I want to
re-display the initial dialog because there are 2 progress
bars to show the level of completion. Everything runs fine
until stmt 700. If I use a modal dialog at this point, the
program waits for a response when there is none. I have tried
this avenue and after makeing a selection to satisfy the dialog,
the box is gone. When I change to modeless, (with or without
the mesg loop) the dialog displays, but none of the buttons
title, or images are displayed. Also, if you check the taskbar
the executable is still in memory after program completes when
using the mesg loop..
Also, when useing modeless the final dlgexit fails with a memory
exception. At his point, I am not sure what to try.
Thanks in advance, I would really appreciate some help.

1ret_val = DLGINIT(IDD_DMAIN, dlgm)
ret_val = DLGSETCHAR(dlgm, IDC_MSGBOX, err_msg)
ret_val = DLGSETCHAR(dlgm, IDC_VERS, vers_num)
ret_val = DLGSETCHAR(dlgm, IDC_RNAME, user_name)
ret_val = DLGSET(dlgm, IDC_PROGRESS1, 0, DLG_RANGEMIN)
ret_val = DLGSET(dlgm, IDC_PROGRESS1, 100, DLG_RANGEMAX)
ret_val = DLGSET(dlgm, IDC_PROGRESS2, 0, DLG_RANGEMIN)
ret_val = DLGSET(dlgm, IDC_PROGRESS2, 100, DLG_RANGEMAX)
mdlg_ret = dlgmodal(dlgm)
err_msg = char(0)
call DLGUNINIT (dlgm)
call dlgexit(dlgm)

if (mdlg_ret .eq. 2) go to 2000

if (mdlg_ret .eq. 1023 ) then
call about
go to 1
endif

:
:

2 status = GetOpenFileName(ofn)
if (status .eq. 0) then
go to 1
else
ilen = INDEX(file_spec,CHAR(0))
end if

:
:

550 OPEN(UNIT=550, FILE=out_file_spec(1:olen), access='direct', status='new', &
FORM='UNFORMATTED', recl=256, IOSTAT=ierr)
if (ierr .eq. 10) then
write(msg_out,'("File ",a," already exists. Overwrite?")')out_file_spec(1:olen-1)
ret_val = DLGINIT(IDD_YESNO, dlgs)
ret_val = DLGSETCHAR(dlgs, IDC_MSG, msg_out)
dlg_ret = dlgmodal(dlgs)
CALL DLGUNINIT (dlgs)
call dlgexit(dlgs)
if (dlg_ret .eq. 2) then
go to 2000
endif
e ndif

:
:

! Put back the main dialog
700 ret_val = DLGINIT(IDD_DMAIN, dlgm)
ret_val = DLGSETCHAR(dlgm, IDC_MSGBOX, err_msg)
ret_val = DLGSETCHAR(dlgm, IDC_VERS, vers_num)
ret_val = DLGSETCHAR(dlgm, IDC_RNAME, user_name)
ret_val = DLGSET(dlgm, IDC_PROGRESS1, 0, DLG_RANGEMIN)
ret_val = DLGSET(dlgm, IDC_PROGRESS1, 100, DLG_RANGEMAX)
ret_val = DLGSET(dlgm, IDC_PROGRESS2, 0, DLG_RANGEMIN)
ret_val = DLGSET(dlgm, IDC_PROGRESS2, 100, DLG_RANGEMAX)
ret_val = DLGMODELESS(dlgm)

! Read and process messages until GetMessage returns 0 because
! PostQuitMessage has been called
do while( GetMessage (mesg, NULL, 0, 0) )
if ( DlgIsDlgMessage(mesg) .EQV. .FALSE. ) then
lret = TranslateMessage( mesg )
ret = DispatchMessage( mesg )
endif
enddo

:
:

m2 = (search_len+save_knt)*mark_val
ret_val = DLGSET (dlgm, IDC_PROGRESS1, m2, DLG_POSITION)

:
:

call DLGUNINIT (dlgm)
call dlgexit(dlgm)

0 Kudos
2 Replies
anthonyrichards
New Contributor III
586 Views

Why don't you just add a button (IDC_OPENFILE) to your main dialog and add a call-back routine to it to use your GetOpenFile code? You can also create a simple Modal dialog to ask YES'/NO/ CANCEL by just adding a call to the MessageBox function, where you can display a message with 'OK', 'CANCEL', 'ABORT' and other buttons, without having to go to the trouble of creating your own dialog to do it. For example

use user32lib
integer myflags, iret

myflags=IOR(MB_YESNOCANCEL,MB_ICONWARNING )
myflags=IOR(myflags,MB_DEFBUTTON1) ! specifies which button is the default
myflags=IOR(myflags,MB_APPLMODAL) ! forces a reply before allowing hWnd window to continue

iret=MessageBox(hWnd,'Your message here'C,'Your message box title here'C, myflags )

Note that the strings must be 'null' terminated C-strings. hWnd can be NULL. For full details, see the Help for MessageBox.

0 Kudos
hargy
Beginner
586 Views

Anthony,Thanks for the ideas. I will look at it and see how it goes. The problem is, in the sections that are not printed because the program is quite lengthy, is the possibility of more dialogs. It seems that if you open a new dialog the other is closed. And the only reason I would like to keep the main dialog is for consistency and to show the progress. I have the program working on a quickwin environment, but I wanted to see if I could convert it to a dialog environment.

Again thanks

Hargy

0 Kudos
Reply