Re: I need help with a text edit window
> From: Gene Mannel
>
> My program is using an edit text window for the user to
> input but I want Windows to stop in the edit window untill
> the user presses 'ENTER" after inputing text then have the
> program continue on.
>
What we need in win32lib is a way to use custom dialogs. I've looked into
it a little bit now and then, and I get scared away almost every time.
Prolly not as hard as I think it is, but...
Until then, I came up with a hack that basically works. I've put together a
couple of routines that allow you to run an extra event loop, so that you
can basically do what you want. It's used similar to WinMain().
Suppose your edit window is named EditWin. To open it, call:
EventLoop( EditWin, Modal )
Then, when this window is closed, be sure to call (most likely in the
onClose event for EditWin):
ExitEventLoop()
Some things to be careful about: Don't allow more than one open modal
window. This causes problems in win32lib. Also, you need to make sure that
ExitEventLoop is called when the window is closed, or your program will
continue to run even after your main window is closed.
You can nest multiple event loops with this code, but you'll have to manage
closing the modal windows yourself. In fact, it probably makes sense to
close the event loop before opening another. But I haven't really figured
out the best way to do this. Let me know if you find something that works
well!
-- eventloop.ew
-----------------------------------------------------------------
-- Added by Matt Lewis 3/10/00
-- to win32lib.
-- Allows extra event loops to be run!
sequence EventLoopExit
EventLoopExit = {}
global procedure EventLoop( integer id, integer style )
-- main routine
atom hWnd
atom msg
atom ele
-- allocate a message buffer
msg = allocate_struct(SIZEOF_MESSAGE)
EventLoopExit &= 0
ele = 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
free(msg)
EventLoopExit = EventLoopExit[1..ele-1]
end procedure
-- Back to original program
------------------------------------------------------------------
global procedure ExitEventLoop()
if length(EventLoopExit) then
EventLoopExit[length(EventLoopExit)] = 1
end if
end procedure
|
Not Categorized, Please Help
|
|