GetCCursor
GetCCursor
Get a handle to a specified 'crsr' resource #include <Quickdraw.h> Color Quickdraw
short crsrID ; resource ID of desired cursor
returns handle leading to a 'crsr' data structure; 0 if error
GetCCursor allocates a new CCrsr data structure and initializes it with information in the new 'crsr' resource type.
crsrID is the resource identifier of the desired cursor.
Returns: a CCrs rHandle leading to the cursor data. If a resource type with the correct crsrID can't be found, the return value is NIL.
Notes: GetCCursor creates a new CCrsr data structure every time your application calls it, so don't call it before each SetCCursor call (as was Make sure that if you load the color table from a 'clut' resource using
GetCTable, mark the 'clut' resource as non-purgeable while the color cursor is in use. You can make 'crsr' resources purgeable since
Make sure you allocate enough space for your color cursor. If your cursor
is, say, 15 pixels tall and 9 pixels wide, you might be tempted to use these
values for the bounds.bottom and bounds.right, respectively, in your
cursor's pixel map. Don't do this! The problem is that when the cursor's
image needs to be expanded (i.e., when you specify a two bit-per- pixel
cursor and the mouse is on an eight-bit screen), SetCCursor rounds the width of the pixel map in such a way that you'll get only the space required
for a 15 by 8 pixel map allocated for the expanded cursor data. When the
cursor's image is expanded into this too-small cursor data handle as a 15 x
9 pixel map, something will get stepped on in your heap.
The solution is to specify that the (**pixmapHandle).bounds be 16 x 16.
This will cause SetCCursor to properly allocate the expanded data area. Since the amount of data drawn for a cursor is specified by the cursor's
pixel values and 'clut' resource, trying to save a few bytes by making the
bounds rectangle smaller than 16 x 16 will not help.