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

trouble with making a "progress-type" dialogue window

robberman
Beginner
541 Views
I am having trouble making a dialogue window (see below) that shows the progress of a lengthy
calculation with two messages that are set at various places in the main "workhorse"
program. The messages only show after the calculation is completed and the next dialogue window
is opened. The messages will show if I call for user input each time the dialogue is called, but not
if I disable user input as in the routine below. Does anyone know how to fix this, or better yet, have
some code that I can "borrow" for a working progress bar? Thanks a lot??

SUBROUTINE wincalctit()
use user32
use kernel32
use dflogm
use wintwqGlobals

implicit none

external wintwqSub
external wintwqExit

include 'resource.fd'

logical*4 lret
logical*4 ret
type (t_msg) mesg

! lret = dlgsetsub(gdlg(11), IDC_EXIT, wintwqExit)
! lret = DlgSetSub(gdlg(11), IDD_CALCTIT, wintwqSub)

lret = dlgset(gdlg(11), IDC_message1, message1)
lret = dlgset(gdlg(11), IDC_message2, message2)

lret = dlgmodeless(gdlg(11), SW_SHOWNORMAL)

! Read and process messsages
! do while( GetMessage (mesg, NULL, 0, 0) )
! if ( DlgIsDlgMessage(mesg) .EQV. .FALSE. ) then
! lret = TranslateMessage( mesg )
! ret = DispatchMessage( mesg )
! end if
! end do

END SUBROUTINE wincalctit
0 Kudos
8 Replies
Jugoslav_Dujic
Valued Contributor II
541 Views
See attachment.

HTH
Jugoslav
0 Kudos
Intel_C_Intel
Employee
541 Views
Here is some lines of progress bar code that one can
embed within a subroutine. IDC_PROGRESS2 is the name of the progress control ID; change to agree with what is in the properties selection from the resources screen on MS Developer Studio.
Be sure to pass dlg as one of the arguments or it can be
a global variable.
subroutine mysubroutine_with_progress_bar(dlg) 
type (dialog) dlg
integer ipercentdone
logical lret
...
do i = 1, 100
! put your code here
ipercentdone = i
lret = DlgSet(dlg, IDC_PROGRESS2, ipercentdone, DLG_POSITION)
call dlgflush (dlg)
end do
...

Harry
0 Kudos
robberman
Beginner
541 Views
Jugoslav,
Thanks alot for your help with this (and my other queries)! It looks like what
you're suggesting should work, but I haven't had time to try it yet. Thanks again.
....Rob
0 Kudos
robberman
Beginner
541 Views
Thanks for your help, Harry. I tried your suggestion, but the progress window
doesn't get updated until after the calculation is finished. It may be that one
needs to implement a second thread to get this to work, as suggested in the
other reply to my query by Juroslav. If you have an idea of how to get it to
work along the lines you suggested, please let me know. Thanks again.....Rob
0 Kudos
Jugoslav_Dujic
Valued Contributor II
541 Views
One of my co-workers had the same problem few days ago (it was Delphi, but underlying Windows is still Windows). The caveat was that he had to have the lengthy operation in the same thread as GUI; we coped with it briefly while and I gave up (the progress bar was updated only at the very end). I see it is solved now -- I'll ask him how he did it tomorrow (if I don't forget :-)).

Jugoslav
0 Kudos
tomballard
Beginner
541 Views
I had this same problem when I first started working with progress bars. I even went so far as to write my own progress bar functions. I finally got it to work when I put it in another thread. There may have been another solution such as calling SendMessage versus PostMessage - one adds the message to the queue and the other executes it immediately.
0 Kudos
hbell
Beginner
541 Views
Is it possible you are placing your time-consuming module (the one that needs to be tracked with a progress bar) in the wrong place in order for it to work right? I put the previously mentioned fragment inside a subroutine that is in turn called from within a callback function. That is, I have something like:
lret = DLGINIT(MY_DIALOGWINDOW,dlg)
lret = DlgSet(dlg, IDC_PROGRESSBAR, .TRUE., DLG_ENABLE)
lret = DlgSet(dlg, IDC_PROGRESSBAR, 0 , DLG_RANGEMIN)
lret = DlgSet(dlg, IDC_PROGRESSBAR, 100 , DLG_RANGEMAX)
lret = DlgSet(dlg, IDC_PROGRESSBAR, 0 , DLG_POSITION )
lret = DlgSetSub(dlg,IDM_APPLY, MY_CALLBACK_FUNCTION)
iret = DLGMODAL(dlg)
...
subroutine MY_CALLBACK_FUNCTION(dlg, id, callbacktype)
...
call timeconsuming_subroutine(dlg,...)
...
end subroutine

where the subroutine, timeconsuming_subroutine, contains the code I sent earlier in this thread (above). Note that timeconsuming_subroutine needs to receive the dialog identifier (dlg in this example) as an argument or by some other mechanism.

Harry Bell
0 Kudos
Intel_C_Intel
Employee
541 Views
hi Rob,
if you manage to do it within a dialog application.could you send me the code or explain me how you did.thank you.
0 Kudos
Reply