RE: return value from dialog window
- Posted by "Horvath Stefan" <horvath at acasa.ro> Feb 04, 2005
- 490 views
it works fine, here's the code. Thank you ck. But I think to make without global variable, if it is possible. > " But I bet there's an easier way. ;) ". (ck) I must find that way. Steve.
without warning include win32lib.ew sequence dlgResult, result dlgResult = "" constant WIN = createEx( Window, "YesNo Dialog", 0, Default, Default, 400, 220, 0, 0 ) constant YesB = createEx( PushButton, "Click here", WIN, 40, 48, 100, 24, 0, 0 ) constant SB = createEx (StatusBar, "", WIN, 0, 0, 0, 0, 0, 0 ) constant win_Main = createEx( Window, "YesNo Dialog", WIN, Default, Default, 192, 120, 0, 0 ) constant LText2 = createEx( LText, "What's your answer?", win_Main, 40, 16, 160, 20, 0, 0 ) constant bttn_Yes = createEx( PushButton, "Yes", win_Main, 40, 48, 52, 24, 0, 0 ) constant bttn_No = createEx( PushButton, "No", win_Main, 100, 48, 52, 24, 0, 0 ) procedure onClick_buttons(integer self, integer event, sequence params) if self = bttn_Yes then dlgResult = "Yes" setText(SB, dlgResult) else dlgResult = "No" setText(SB, dlgResult) end if closeWindow(win_Main) end procedure setHandler({bttn_Yes, bttn_No}, w32HClick, routine_id("onClick_buttons")) function runDialog( ) openDialog(win_Main) return dlgResult end function procedure onClick_YesB(integer self, integer event, sequence params) result = runDialog() setText(SB, dlgResult) end procedure setHandler(YesB, w32HClick, routine_id("onClick_YesB")) WinMain(WIN, Normal)
-----Original Message----- From: cklester [mailto:guest at RapidEuphoria.com] Sent: Friday, February 04, 2005 9:12 PM To: EUforum at topica.com Subject: Re: return value from dialog window posted by: cklester <cklester at yahoo.com> Horvath Stefan wrote: > > Hi all, > It is possibly to have a Dialog which return a value (integer, exemple) in > correspondence with PushButtons clicked in Window. You could create a function which wraps a openWindow() call like this: sequence dlgResult -- build an input dialog constant win_Main = createEx( Window, "YesNo Dialog", 0, Default, Default, 192, 120, 0, 0 ) constant LText2 = createEx( LText, "What's your answer?", win_Main, 40, 16, 116, 20, 0, 0 ) constant bttn_Yes = createEx( PushButton, "Yes", win_Main, 40, 48, 52, 24, 0, 0 ) constant bttn_No = createEx( PushButton, "No", win_Main, 100, 48, 52, 24, 0, 0 ) -- create functions to set variable result -- i.e., for bttn_Yes_OnClick, setResult="Yes" -- i.e., for bttn_No_OnClick, setResult="No" function runDialog( sequence win ) openWindow(win,Normal) return dlgResult end function Then result = runDialog( win_input ) But I bet there's an easier way. ;) -=ck "Programming in a state of EUPHORIA." http://www.cklester.com/euphoria/ Disclaimer: It is possible that the Trend Micro VirusWall product may not be able to detect all new viruses and variants. Please be aware that there is a risk involved whenever opening e-mail attachments to your computer and that MobiFon is not responsible for any damages caused by your decision to do so.