Unit 'Graphics' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#lcl]

CreateGraphicFromResourceName

Creates and loads a TGraphic instance with the content from the specified resource instance handle and resource name.

Declaration

Source position: graphics.pp line 1990

function CreateGraphicFromResourceName(

  Instance: TLCLHandle;

  const ResName: string

):TGraphic;

Arguments

Instance

  

TLCLHandle instance for the application resource accessed in the routine.

ResName

  

Name for the resource loaded from the specified resource handle.

Function result

TGraphic (or descendant) instance with the graphic content loaded for the specified resource.

Description

CreateGraphicFromResourceName calls the RTL FindResource routine to get an FPC resource handle for the LCL handle in Instance and the resource with the name in ResName.

Both Icon and Cursor group resource types are checked using FindResource. When a valid resource handle (one with a non-zero value) is available, a TIcon or TCursorImage instance is created and used as the return value for the routine. The LoadFromResourceHandle method in the class instance is called to load the image content for the resource.

If a handle is not found for an Icon or a Cursor resource type, the CreateBitmapFromResourceName routine is called to create and load the content in the TGraphic instance.

CreateGraphicFromResourceName is used in the implementation of the TCustomImageList.AddResourceName method.

Version info

Modified in LCL version 4.0 to use the TLCLHandle type instead of the deprecated THandle type in the Instance parameter.

See also

TGraphic

  

Abstract base class used for images in supported image formats.

TIcon.LoadFromResourceHandle

  

Loads icon data from the specified instance and resource handles.

TCursorImage.LoadFromResourceHandle

  

Loads cursor images from the specified instance and resource handles.

TCustomImageList.AddResourceName

  

Adds a graphic from a resource with the specified resource name.

LCLType.TLCLHandle

WSReferences.TLCLHandle

  

The type used for handles in LCL applications, components, controls, and widget set classes.