1. FindFile.EXW
- Posted by tone.skoda at siol.net May 31, 2002
- 463 views
In Win32lib example FindFile.EXW you can press Stop button in the middle of loop and it will stop. How would I do that in my program without walk_dir()? So that window buttons respond to clicks even when a loop is running? I am thinking that window of that demo responds only because it does a lot of work on disk and processor has enough free power so window can respond to user clicks. I checked with task manager, CPU is used less than 50% when search is running. Maybe I could add event loop into my loop, GetMessage ()... ?
2. Re: FindFile.EXW
- Posted by tone.skoda at siol.net May 31, 2002
- 479 views
I found it: doEvents (0) ----- Original Message ----- From: <tone.skoda at siol.net> To: "EUforum" <EUforum at topica.com> Subject: FindFile.EXW > > In Win32lib example FindFile.EXW you can press Stop button in the middle of > loop and it will stop. > > How would I do that in my program without walk_dir()? So that window buttons > respond to clicks > even when a loop is running? > I am thinking that window of that demo responds only because it does a lot > of work on disk and processor has enough free power so window can respond to > user clicks. > I checked with task manager, CPU is used less than 50% when search is > running. > > Maybe I could add event loop into my loop, GetMessage ()... ? > > > >
3. Re: FindFile.EXW
- Posted by Derek Parnell <ddparnell at bigpond.com> May 31, 2002
- 556 views
> > In Win32lib example FindFile.EXW you can press Stop button in the middle of > loop and it will stop. > > How would I do that in my program without walk_dir()? So that window buttons > respond to clicks even when a loop is running? Tone, you need to use the doEvents() routine inside your loop. Here is an example.... -------------- include win32lib.ew without warning constant w = createEx(Window, "Pokie", 0, 0, 0, 300, 300, 0, 0), s = createEx(StatusBar, "", w, 0, 0, 0, 0, 0, 0), b = createEx(Button, "&Start", w, 20, 10, 60, 25, 0, 0), m = createEx(Button, "&Coins", w, 200, 10, 60, 25, 0, 0), e = createEx(EditText, "", w, 20, 40, 150, 45, 0, 0), pw = createEx(LText, "", w, 20, 90, 150, 25, 0, 0), Lsc = createEx(RText, "This Spin:", w, 10, 130, 80, 25, 0, 0), sc = createEx(RText, "", w, 95, 130, 50, 25, 0, 0), Lwn = createEx(RText, "Purse:", w, 10, 160, 80, 25, 0, 0), wn = createEx(RText, "", w, 95, 160, 50, 25, 0, 0), Lpo = createEx(RText, "Payout:", w, 10, 190, 80, 25, 0, 0), po = createEx(RText, "", w, 95, 190, 50, 25, 0, 0) integer IsLooping integer vPurse integer vPayOut vPurse = 0 vPayOut = 0 IsLooping = False constant kAlphas = {197,167,168,169,170,165} constant kPop = 165 & repeat(167,4) & repeat(168,4) & repeat(169,4) & repeat(170,4) & 197 ------------------------------------------------ procedure SpinWheels() ------------------------------------------------ sequence lText integer lChar integer lPrevChar integer lSize integer lWinnings sequence lPosWin if vPurse < 10 then setText(s, "Enter more coins to play.") setText(e, "") setText(pw, "") return end if vPurse -= 10 setText(sc, "") setText(s, "Started") setText(b, "&Stop") IsLooping = True lPosWin = repeat(0, 5) while IsLooping do lSize = 5 lText = "" lPrevChar = 0 while length(lText) < lSize do lChar = kPop[rand(length(kPop))] if lChar != lPrevChar then lText &= lChar lPrevChar = lChar end if end while setText(e, lText) doEvents(0) end while lWinnings = 0 for i = 1 to length(lText) do if lText[i] = kAlphas[1] then vPurse = 0 exit else lPosWin[i] = (find(lText[i], kAlphas) * i ) end if if find(lText[i], kAlphas[i..length(kAlphas)]) then lPosWin[i] += (i * i) end if if lText[i] = kAlphas[i+1] then lPosWin[i] += (i*10) end if lWinnings += lPosWin[i] end for vPurse += lWinnings if find(kAlphas[6], lText) then vPayOut += vPurse vPurse = 0 end if setText(pw, sprintf("$%d $%d $%d $%d $%d", lPosWin)) setText(sc, sprintf("$%d", lWinnings)) setText(wn, sprintf("$%d", vPurse)) setText(po, sprintf("$%d", vPayOut)) setText(s, "Stopped") setText(b, "&Start") end procedure ------------------------------------------------ procedure Click_b(integer self, integer event, sequence parms) ------------------------------------------------ if IsLooping = False then SpinWheels() else IsLooping = False end if end procedure setHandler(b, w32HClick, routine_id("Click_b")) ------------------------------------------------ procedure Click_m(integer self, integer event, sequence parms) ------------------------------------------------ vPurse += 5 setText(wn, sprintf("$%d", vPurse)) end procedure setHandler(m, w32HClick, routine_id("Click_m")) setFont(e, "Symbol", 24, Normal) setText(wn, sprintf("$%d", vPurse)) WinMain(w, Normal) ------------ Derek.