Important: The information in this document is obsolete and should not be used for new development.
IconMethodToRgn
You can use theIconMethodToRgnfunction to convert, to a region, the mask for an icon thatIconMethodToRgnobtains with the aid of your icon getter function.
FUNCTION IconMethodToRgn (theRgn: RgnHandle; iconRect: Rect; align: IconAlignmentType; theMethod: IconGetter; yourDataPtr: Ptr): OSErr;
theRgnIconMethodToRgnreturns a handle to the requested region in this parameter. You must allocate memory for the region handle before callingIconMethodToRgn.iconRect- The rectangle in which to draw the icon, specified in local coordinates of the current graphics port. The
IconMethodToRgnfunction obtains the data for the icon mask from your icon getter function and then converts the icon mask to a region.IconMethodToRgnuses the rectangle specified in this parameter as the bounding box of the region.align- A value that specifies how
IconMethodToRgnshould align the region within the rectangle. See the description ofPlotIconIDon page 5-20 for a list of constants you can use in this parameter.theMethod- A pointer to an icon getter function.
yourDataPtr- A pointer to data that is passed to your icon getter function.
DESCRIPTION
TheIconMethodToRgnfunction modifies the region referred to by the handle in thetheRgnparameter. The region corresponds to the icon's mask (as returned by your icon getter function, and according to the rectangle and alignment specified in theiconRectandalignparameters).
IconMethodToRgnpasses to your icon getter function the type of the icon to get and the value specified in theyourDataPtrparameter. TheIconMethodToRgnfunction examines the size of the rectangle and requests the appropriate icon from your icon getter function--an icon of icon type'ICN#'or'ics#'. Your icon getter function should return a handle to the data of the requested icon type. TheIconMethodToRgnfunction extracts the mask from the icon data that your icon getter function returns. If your icon getter function returns data that does not correspond to an icon of type'ICN#'or type'ics#',IconMethodToRgnattempts to generate a mask from the returned data.Your icon getter function can get the data for the icon and its mask using whatever method is appropriate to your application. For example, your application might maintain its own cache of icons (and pass a pointer to it in the
yourDataPtrparameter) or use its icon getter function to get an icon from the desktop database.RESULT CODES
noErr 0 No error noMaskFoundErr -1000 No mask found