;========================================================================================================================================== ; ; How to use WinBatch Box functions to display running status report? ; ; (c)Detlev Dalitz.20120719. ;========================================================================================================================================== DirChange (DirScript ()) hdlWinID = WinIdGet ("") WinPlace (300, 300, 700, 600, hdlWinID) strBoxTitle = "WinBatch Box" strBoxColorNormal = "248,248,248" strBoxColorWarning = "255,235,235" strBoxTextColor = "0,0,0" BoxOpen (strBoxTitle, "") BoxColor (1, strBoxColorNormal, 0) BoxTextColor (1, strBoxTextColor) BoxDataTag (1, "1") ; Create a tag entry in a WinBatch box command stack. intLoopMax = 2222 intCounter = 0 strDTStart = TimeYmdHms () For intLoop = 1 To intLoopMax ; For example ... do your work here. TimeDelay (0.02) If 0 == intLoop mod 10 ; For this example, display message only once per each 10th item. intCounter = intCounter + 1 ; For this example, set some other counter. strBoxText = "Box Test" strBoxText = strBoxText : @LF : @LF : "Loop = " : intLoop strBoxText = strBoxText : @LF : "Counter = " : intCounter BoxTitle (strBoxTitle : " - Status = " : Int (100.0 * intLoop / intLoopMax) : "%%") ; BoxTitle can be set dynamically too. If WinState (hdlWinID) != @ICON ; Do not display box when window minimized. If 0 == intCounter mod (1 + Random (111)) ; For this example, display warning message randomly. BoxTitle (strBoxTitle : " - Counter = " : intCounter : " *** Warning ***") BoxColor (1, strBoxColorWarning, 0) BoxText (strBoxText) TimeDelay (2) BoxColor (1, strBoxColorNormal, 0) BoxText (strBoxText) ; This BoxText after setting BoxColor is needed because otherwise possible bug shows wash color. Else ; Display normal status. BoxText (strBoxText) EndIf BoxDataClear (1, "1") ; Removes commands from a WinBatch box command stack. EndIf EndIf Next ; Status at end of loop. strBoxText = "Box Test" strBoxText = strBoxText : @LF : @LF : "Loop = " : intLoopMax strBoxText = strBoxText : @LF : "Counter = " : intCounter ; Prepare ready message. strDTStop = TimeYmdHms () strBoxText = strBoxText : @LF : @LF : "Start = " : strDTStart strBoxText = strBoxText : @LF : "Stop = " : strDTStop strBoxText = strBoxText : @LF : @LF : "Ready." ; Get window on top. WinShow (hdlWinID) ; Shows a window in its "normal" state. WindowOnTop (hdlWinID, 1) ; Keep window on top. ; Display ready message. BoxTitle (strBoxTitle : " - Completed") BoxColor (1, strBoxColorNormal, 0) ; For sure because of possible washcolor bug. BoxText (strBoxText) BoxButtonDraw (1, 1, "&OK", "50,780,950,950") While !BoxButtonStat (1, 1) TimeDelay (0.2) EndWhile BoxButtonKill (1, 1) BoxShut () :CANCEL Exit