Clarification on BoxUpdates Function
Keywords: boxupdates
Question:
I stripped my 48k program down to 4k, so it may look a little strange. When you run the program, click on the Sort button. This brings up the Sort box (and since the code is gone, immediately destroys it). The next time you click on the Sort button, BoxUpdates for the main box is set to 2, and the Sort and exit buttons will not display. (Unless you bring another window in front, resize the window, drag it off the screen then back, etc.)The code's somewhat messy but even so it demonstrates an apparent update problem.
;Check the SortJobs routine for the BoxUpdates(1,?) line. ; Try clicking on the Sort Jobs button with the ? set to 1 and set to 2 (or 3). ; Automated it to cycle between 1,1, (1,2), and (1,3) every time you click Sort errormode(@notify) :Startup Gosub InitVars Gosub LoadBox Gosub MakeSortedList Gosub UpdateBox :MainLoop While @True Gosub CheckButtons if UpdateBoxes Gosub UpdateBox UpdateBoxes = @False endif endwhile exit ;******* :LoadBox ;******* MaxButtons = 2 x1 = 50 x2 = 740 y1 = 50 y2 = 740 BoxesUp("%x1%,%y1%, %x2%, %y2%", @normal) BoxCaption(1, "%ThisProgName% - loading") xdiff = x2 - x1 ydiff = y2 - y1 tag1 = "TAG1" for loop = 1 to MaxButtons bd%loop%=loop next loop Gosub ResetBoxes Return ;************ :CheckButtons ;************ ;Only 1 button can be pushed at any one time bpushed = 0 for loop = 1 to MaxButtons If BoxButtonStat(1,loop) Then bpushed = loop next loop Select bpushed case 0 ;No button pushed break case bd1 ;Sort - open sort box... Gosub SortJobs break case MaxButtons ;Exit query = AskYesNo("Exiting...", "Are you sure you want to quit?") if query == @Yes exit endif break endSelect Return ;**************** :CheckSortButtons ;**************** Gosub MakeSortedList Return ;************** :MakeSortedList ;************** sortedList = "" UpdateBoxes = @True Return ;******** :InitVars ;******** ThisProgName = "Box Bugs" SortedList = "" UpdateBoxes = @True UpdateBug = 1 Return ;********* :UpdateBox ;********* BoxCaption(1, ThisProgName) BoxDataClear(3, tag1) BoxDataTag(3, tag1) BoxUpdates(3,0) ;Delay drawing until end BoxUpdates(3,2) Return ;******** :SortJobs ;******** BoxNew(2, "10,10,1000,1000", 2) ;*************** ;Confirmed bug ; Boxes don't open in front the way they are supposed to do, if you use them as I ; have been. ;*************** ;Trying open box 3 to display box 2. just might work. Does, mostly ; must kill the buttons on box 1 ; must redraw box 1 and 3, reset their text settings, when I'm done with box "2" BoxNew(3, "10,55,950,600", 1) BoxDataTag(3, tag1) BoxUpdates(1, 0) for a = 1 to MaxButtons BoxButtonKill(1, a) next a ;*************************** following line shows apparent box bug #2. ;If updates is set to 2 or 3, update doesn't take place until screen is covered by ; a separate window. (shows up when window moved off screen, or is resized also) BoxUpdates(1, updateBug) if UpdateBug == 1 Display(2, "Sort and Exit button should come back normally", "") UpdateBug = 2 else if UpdateBug == 2 Display(2, "Update set to 2", "Sort and Exit button don't come back until windows tells winbatch to redraw") UpdateBug = 3 else Display(2, "Update set to 3", "Sort and Exit button don't come back until windows tells winbatch to redraw") UpdateBug = 1 endif endif ;*************** BoxUpdates(2,0) BoxCaption(2, "Sort jobs by...") BoxUpdates(2,1) BoxDestroy(2) Gosub ResetBoxes ;to get around a bug in WinBatch Return ;********** :ResetBoxes ;********** BoxNew(3, "7,55,993,600", 1) Black = "0,0,0" White = "255,255,255" BoxColor(1, White, 1) BoxPen(1, Black, 2) BoxDrawRect(1, "0,0, 1000,1000", 1) bx1 = 55 bx2 = 135 by1 = 10 by2 = 50 BoxTextColor(1, White) BoxButtonDraw(1, bd1, "Sort Jobs...", "300,680, 550,730") BoxButtonDraw(1, bd%MaxButtons%, "Exit", "800,890, 950,990") BoxDataTag(3, tag1) ReturnAnswer:
I added message boxes just below all your BoxUpdates and wrote down the results.
- BoxUpdates 0 and 1 are "states" (enabler drawing/disable drawing) whileas 2 and 3 are "commands" (do something NOW).
- Box 1, which has the buttons in it, had the update state still disabled, even though you requested a redraw (2), i think it was before the buttons get activated.
- Set all the BoxUpdate states back to 1 before you expect good results.
- That means, for BoxUpdates, you would have to use 2 or 3 each time you drew something new to a box if you wanted that type of drawing.
Article ID: W12758Filename: Clarification on BoxUpdates Function.txt