Simple solution figured out
- Posted by George Henry <ghenryca at HOTMAIL.COM> Dec 11, 2000
- 487 views
-- This is all I was looking for. -- -- I found the C code that implements DoEvents online somewhere. -- I noticed that it was functionally identical to the message -- loop code in Win32lib, so I appropriated that code into my -- program. After a tiny bit of tweaking (getting the bugs out), -- it does precisely what I wanted. -- -- Note that a nested loop such as the following DOES NOT work -- properly. -- -- while isOpen3 do -- -- DoEvents -- while c_func(xGetMessage, {msg, NULL, 0, 0}) do -- c_proc(xTranslateMessage, {msg}) -- c_proc(xDispatchMessage, {msg}) -- end while -- end while -- -- If anyone was working on this, thanks anyway. Hopefully we have -- had a good exercise in communcation, at least, and now anyone -- who has read my series and needs to do the something similar -- will know how. -- -- George Henry include dll.e include \euphoria\userlib\win32lib.50\win32lib.ew without warning object sink constant win1 = create(Window, "Help Me Please", 0, Default, Default, 640, 480, 0), ctrlGo = create(PushButton, "Go", win1, 10, 10, 30, 20, 0), win2 = create(Window, "Output - Normal", win1, Default, Default, 640, 480, 0), ctrlText2 = create(MleText, "", win2, 10, 10, 500, 300, 0), win3 = create(Window, "Output - Modal", win2, Default, Default, 640, 480, 0), ctrlText3 = create(MleText, "", win3, 10, 10, 500, 300, 0) integer calls, counter, id_two, id_three, isOpen2, isOpen3 sequence text procedure update_text(sequence name) atom msg text &= "in " & name & "() counter=" & sprint(counter) & "\r\n" if not isOpen2 then openWindow(win2, Normal) end if setText(ctrlText2, text) setFocus(win1) if remainder(calls, 5) = 0 then if not isOpen3 then openWindow(win3, Modal) end if setText(ctrlText3, text) -- BEGIN DoEvents MESSAGE LOOP msg = allocate_struct(SIZEOF_MESSAGE) while isOpen3 and c_func(xGetMessage, {msg, NULL, 0, 0}) do c_proc(xTranslateMessage, {msg}) c_proc(xDispatchMessage, {msg}) end while free(msg) -- END DoEvents MESSAGE LOOP end if end procedure procedure one() calls += 1 if counter < 20 then counter -= 2 update_text("one") end if end procedure procedure two() calls += 1 if counter < 20 then counter += 1 update_text("two") end if end procedure procedure three() calls += 1 if counter < 20 then counter += 3 update_text("three") end if end procedure procedure onClick_ctrlGo() integer guess for iter = 1 to 20 do guess = rand(9) if guess <= 3 then one() elsif guess <= 6 then two() else three() end if end for end procedure procedure onOpen_win2() isOpen2 = True end procedure procedure onClose_win2() isOpen2 = False setFocus(win1) end procedure procedure onOpen_win3() isOpen3 = True end procedure procedure onClose_win3() isOpen3 = False setFocus(win1) end procedure onClick[ctrlGo] = routine_id("onClick_ctrlGo") onOpen[win2] = routine_id("onOpen_win2") onClose[win2] = routine_id("onClose_win2") onOpen[win3] = routine_id("onOpen_win3") onClose[win3] = routine_id("onClose_win3") calls = 0 counter = 0 id_two = routine_id("two") id_three = routine_id("three") isOpen2 = False isOpen3 = False text = "" sink = sendMessage(ctrlText2, EM_SETREADONLY, True, 0) sink = sendMessage(ctrlText3, EM_SETREADONLY, True, 0) WinMain(win1, Normal) _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com