Win32Lib: setVisible (true) problem ?
- Posted by Dan Moyer <DanMoyer at PRODIGY.NET> Nov 02, 1999
- 481 views
David, I think the problem I've been having with playSound "interfering" with setVisible (true) isn't actually a playSound problem, but rather a problem with setVisible. setVisible (true) apparently doesn't finish up as one would expect & other commands after it can execute before it's finished, delaying it. I made a demo in which a button click sets one label invisible, another visible, and THEN does a time delay, and while the first label does go invisible on click, the other one doesn't become visible until AFTER the time delay, even though the setVisible (true) is before the time delay. Dan Moyer Here's the demo: -- demo of problem with setVisible True not happening when it should; -- a time delay *AFTER* setVisible true demonstrates the problem, -- but other things, like "playsound" also invoke this same problem. include Win32Lib.ew without warning global constant TheWindow = create( Window, "setVisible True Problem", 0, 100, 100, 450, 300,0), CText2 = create( CText, "CText2", TheWindow, 40, 10, 400, 76, 0 ), CText1 = create( CText, "CText1", TheWindow, 120, 10, 240, 60, 0 ), DoTest = create( PushButton, "CLICK HERE", TheWindow, 148, 92, 132, 40, 0 ), Restart = create( PushButton, "RESTART", TheWindow, 148, 164, 132, 36, 0 ) --------------------------------------- procedure TheWindow_onOpen () -- TEXT TO MAKE INVISIBLE WHEN BUTTON CLICKED; MAKE IT VISIBLE FOR NOW: setText(CText1,"This text should DISAPPEAR on click, then new text should reappear RIGHT AWAY.") setVisible(CText1,True) --TEXT TO *SHOW* WHEN BUTTON CLICKED ; MAKE IT INVISIBLE FOR NOW: setFont(CText2,"Arial", 15,Bold) setText(CText2,"This text should have shown WITHOUT DELAY!") setVisible(CText2,False) end procedure onOpen[TheWindow] = routine_id("TheWindow_onOpen") ----------------------------------- procedure aShortTimeDelay() object w w = time()+1 while time() < w do end while end procedure ----------------------------------- --DO THE TEST: procedure DoTest_onClick () setVisible(CText1,False)-- visible test text should first disappear, setVisible(CText2,True)-- then invisible text SHOULD become VISIBLE; aShortTimeDelay() -- WITHOUT this time delay, second text displays -- right after first text disappears, as it should; -- WITH it, the second text DOES NOT APPEAR until -- AFTER the time delay, even though the time delay -- happens AFTER THE SET VISIBLE (true) COMMAND. end procedure onClick[DoTest] = routine_id("DoTest_onClick") ------------------------------------ -- RESET TO DO TEST AGAIN: procedure Restart_onClick () setVisible(CText2,False) setVisible(CText1,True) end procedure onClick[Restart] = routine_id("Restart_onClick") ---------------------------------------------------------------------- WinMain( TheWindow, Normal )