Using Dialog as Progress Indicator

Started by LouInova, February 22, 2014, 01:29:33 PM

Previous topic - Next topic

LouInova

I've been trying out a couple of different methods to show a "please wait" type of display as part of an application launch that has to connect out over the network and takes a little while to show the UI.

In previous iterations, I had used some of the Box functions. Then, I ran across this example on the tech support site:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/Samples~from~Users+Progress~Bar~in~Dialog.txt

I would like to incorporate that code in my script. However, I haven't done a whole lot with dynamic dialogs and I'm not sure how to best fit in the actual app launch since once the dialog initializes and it hits the Switch line, it'll just loop until the dialog is closed.

Here is a snippet of what I had with boxes:

BoxesUp("25,65,255,335", @normal)
BoxTitle ("Launching The App")
BoxDrawText(1, "475,300,450,450", "Please wait. Connecting to server", @FALSE, 1)

runshell (Exec, Param, "", @NORMAL, @NOWAIT)

While @true
If !WinExist ("App")
TimeDelay(.5)
Else
BoxShut ()
Break
EndIf
EndWhile


Since the RunShell function tends to wait a little for the app even with the @nowait option, I had the box up before trying to actually launch the application. With using the dialog example above, I'm not sure how to get the dialog up, and then execute the RunShell without any sort of user interaction in between.

Thanks for viewing and hopefully pointing me in the right direction,
Lou


Deana

The key is to add your WinExist code to the Timer procedure and have it RETURN to exit the dialog. This procedure gets triggered every {n} milliseconds ( defined by the DialogProcOptions option 1 TIMER in the INIT prodcedure  ).  The code might look something like this

Code (winbatch) Select

#DefineSubRoutine DlgCallback(DlgName,DlgEvent,DlgCtrl,rsvd1,rsvd2)
;Jeremy Whilde's spiffy progress meter:
;It turns out that fading more toward the outsides doesn't take all that much morecode--I just had to have the time to lookat it for a bit.
   ;DialogprocOptions Constants
   MSG_INIT=0                                              ; The one-time initilization
   MSG_TIMER=1                                             ; Timer event
   DC_BACKGROUNDCOLOR = 11                                 ; Initalize background colour
   ;DialogControlSet / DialogControlGet Constants
   Switch DlgEvent
   Case MSG_INIT
      LOn   ="0|0|160"
      LMid1 ="30|30|160"
      LMid2 ="60|60|160"
      LMid3 ="90|90|160"
      LMid4 ="120|120|160"
      LEnd  ="150|150|160"
      LOff  ="192|192|192"
      DialogProcOptions (DlgName,MSG_TIMER,150)            ; Adjust timer to suit
      Light = 1
      Direction = 1
      Return (-1)
   Case MSG_TIMER
   
     ;Check if window is up then exit progressbar         ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      If WinExist ("App")then Return (1)                       ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      DialogControlSet (DlgName,Light+1,DC_BACKGROUNDCOLOR,LOff)          ;Off
      If Light == 11 Then Direction=(-1)                                  ;-1 for Side to Side -10 for Left to Right
      If Light == 1 Then Direction=1
      Light = Light + Direction
      Switch Light
         Case 1
         Case 11
            DialogControlSet(DlgName,Light+1,DC_BACKGROUNDCOLOR,LEnd)     ;Off
            Break
         Case 2
         Case 10
            DialogControlSet(DlgName,Light+1,DC_BACKGROUNDCOLOR,LMid4)    ;Dim
            Break
         Case 3
         Case 9
            DialogControlSet(DlgName,Light+1,DC_BACKGROUNDCOLOR,LMid3)    ;Brighter
            Break
         Case 4
         Case 8
            DialogControlSet(DlgName,Light+1,DC_BACKGROUNDCOLOR,LMid2)    ;Brighter still
            Break
         Case 5
         Case 7
            DialogControlSet(DlgName,Light+1,DC_BACKGROUNDCOLOR,LMid1)    ;Almost fully on
            Break
         Case 6
            DialogControlSet(DlgName,Light+1,DC_BACKGROUNDCOLOR,LOn)      ;On
            Break
         EndSwitch
      Return (-1)                                          ; Do default processing
   EndSwitch                                               ; DlgEvent
Return(-1)                                                 ; Do default processing
#EndSubRoutine                                             ; End of Dialog Callback

IntControl (49,1,0,0,0)
MyDialogFormat=`WWWDLGED,6.1`
MyDialogCaption=`Please Wait...`
MyDialogX=-01
MyDialogY=-01
MyDialogWidth=116
MyDialogHeight=040
MyDialogNumControls=013
MyDialogProcedure=`DlgCallback`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialog001=`021,007,068,010,STATICTEXT,DEFAULT,"Final Configuration",DEFAULT,9,512,"Microsoft Sans Serif|6144|70|34","0|0|0",DEFAULT`
MyDialog002=`023,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog003=`029,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog004=`035,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog005=`041,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog006=`047,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog007=`053,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog008=`059,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog009=`065,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog010=`071,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog011=`077,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog012=`083,021,004,006,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"192|192|192"`
MyDialog013=`021,015,068,016,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,13,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ButtonPushed=Dialog("MyDialog")

Pause('Notice','App is loaded')
Exit


Deana F.
Technical Support
Wilson WindowWare Inc.

LouInova

Thanks for the reply, Deana.

In actuality though, I was looking more for how to best actually launch the app that it needs to wait on before exiting the dialog and making the launch fit in with displaying the progress bar.

I'm using ShellExecute to launch the application and I'm using the @nowait option. And even though it says "nowait", it actually kind of waits...the app launches before the script moves on to the next line. Therefore making the progress indicator a moot point.

In my earlier example that uses the Box functions, I was putting up the box and then I was using the While statement. Therefore, the "please wait" was up before the app launch. Initially, I couldn't find a good way to do that same thing with the Dialog function.

What I've ended up doing is setting up the dialog as a separate script and I'm running it before I use the ShellExecute function. Since the dialog is running in it's own space, and before the app launch, it just sits there until the WinExist () statement becomes true and then closes.

So, in actuality my question is...is that really the best way to do it or is there a better method I can use to "parallel process" the dialog and the app launch? Hopefully that makes sense.


Deana

I recommend calling the ShellExecute right before the Dialog() function.
Deana F.
Technical Support
Wilson WindowWare Inc.