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

How to implement noninteractive dialog?

Intel_C_Intel
Employee
454 Views
In CVF version 6.6A I would like to code a noninteractive modal dialog box to steadily print out an lengthening edit box (similar in function to a MS Visual Studio Output window when a Compile or Link operation is proceeding) and tracking the progress of a long calculation. I wouldn't need any input from the user other than perhaps their optional use of the vertical scroll bar; the window would exit automatically when the calculation is complete.
It seems that the DlgModal command would be waiting forever without any user interaction and there doesn't seem to be another way of launching a modal dialog box.
Can somebody please help me with the top level logic of implementing a noninteractive dialog.


0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
454 Views
See ThreadDlg sample.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
454 Views
Thanks Jugoslav. But I don't understand how to morph your loop:

DO i=1,100
   !Your number crunching here instead of SLEEPQQ
   CALL SLEEPQQ(200)
   WRITE(*,*) i
   IF (IsCancelSignalled(Dlg,i).EQ.1) THEN
      Worker=0
      RETURN
   END IF
END DO

to include my long-running subroutine instead of SLEEPQQ. Also, this is clearly an interactive dialog.
Can one make a dialog without the buttons, for example, showing only a progress bar and read-only scrollable edit box?

Harry Bell
0 Kudos
Jugoslav_Dujic
Valued Contributor II
454 Views
The sample explains the principle; you could easily adapt it by removing IDC_BUTTON_RUN and IDCANCEL, removing references to IDC_BUTTON_RUN from the code, and putting thread start to dlg-initialization callback, i.e:

iDummy=DlgSetSub(Dlg, IDD_DIALOG1, OnRun)

You can also remove Stop functionality if you wish. Of course, you can replace progress bar with a text control or read-only edit-box as well. The gotcha with progress bars is that you must know in advance how many iterations will be there.

Your long-running subroutine probably does not consist of linear-flow code; it must have some DO-loops. Putting IsCancelSignalled in these loop should be OK. If your code can be logically divided into "steps", you might put DlgSet(IDC_EDIT...) calls between these "steps", e.g.

Step 1/7: Loading data...
Step 2/7: Preparing data...
...
Step 7/7: Creating output list...

The point of the sample was that you have to create a thread if you want that the UI is updated at all. If there were no thread, the text as above (or filled progress bar) would appear only after the calculation ends.

Jugoslav
0 Kudos
Reply