Indy500 Posted October 26, 2009 Share Posted October 26, 2009 Here's my code in a Quick Sequence in a Button: private string result = System.MessageBox("Clean the probe and put it in the 4.01 pH solution and click OK. The calibration will take 60 seconds.", "OKCancel") if (result == "OK") delay(60) PH401Voltage3 = mean(PhVoltage3[0,599]) Registry.PH401Voltage3 = PH401Voltage3 System.MessageBox("The probe is now calibrated at 4.01 ph", "OKCancel") endif It works OK, but I've got two questions: 1. The first MessageBox stays on the screen for 60 seconds after I click "OK". I thought it would go away as soon as it returned the result from clicking "OK" or "Cancel". How do I do that? 2. What I would really love to happen is that the user clicks "OK" on the first MessageBox and then some other message pops up with a sixty second countdown, and then it would go away and the final MessageBox would display. Any ideas on how to do that? Thanks for all your help! Link to comment Share on other sites More sharing options...
AzeoTech Posted October 27, 2009 Share Posted October 27, 2009 OK, what you are seeing here is why you can't put delay() in component events. The component On click event runs in the main application thread, which is the same one that draws the screen, so, when the dialog is dismissed, the code quickly gets to the delay(), but doesn't give the thread the ability to actually redraw the window without the message box. Bottom line is that you can't put delay() in Quick Sequences. That said, I would put the delay() in a sequence, started by beginseq(). Actually all the code inside the if() should be in a sequence, except the system.messagebox() which can't run in a secondary thread. To do a countdown, you'll need to create a page that you popup modally, and then have it update with the countdown and the final message. Its actually not very difficult to do. You just need a global variable and an extra page, then the sequence might look something like: page.mybutton.visible = 0 page.mypage.popupmodal() private st = systime() while(systime() < st+60) page.mytextcomponent.text = "You have " + doubletostr(60 - (systime() - st)) " seconds remaining" delay(1) endwhile page.mytextcomponent.text = "Compelte!" page.mybutton.visible = 1 I think its .text, it might be .caption. MyTextComponent is a static text control with that name. MyButton is a button control with a page.mypage.closepopup() action that we make invisible until the 60 seconds are up. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.