ban2/png

tutor/gif
Home

cell/gif

Drawing in a window

cell/gif
1/gif Creating a non auto-redraw window
flag/pngCreate an application with a resfile containing a single window template so that, when the application is double-clicked, the window opens on the desktop and when the window closes the application quits; see Example 1.2.

By default redraws for Toolbox windows are handled automatically but this can be altered by deselecting the Auto-redraw option in the Other properties... dialogue box.

When drawing to a window it is a common policy to set the colour of its background to white. This can be done via the edit window's Colours... dialogue box.

2/gif Add a “WindowRedraw” event handler
event1/gifWhen the auto-redraw flag is deselected the corresponding event-handler entry in the application processing menu is no longer faded. Selecting this entry places a BASIC file in !RunImage containing the procedure definition:

DEF PROCDealWith_WindowRedraw(object,a%,b%,h%)
REM -------------------------------------------------
REM Current position of the lower left-hand corner of
REM work area is (a%,b%). Height of work area is h%
REM -------------------------------------------------

ENDPROC
event2/png
3/gif Drawing a circle
The following procedure draws a circle of radius 200 at position (500,500):
DEF PROCDealWith_WindowRedraw(object,a%,b%,h%)
CIRCLE FILL a%+500,b%+500,400
ENDPROC

draw/gif

The following procedures draw the circle in colour
DEF PROCDealWith_InitialEvent
Colour=15
ENDPROC

DEF PROCDealWith_WindowRedraw(object,a%,b%,h%)
SYS “Wimp_SetColour“,Colour
CIRCLE FILL a%+500,b%+500,400
ENDPROC

drawc/gif

4/gif Worked solution