GetIndPattern
GetIndPattern Get Pattern from an indexed 'PAT#' resource
#include <ToolUtils.h> Toolbox Utilities
void GetIndPattern(thePattern, patListID, index );
Pattern thePattern; Pattern structure; receives data
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).
Returns: none

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
system pattern list contains the following 38 Standard Patterns:
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.:
Handle myResHandle;
short myResSize, myResCount;
myResHandle = GetResource( 'PAT#', sysPatListID );
myResSize = SizeResource( myResHandle );
myResCount = myResSize / sizeof( Pattern );
In the example above, the value of myResCount is calculated correctly as
38.
See PenPat for related information.
Example
#include <ToolUtils.h>
Pattern thePat;
Rect theRect;
GetIndPattern( thePat, sysPatListID, 12 ); /* system pattern */
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 */