GetIndPattern
short patListID ; 0=system pattern list; else 'PAT#' rsrc ID
short index ; ID of desired pattern
GetIndPattern copies a specified pattern from an indexed 'PAT#' resource into a user variable.
thePattern is the address of an 8-byte Pattern structure. Upon return, it will contain the pattern data. If the index is an invalid value, the contents
of thePat will be un changed.
patListID is the resource ID of a 'PAT#' resource. The constant, sysPatListID
(value 0) is defined in ToolboxUtil.h; it identifies a list of 38
standard patterns (see Notes).
index identifies which element of the pattern list you want to retrieve. It
will range from 1 to the number of elements in the indexed resource.
Valid values can be calculated from the size of the resource (see
below).
Notes: Use GetIndPattern to access a 'PAT#' resource. Indexed pattern resources are more efficient than 'PAT ' resources (see GetPattern) for storing multiple patterns. Remember to start indexing from 1, not 0. The
As with all indexed resources, you can determine the number of elements
(thus, the highest valid value for index ) by dividing the size of the
resource by the size of each element; e.g.:
short myResSize, myResCount;
myResCount = myResSize / sizeof( Pattern ); In the example above, the value of myResCount is calculated correctly as
38.
Example
#include <ToolUtils.h>
SetRect( & theRect, 100,100, 200,200 ); FrameRect( & theRect); [TOKEN:12074] frame the area */ InsetRect( & theRect, 1,1); [TOKEN:12074] don't overwrite the frame */ FillRect( & theRect, thePat ); [TOKEN:12074] fill with 'brickwork' pattern */