1. RE: return value from dialog window
- Posted by "Horvath Stefan" <horvath at acasa.ro> Feb 04, 2005
- 491 views
- Last edited Feb 05, 2005
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.
2. RE: return value from dialog window
- Posted by Brian Broker <bkb at cnw.com> Feb 04, 2005
- 484 views
- Last edited Feb 05, 2005
Horvath Stefan wrote: > > > 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. I must be misunderstanding your request but what's wrong with using message_box() instead of a custom dialog? For example:
include win32lib.ew without warning ------------------------------ constant Win = create( Window, "YesNo Dialog", 0, Default, Default, 300, 220, 0 ), DlgB = create( PushButton, "Click here", Win, 40, 48, 100, 24, 0 ), SB = create(StatusBar, "", Win, 0, 0, 0, 0, 0 ) ------------------------------ procedure onClick_DlgB(integer self, integer event, sequence params) integer response response = message_box( "What's your answer?", "YesNo Dialog", MB_YESNO ) if response = IDYES then setText( SB, "Yes" ) else -- response = IDNO setText( SB, "No" ) end if end procedure setHandler(DlgB, w32HClick, routine_id("onClick_DlgB")) ------------------------------ WinMain(Win, Normal) ------------------------------
-- Brian
3. RE: return value from dialog window
- Posted by cklester <cklester at yahoo.com> Feb 04, 2005
- 456 views
- Last edited Feb 05, 2005
Brian Broker wrote: > Horvath Stefan wrote: > > it works fine, here's the code. Thank you ck. > > But I think to make without global variable, if it is possible. > > I must be misunderstanding your request but what's wrong with using > message_box() instead of a custom dialog? I think he didn't want to be confined to just "Yes" and "No" responses. With this method, you could also return the state of checkboxes, etc... x = runDialog( myDialog ) -- x now might equal {"Yes","No","Maybe",3,0} -=ck "Programming in a state of EUPHORIA." http://www.cklester.com/euphoria/
4. RE: return value from dialog window
- Posted by "Horvath Stefan" <horvath at acasa.ro> Feb 05, 2005
- 457 views
1. I must look at input_box(). Maybe it is what I want. 2. Yes, I need a response not from message_box, but from other window. Dialog result will be "context sensitive" (ineger, sequence, etc). But... 3. Also if I use english version of Windows98, it doesn't have an romanian language pack (interface). If I call message_box, buttons caption is in english. I intend to write an international message_box that will be able to load Buttons caption from some "resource file", not only in romanian, but also in other languages (slovakian, ungarian, german, etc). It is possible in Euphoria ? (I think in C++ I must create (register) a new class, declaring procedure for window, etc..) Thanks all. -----Original Message----- From: Greg Haberek [mailto:ghaberek at gmail.com] Sent: Saturday, February 05, 2005 12:53 AM To: EUforum at topica.com Subject: Re: return value from dialog window Have a look at my "input_box()" routine in the Archive. It creates a custom dialog and returns a result from a Window. It also saves on resources, because it does not create the dialog window unless it is necessary. And it returns different values based on user input, that is "" (empty sequence) on Cancel or whatever the user typed on OK (could be ""). Have fun, ~Greg On Fri, 4 Feb 2005 21:00:27 +0200, Horvath Stefan <horvath at acasa.ro> wrote: > > Hi all, > It is possibly to have a Dialog which return a value (integer, exemple) in > correspondence with PushButtons clicked in Window. > I think someting like " result = message_box(..) ". I am not too familiar > with Windows programming, but I learn ... > I think that isn't possible with returnValue from win32lib ?! > All sugestions are welcome. Thanks. > Steve > >