1. Windows programming question
- Posted by Ted Fines <fines at macalester.edu> Sep 19, 2003
- 375 views
Hi all, I am not understanding how the order of events really works. I'm using Judith's IDE, and Win32lib--both the newest versions. Here is a procedure for a button: procedure btnOK_onClick sequence themsg themsg = "Now about to run other procedure.\n" setText(InfoWindow,themsg) sleep(10) process_requirement({InfoWindow,DLProgress}) end procedure But even with the sleep(10) in there (which I just added for troubleshooting this), the text in my InfoWindow (a ML Text box) doesn't get updated until AFTER the other procedure has completed. I am guessing there is some way to force a refresh of my InfoWindow before continuing the procedure. How? Similarly, the procedure that gets called downloads a file, then runs it with a "system" call. It shows the download progress while downloading the file, in a label box. What is displayed are bytes downloaded so far, and the percent of the total, like this: "12849 bytes (5%)" But again, the updating of the label box lags far behind. The program actually gets downloaded, runs, and only after I quit it does the progress indicator get refreshed to say 100%. In my initial testing of the download procedure, I just wrote everything to a command window with "puts" commands, and did not have this problem. Could someone fill me in on refreshing widget/window contents? Thanks, Ted
2. Re: Windows programming question
- Posted by Elliott Sales de Andrade <quantum_analyst at hotmail.com> Sep 19, 2003
- 383 views
This is because the sleep(10) stops any processing of Windows messages. You should call doEvents(0) to process event before the sleep(). Also, if you are doing some intensive work, then you should call doEvents(0) periodically for your label to update the percentage. >From: Ted Fines <fines at macalester.edu> >Subject: Windows programming question > > >Hi all, > >I am not understanding how the order of events really works. I'm using >Judith's IDE, and Win32lib--both the newest versions. > >Here is a procedure for a button: >procedure btnOK_onClick > sequence themsg > themsg = "Now about to run other procedure.\n" > setText(InfoWindow,themsg) > sleep(10) > process_requirement({InfoWindow,DLProgress}) >end procedure > >But even with the sleep(10) in there (which I just added for >troubleshooting this), the text in my InfoWindow (a ML Text box) doesn't >get updated until AFTER the other procedure has completed. > >I am guessing there is some way to force a refresh of my InfoWindow before >continuing the procedure. How? > >Similarly, the procedure that gets called downloads a file, then runs it >with a "system" call. It shows the download progress while downloading the >file, in a label box. What is displayed are bytes downloaded so far, and >the percent of the total, like this: >"12849 bytes (5%)" > >But again, the updating of the label box lags far behind. The program >actually gets downloaded, runs, and only after I quit it does the progress >indicator get refreshed to say 100%. In my initial testing of the download >procedure, I just wrote everything to a command window with "puts" >commands, and did not have this problem. > >Could someone fill me in on refreshing widget/window contents? > >Thanks, >Ted
3. Re: Windows programming question
- Posted by Derek Parnell <ddparnell at bigpond.com> Sep 20, 2003
- 380 views
----- Original Message ----- From: "Ted Fines" <fines at macalester.edu> To: "EUforum" <EUforum at topica.com> Subject: Windows programming question > > > Hi all, > > I am not understanding how the order of events really works. I'm using > Judith's IDE, and Win32lib--both the newest versions. > > Here is a procedure for a button: > procedure btnOK_onClick > sequence themsg > themsg = "Now about to run other procedure.\n" > setText(InfoWindow,themsg) > sleep(10) > process_requirement({InfoWindow,DLProgress}) > end procedure > > But even with the sleep(10) in there (which I just added for > troubleshooting this), the text in my InfoWindow (a ML Text box) doesn't > get updated until AFTER the other procedure has completed. > > I am guessing there is some way to force a refresh of my InfoWindow before > continuing the procedure. How? If the routine 'process_requirement' can take some time (say more than 1 second) then it would be a good idea to insert some 'doEvents(0)' into it. The way Windows words is that events that happen while YOUR code is running, is blocked until your code returns to Windows. To help alleviate this, the doEvents(0) call will temporarily give control back to Windows so it can process any events that might have happened - including repainting parts of your screen. > Similarly, the procedure that gets called downloads a file, then runs it > with a "system" call. It shows the download progress while downloading the > file, in a label box. What is displayed are bytes downloaded so far, and > the percent of the total, like this: > "12849 bytes (5%)" > > But again, the updating of the label box lags far behind. The program > actually gets downloaded, runs, and only after I quit it does the progress > indicator get refreshed to say 100%. In my initial testing of the download > procedure, I just wrote everything to a command window with "puts" > commands, and did not have this problem. > > Could someone fill me in on refreshing widget/window contents? Yes, definitely run a doEvents(0) call after each time you update the progress display. -- Derek