RE: Win32lib cascading windows
- Posted by Derek Parnell <ddparnell at bigpond.com> Apr 09, 2001
- 668 views
Hi Kenneth, you found a bug with using Modal windows. I'll track it down later but for now you can do this instead. Use the openDialog( win) function instead of openWindow(win, Modal) and remove onClose[] trapping, instead just call the close routine directly. eg... WAS procedure onCloseMyWin() . . . end procedure onClose[mymin] = routine_id("onCloseMyWin") . . . openWindow(mywin, Modal) SHOULD BE procedure onCloseMyWin() . . . end procedure . . . openDialog(mywin) onCloseMyWin() The main difference between openDialog() and openWindow(...,Modal) is that the next line after the openDialog() is not executed until the window is closed, whereas with openWindow() the next line is executed immediately after the window is opened. Here is your sample program with these amendments... ------------------- include file.e include misc.e include Win32Lib.ew without warning sequence userName constant scoreWin = create(Window,"Standings",0,Default,Default,350,320,0 ), scoreOKButton = create( DefPushButton, "OK", scoreWin, 160, 250, 60, 32, 0 ) procedure closeScoreWin() integer result result = message_box( "Ready to close scoreWin", "finishScoreWin!", 0 ) end procedure --onClose[ scoreWin ] = routine_id("closeScoreWin") procedure onClick_ScoreOKButton() closeWindow(scoreWin) end procedure onClick[ scoreOKButton ] = routine_id( "onClick_ScoreOKButton" ) procedure scorePaint( integer x1, integer y1, integer x2, integer y2 ) sequence printSol, sortSols integer madeTop10 madeTop10 = 1 if madeTop10 = 0 then setPosition( scoreWin, 50, 210 ) wPuts( scoreWin, printSol ) end if end procedure onPaint[scoreWin] = routine_id( "scorePaint" ) procedure writeSol() -- openWindow( scoreWin, Modal ) openDialog(scoreWin) closeScoreWin() end procedure constant PromptWin = create( Window,"Enter your name",0,Default,Default,260,120,0), NameLbl = create( LText, "Please enter your name", PromptWin, 10, 10, 120, 30, 0 ), NameFld = create( EditText, "", PromptWin, 10, 45, 120, 20, 0 ), OKButton = create( DefPushButton, "OK", PromptWin, 180, 40, 30, 30, 0 ) procedure finishGameWon() atom result result = message_box( "Ready to close PromptWin", "finishGameWon!", 0 ) writeSol() --nextPuzzle() end procedure procedure displayUserName( integer x1, integer y1, integer x2, integer y2 ) sequence tmpName tmpName = "JoKeR" setText(NameFld, tmpName) end procedure procedure onClick_OKButton() userName = getText( NameFld ) closeWindow(PromptWin) end procedure onClick[ OKButton ] = routine_id("onClick_OKButton") onPaint[ PromptWin ] = routine_id("displayUserName") --onClose[ PromptWin ] = routine_id("finishGameWon") constant ButtonWindow = create( Window, "Button Example", 0, Default, Default, 100, 100, 0 ) -- create a control in the window constant OkButton = create( PushButton, "&Button", ButtonWindow, 10, 10, 80, 40, 0 ) -- add a tooltip to the button setHint( OkButton, "This button invokes name prompting." ) procedure doPrompt() -- openWindow(PromptWin, Modal) openDialog(PromptWin) finishGameWon() end procedure onClick[ OkButton ] = routine_id("doPrompt") -- hand control over to Windows WinMain( ButtonWindow, Normal ) ------------------- ----------- cheers, Derek Parnell Senior Design Engineer Global Technology Australasia Ltd dparnell at glotec.com.au ---------------------