Class: cSigCJImage_Manager_Mixin
Class Hierarchy:
cObject

Mixin


cSigCJImage_Manager_MixinClass Definition
Properties
Handle
phoImagelist
Integer
piLastImageId
tdImageInfo[]
ptImageInfo
Functions and Procedures
Integer
AddImage(String sImage Integer iId Integer eImageType)
-------------------------------------------------------------------------
Purpose : Adds an image to the image manager
Parameters : sImage - The file name of the image to load#
iID - If zero the next ID will be allocated
If NOT zero this will be used as the ID. If an image
with this ID has already been loaded then it will be
replaced
eImageType - The usage type of the image i.e. normal,
shadowed, checked etc.
Returns : The image ID.
-------------------------------------------------------------------------
Function AddImage String sImage Integer iId Integer eImageType Returns Integer
Boolean bIsIcon bIsBitmap bOK
Handle hImage
Variant vImageManager vImageHandle
Handle hoImageIcons
Integer iVoid iNextImage iImageId
String sFileImage
tdImageInfo[] tImageInfo
//Have we already loaded this
Get Find_Image sImage to iImageId
If (iImageId = 0) Begin
//What type of image...
//If .ICO try loading from file first then from resource (resource only allows one image)
//If .BMP try loading from resource first then from file (resource quicker)
//If any other load from file (resource only support .BMP & .ICO)
Move (Pos(".ico",Lowercase(sImage))>0) to bIsIcon
Move (Pos(".bmp",Lowercase(sImage))>0) to bIsBitMap
Move False to bOK
//If no ID passed use next else replace image for specified ID
If (iId=0) Begin
Get piLastImageId to iImageId
Increment iImageId
Set piLastImageId to iImageId
End
Else Begin
Move iId to iImageId
End
//Connect to the local Image manager
Get Create U_cCJImageManagerIcons to hoImageIcons
Get ComIcons to vImageManager
Set pvComObject of hoImageIcons to vImageManager
// if an icon we will always try to load from a file first. Loading from a file works better than
// the internal resource load because the internal load only finds the first image. If the ico has
// multiple images (which CJ can use) all of the extra images are lost
// if an Icon - load from file first then load from resource
If bIsIcon Begin
Get_File_Path sImage to sFileImage // find path in DFPATH, if appropriate
If (sFileImage<>"") Begin
Send ComLoadIcon of hoImageIcons sFileImage iImageId eImageType
Move True to bOk
End
Else Begin
Move (LoadImage(GetModuleHandle(0), sImage, IMAGE_ICON, 0, 0, 0)) to hImage
If hImage Begin
// this works with alpha blends - even when passed false
Send ComAddIconHandle hImage iImageId eImageType False
Move (DestroyIcon(hImage)) to iVoid
Move True to bOk
End
End
End //is icon
Else Begin
If bIsBitmap Begin // if a bitmap - load from resource first then from file
Move (LoadImage(GetModuleHandle(0), sImage, IMAGE_BITMAP, 0, 0, 0)) to hImage
If (hImage=0) Begin // the bitmap was not in the EXE resource
Get_File_Path sImage to sFileImage // find path in DFPATH, if appropriate
If (sFileImage <>"") Begin // The image was found!
Move (LoadImage(0, sFileImage, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)) to hImage
End
End
If hImage Begin
Send ComAddBitmap of hoImageIcons hImage iImageId eImageType False
Move (DeleteObject(hImage)) to iVoid
Move True to bOk
End
End //is bitmap
Else Begin //other image type
Get_File_Path sImage to sFileImage // find path in DFPATH, if appropriate
If (sFileImage <>"") Begin // The image was found!
Send ComLoadBitmap of hoImageIcons sFileImage iImageId eImageType
Move True to bOk
End
End
End //not icon
Get ComGetImage of hoImageIcons iImageId 0 to vImageHandle
Send destroy of hoImageIcons
If bOK Begin
//Note what we have just added
Get ptImageInfo to tImageInfo
Move (SizeOfArray(tImageInfo)) to iNextImage
Move sImage to tImageInfo[iNextImage].sImageName
Move iImageId to tImageInfo[iNextImage].iImageID
Move vImageHandle to tImageInfo[iNextImage].vImageHandle
Move hImage to tImageInfo[iNextImage].hWnd
Set ptImageInfo to tImageInfo
End
End
Function_Return (If(bOk, iImageId, 0))
End_Procedure
Integer
CompareImageID(tdImageInfo tImage1 tdImageInfo tImage2)
---------------------------------------------------
Function : CompareImageID
Scope : Private
Purpose : Used internally as part of a SearchArray call to compare the iImageId elements
of two tdImageInfo structs
---------------------------------------------------
Integer
CompareImageName(tdImageInfo tImage1 tdImageInfo tImage2)
---------------------------------------------------
Function : CompareImageName
Scope : Private
Purpose : Used internally as part of a SearchArray call to compare the sImageName elements
of two tdImageInfo structs
---------------------------------------------------

Create_Image_Manager()
Creation method that creates the image list object for storage of images and icons
Integer
Find_Image(String sImage)
---------------------------------------------------
Function : Find_Image
Scope : Public
Paramaters : String sImage
Returns : Integer (Image ID)
Purpose : Searches the ptImageInfo property to see if an image, specified by name ("someicon.ico") has
already been uploaded. If so, it returns the unique id to that image.
---------------------------------------------------
String
Find_Image_Name(Integer iImageId)
---------------------------------------------------
Function : Find_Image_Name
Scope : Public
Paramaters : Integer iImageId
Returns : Handle
Purpose : Returns the Image file name as specified by its Image ID
---------------------------------------------------
Variant
ImageFromId(Integer iImageId)
---------------------------------------------------
Function : ImageFromId
Scope : Public
Paramaters : Integer iImageId
Returns : variant (IDispatch* pointer to the image)
Purpose : Returns the IDispatch* pointer to the image as specified by its Image ID
---------------------------------------------------
Handle
ImageHwndFromId(Integer iImageId)
---------------------------------------------------
Function : ImageHwndFromId
Scope : Public
Paramaters : Integer iImageId
Returns : Handle
Purpose : Returns the window handle to an image as specified by its Image ID
---------------------------------------------------

Initialise_Image_Manager_Mixin()
Initialise, create properties etc

Load_Images()
Hook for loading Images