Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra Dialog which does not require user response

Status
Not open for further replies.

cssun

Programmer
Feb 17, 2004
4
0
0
AU
How can I display a progress/info dialog or message window of some sort which is visible while a loop is processing in an EXTRA (VBA) macro ?
The loop iterates upto 22 times and I'd like a message window which will show what number iteration it's on while the loop is processing in background (ie. without a user needing to click a button at each iteration).
Something similar to the VB progress bar routine or a modeless window which could be invoked then destroyed by the script, would be great.
 
Let me know if this helps...

Add at the beginning of the macro
Code:
'$Include "progress.ebh"

Call this once you start the procedure
Code:
Progress = 0
Shell("ebrun progress_dlg.ebm", 1)

While
  Progress = Completed / Total * 100
  DoEvents
  ' do what ever
Wend

' Finished process, close dialog
Progress = 100

progress.ebh
Code:
Global Progress As Single

progress_dlg.ebm
Code:
'$Include "progress.ebh"

Function DlgProc(Control As String, Action As Integer, LValue As Long)
  If Action = 5 Then
    DlgProc = 1 ' Keep these messages coming
    DoEvents    ' Let Windows breath for a nanosecond (reduce processor usage)
    DlgText DlgControlId("LabelProgress"), Format(Progress, "0.00%")
    If Progress >= 100.0 Then
      ' Attempt to close by Tabbing to the ok button and hitting space
      AppActivate "EXTRA! Basic Dialog"
      SendKeys "{TAB} ", True
    End If              
  End If
End Function

Sub Main()
    Begin Dialog DialogProgress 186, 83, "EXTRA! Basic Dialog", .DlgProc
       OkButton  125, 60, 50, 15
       Text  10, 10, 165, 30, "0.0%", .LabelProgress       
    End Dialog
        
    Dim Dlg As DialogProgress
    Dialog Dlg
End Sub
 
Unfortunately the progess dialog is not returning processor control to the calling macro. Tried various approaches without success.

Can you please clarify ...
===============================================
I added '$Include "progress.ebh" at the top of my macro,
===============================================
Created the progress.ebh with the single entry of ...
Global Progress As Single
===============================================
Created the progress_dlg.ebm with ....
'$Include "progress.ebh"

Function DlgProc(Control As String, Action As Integer, LValue As Long)
If Action = 5 Then
DlgProc = 1 ' Keep these messages coming
DoEvents ' Let Windows breath for a nanosecond (reduce processor usage)
DlgText DlgControlId("LabelProgress"), Format(Progress, "0.00%")
If Progress >= 100.0 Then
' Attempt to close by Tabbing to the ok button and hitting space
AppActivate "EXTRA! Basic Dialog"
SendKeys "{TAB} ", True
End If
End If
End Function

Sub Main()
Begin Dialog DialogProgress 186, 83, "EXTRA! Basic Dialog", .DlgProc
OkButton 125, 60, 50, 15
Text 10, 10, 165, 30, "0.0%", .LabelProgress
End Dialog

Dim Dlg As DialogProgress
Dialog Dlg
End Sub
===============================================
My macro then looks like this ...
'$Include "progress.ebh"
' Global variable declarations
...
...
Sub main()
Code ...
Code ...
Code ...
Set oArea = Sess0.Screen.Search("RuleName")
iTitleLn = oArea.Top
' iTitleLn = 6

Set oArea = Sess0.Screen.Search("**END**")
iFootLn = oArea.Top
' iFootLn = 15

iLine = iTitleLn + 1
Total = iFootLn - iTitleLn - 1
Completed = 1
Progress = 0
call Shell("ebrun progress_dlg.ebm", 1)
While left(msg,6) <> "**END*"
If left(msg,6) = "1=HELP" Then
Sess0.Screen.Sendkeys("<Pf8>") 'Pg Fwd
iLine = iTitleLn - 1 'Reset iLine
Completed = 1 'Reset bar
End If
Progress = Completed / Total * 100
DoEvents
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Msg = Sess0.Screen.Select(iLine,4,iLine,79)
msgbox "Line#=" & iLine & " and Line=" & Msg
iLine = iLine + 1
Completed = iLine
Wend' Finished process, close dialog
Progress = 100



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top