1. How do I ....?
- Posted by don cole <doncole at pacbell.net> Oct 16, 2006
- 577 views
- Last edited Oct 17, 2006
Hello everybody, Using the examples I can't seem to get this right. 1. Open a window with a Cancel button showing. 2. Draw a line across the window using pixmaps. (this I've done sucessfully) 3. At any time stop the procedure by clicking the Cancel button. Don Cole
2. Re: How do I ....?
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 17, 2006
- 586 views
don cole wrote: > > Hello everybody, > > Using the examples I can't seem to get this right. > > 1. Open a window with a Cancel button showing. > > 2. Draw a line across the window using pixmaps. > (this I've done sucessfully) > > 3. At any time stop the procedure by clicking the Cancel button. This might give you a hint or two...
include win32lib.ew without warning integer vWin integer vCancelBtn integer vDrawBtn integer vTimerId integer vDrawingState procedure Timer_Beat(integer self, integer event, sequence parms) integer lColor integer x1,y1 integer x2,y2 sequence lRect -- Pick some random points in the client area lRect = getClientRect(vWin) x1 = rand(lRect[3]-lRect[1]) + lRect[1] x2 = rand(lRect[3]-lRect[1]) + lRect[1] y1 = rand(lRect[4]-lRect[2]) + lRect[2] y2 = rand(lRect[4]-lRect[2]) + lRect[2] -- Pick a color, any color. lColor = rand( power(2, 24) ) -- Draw a line... setPenColor(vWin, lColor) drawLine(vWin, x1, y1, x2, y2) -- Redraw the buttons in case the line messed them up. repaintFG(vCancelBtn) repaintFG(vDrawBtn) end procedure procedure Click_CancelBtn(integer self, integer event, sequence parms) vDrawingState = 0 -- No longer drawing. setEnable(self, 0) -- Disable this button setEnable(vDrawBtn, 1) -- Enable drawing to recommence. killTimer( vWin, vTimerId ) -- Stop the drawing ticker. end procedure procedure Click_DrawBtn(integer self, integer event, sequence parms) vDrawingState = 1 -- Now drawing setEnable(self, 0) -- Disable this button setEnable(vCancelBtn, 1) -- Allow cancelling -- 100 millisecond ticker setTimer( vWin, vTimerId, 100 ) -- kick off the timer again. end procedure procedure main() vWin = create(Window, "Sample Window", 0, 0, 0, 400, 400, 0) vCancelBtn = create(Button, "&Cancel", vWin, 10, 10, 60, 30, 0) vDrawBtn = create(Button, "&Draw", vWin, 100, 10, 60, 30, 0) vTimerId = 1 vDrawingState = 0 setEnable(vDrawBtn, 1) setEnable(vCancelBtn, 0) setHandler(vCancelBtn, w32HClick, routine_id("Click_CancelBtn")) setHandler(vDrawBtn, w32HClick, routine_id("Click_DrawBtn")) setHandler(vWin, w32HTimer, routine_id( "Timer_Beat" )) WinMain(vWin, Normal) end procedure main()
-- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
3. Re: How do I ....?
- Posted by don cole <doncole at pacbell.net> Oct 17, 2006
- 571 views
Thank you very much Derek, This is very similar to the demo Drawing2.exw One problem with this is the use of the timer. Also drawing directly to Window rather than pasting pixmaps. I prefer to change the tick with an outside loop. Even from another program. Such as:
one does not need to understand all this except that the pixmaps are
being manipulated by x.
And then the pixmaps are copied to the mainWindow.
procedure BuildPicture(integer xx) copyBlt(pixmapM,0,0,pixmap2) BrightBlue to main (dosen't go. -- needed to erase) copyPixmap (pixmap5,pixmapM,xx*fac)Blue to main goes forward
printout_percent(pixmapM,xx)
for x=1 to count do BuildPicture(x) end for
WinMain(maineWin, Normal)
Don Cole }}}
4. Re: How do I ....?
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 17, 2006
- 577 views
don cole wrote: > > Thank you very much Derek, > > This is very similar to the demo Drawing2.exw > > One problem with this is the use of the timer. > Also drawing directly to Window rather than pasting pixmaps. My example was only to give a hint. Try this /SORT OF THING/ ... integer vDrawing vDrawing = 1 procedure BuildPicture( int xx) if not vDrawing then return . . . doEvents(0) -- Give a chance to test for button clicks. end procedure procedure Click_CancelBtn( ... ) vDrawing = 0 end procedure procedure Click_DrawBtn( ... ) vDrawing = 1 end procedure for i = 1 to 92929292 do BuildPicture( i ) end for -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
5. Re: How do I ....?
- Posted by "Greg Haberek" <ghaberek at gmail.com> Oct 17, 2006
- 557 views
> }}} <eucode> > copyBlt(pixmapW,(winwidth-pbRight)/2,60,--raise and lower time here > pixmapT)--printing time to win > copyBlt(pixmapW,(winwidth-pbRight)/2,80,--raise and lower pb here > pixmapM)--both pbs to window > </eucode> {{{ The divisions above may result in a floating point. I believe copyBlt() expects integers. So if the division results in a decimal of .5, you'll get an error. Just a tip. :) ~Greg
6. Re: How do I ....?
- Posted by don cole <doncole at pacbell.net> Oct 17, 2006
- 534 views
Thanks again Derek. Help please.
Procedure BuildPicture(integer x) --copy the pixmap to different areas of the window copyBlt(RGBWin,0,0,pixmapW) doEvents(0) end procedure
procedure Paint_mainWindow(integer self, integer event, sequence parms) for x=1 to 100 do BuildPicture(x) doEvents(0) end for end procedure setHandler(RGBWin, w32HPaint,routine_id("Paint_mainWindow"))
procedure myclose( integer self, integer event, sequence parms ) abort(0) end procedure setHandler(PushButton2,w32HClick,routine_id("myclose"))
WinMain(RGBWin, Normal)
Clicking PushButton2 dosen’t do anything.
And Greg I tried putting floor in there where you suggested but it doesn’t change anything.
Don Cole }}}
7. Re: How do I ....?
- Posted by "Greg Haberek" <ghaberek at gmail.com> Oct 17, 2006
- 549 views
- Last edited Oct 18, 2006
> And Greg I tried putting floor in there where you suggested but it doesn't > change anything. Nope. It won't *change* anything, but in the chance event that decimal isn't expected, you could end up with a crash. Its just good practice to round pixel calculations off since you can't have 1/2 a pixel. ~Greg