Re: inputbox
- Posted by Matthew Lewis <MatthewL at KAPCOUSA.COM> Jul 26, 2000
- 421 views
-----Original Message----- From: =A9koda >how do i make inputbox function with Win32Lib? >object text >text=3Dinputbox() >it will return text when user presses ok, or 0 if user presses cancel button. There's no real way to do this (yet). The proper way to do it would be = to use a dialog box (CreateDialog, etc--see msgbox.e), which isn't wrapped = into win32lib yet. I came up with a hack a while back, which allows you to = run extra event loops within the main loop. Then you can create a separate window with your input box. Include the code below, and use a function to 'wrap' the input box = function. The pseudocode for the input box would look something like this: function inputbox run event loop check status (pressed cancel, ok, etc) return value end function -- Begin Code -- Allows extra event loops to be run! sequence EventLoopExit =20 EventLoopExit =3D {} global procedure EventLoop( integer id, integer style ) -- main routine=20 atom hWnd atom msg atom ele =20 -- allocate a message buffer =20 msg =3D allocate_struct(SIZEOF_MESSAGE) =20 EventLoopExit &=3D 0 ele =3D length(EventLoopExit) openWindow( id, style ) -- message loop while c_func( xGetMessage, { msg, NULL, 0, 0 } ) and not EventLoopExit[ele] do c_proc( xTranslateMessage, { msg } ) c_proc( xDispatchMessage, { msg } ) end while =20 free(msg) =20 EventLoopExit =3D EventLoopExit[1..ele-1] end procedure -- Back to original program ------------------------------------------------------------------ global procedure ExitEventLoop() =20 if length(EventLoopExit) then EventLoopExit[length(EventLoopExit)] =3D 1 end if end procedure -- End Code