Skip to content

AddImage - cCJCommandBarSystem

Adds a bitmap or icon Image to the CommandBar's imagelist

Type: Function
Return Data Type: Integer

Parameters

Parameter Type Description
sImage String Relative name of image to be found in filepath or resource.
iId Integer Unqiue integer identifier. If zero, the ID will be auto assigned.
eImageType Integer Type of ImageConstantMeaning

Syntax

Function AddImage String sImage Integer iId Integer eImageType Returns Integer

Call Example

Get AddImage sImage iId eImageType to IntegerVariable

Description

AddImage adds a bitmap or icon image to the commandbar system's imagelist. The type of image used is determined by its file extension. The image type is determined by the file extension in the passed image name: .bmp, .ico, .jpg, .png, .gif are all supported.

The Id passed must be a unique identifier for the image. Alternately, if you pass a zero for the ID, the ID will be automatically assigned and its value returned.

The image name must be a relative name (i.e., "MyImage.ico" and not "c:\MyApp\Bitmaps\MyImage.ico"). The message will first attempt to find the image in the program's resource area. If not found, it will search your program's dfpath for the filename. If the file cannot be found in the resource or in a filepath, the image will not be added and zero will be returned.

This message is identical to AddImageType except that the image type is auto-detected.

Adding Images to an Imagelist

If you need to dynamically add changes images in menus, toolbars and statusbars you will need to add the images to the commandbar system's imagelist. This is usually done within the cCJCommandBarSystem OnCreateCommandBars event.

// First you must assign IDs for the images

Define idImgSave for 100
Define idImgDelete for 101
Define idImgClear for 102
:

// next you add the images withn OnCreateCommandBars

Procedure OnCreateCommandBars
    Integer iId
    Forward Send OnCreateCommandBars

    Get AddImage "ActionSave.ico" idImgSave   xtpImageNormal to iId
    Get AddImage "ActionDelete.ico" idImgDelete xtpImageNormal to iId
    Get AddImage "ActionClear.ico" idImgClear xtpImageNormal to iId
    :
End_Procedure

Auto Assigning an Image Id

In this example, an image is added to the imagelist and the image id will be auto assigned.

// add an icon, auto assign the id
Get AddImage "MyImage.ico" 0 xtpImageNormal to iId
If (iId=0) Begin
   // image was not added 
End

Note

This message is normally not used to add images. The cCJAction methods psImage, psImageHot, psImageDisabled, psImageChecked and psImagePressed are typically used for this.

Image Mask Color

The image mask color determines how the various image states (normal, disabled, hot, etc.) are rendered. This data is provided in icon files. With bitmap files this color is determined by using the image's top left corner.

Return Value

If successful, this returns the ID of the image. If not successful, this returns zero.