The following program illustrates how to create a gadget list and use it:
MODULE 'intuition/intuition' CONST GADGETBUFSIZE = 4 * GADGETSIZE PROC main() DEF buf[GADGETBUFSIZE]:ARRAY, next, wptr next:=Gadget(buf, NIL, 1, 0, 10, 30, 50, 'Hello') next:=Gadget(next, buf, 2, 3, 70, 30, 50, 'World') next:=Gadget(next, buf, 3, 1, 10, 50, 50, 'from') next:=Gadget(next, buf, 4, 0, 70, 50, 70, 'gadgets') wptr:=OpenW(20,50,200,100, 0, WFLG_ACTIVATE, 'Gadgets in a window',NIL,1,buf) IF wptr /* Check to see we opened a window */ Delay(500) /* Wait a bit */ CloseW(wptr) /* Close the window */ ELSE WriteF('Error -- could not open window!') ENDIF ENDPROC
Four gadgets are created using an appropriately sized array as the buffer.
These gadgets are passed to
OpenW (the last parameter).
If the window could be opened a small delay is used so that the window is visible before the program closes it and terminates.
Delay is an Amiga system function from the DOS library, and
Delay(n) waits n/50 seconds.
Therefore, the window stays up for 10 seconds, which is enough time to play with the gadgets and see what the different types are.
The next example will show a better way of deciding when to terminate the program (using the standard close gadget).
Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.