PDA

View Full Version : Add icons with subset of images to CodeJock CommandBars.



=?iso-8859-1?Q?Bj=F6rn_Thunvik?=
22-Apr-2008, 06:36 AM
If you add an icon with a subset of images to the CodeJock Commandbars, it
will use the first icon in the set and in most cases it will look awful.
This function will use a different approach and use CodeJock's imagelist to
load the icon.
The result is that the appropriate icon in the set will be used instead of
the first.

Just add the function below to your project (below "Use
cCJCommandBarSystem.pkg" or such).

Function AddImageType for cCJCommandBarSystem Boolean bIsIcon String sImage
Integer iId Integer eImageType Returns Integer
Handle hBitmap
Variant vImageManager
Handle hoImageIcons
Integer iVoid eType
Boolean bOk
String sImageName

Move sImage to sImageName

If (iId=0) Begin
Get piLastImageId to iId
Increment iId
Set piLastImageId to iId
End

Move (If(bIsIcon,IMAGE_ICON,IMAGE_BITMAP)) to eType

Move (LoadImage(GetModuleHandle(0), sImage, eType, 0, 0, 0)) to hBitmap
If (hBitmap =0) Begin // the bitmap was not in the EXE resource
Get_File_Path sImage to sImage // find path in DFPATH, if
appropriate
If (sImage <>"") Begin // The image was found!
Move (LoadImage(0, sImage, eType, 0, 0, LR_LOADFROMFILE)) to
hBitmap
End
End

If hBitmap Begin
// if a bitmap it appears we must add this via an image manager
If (not(bIsIcon)) Begin
Get Create U_cCJImageManagerIcons to hoImageIcons
Get ComIcons to vImageManager
Set pvComObject of hoImageIcons to vImageManager
Send ComAddBitmap of hoImageIcons hBitmap iId eImageType False
Send destroy of hoImageIcons
End
Else Begin
// First check if we can find the icon file.
// Loading from file works much better with subset of icons
Get_File_Path sImageName to sImageName // find path in DFPATH,
if appropriate
If (sImageName <>"") Begin // The image was found!
Get Create U_cCJImageManagerIcons to hoImageIcons
Get ComIcons to vImageManager
Set pvComObject of hoImageIcons to vImageManager
Send ComLoadIcon of hoImageIcons sImageName iId eImageType
Send destroy of hoImageIcons
End
// We where not able to find the file, use original code.
Else Begin
// this works with alpha blends - even when passed false
Send ComAddIconHandle hBitmap iId eImageType False
End
End
Move (DeleteObject(hBitmap)) to iVoid
End
Function_Return (If(hBitmap<>0,iId,0))
End_Procedure


/ Björn Thunvik

wila
22-Apr-2008, 07:06 AM
Hi Björn!

Cool stuff, would you mind adding this to vdfwiki? In my opinion it is a
little easier to find/manage/update/extend things over there as in this
group.

--
Wil

Björn Thunvik wrote:
> If you add an icon with a subset of images to the CodeJock Commandbars,
> it will use the first icon in the set and in most cases it will look awful.
> This function will use a different approach and use CodeJock's imagelist
> to load the icon.
> The result is that the appropriate icon in the set will be used instead
> of the first.
>
> Just add the function below to your project (below "Use
> cCJCommandBarSystem.pkg" or such).
>
> Function AddImageType for cCJCommandBarSystem Boolean bIsIcon String sImage
> Integer iId Integer eImageType Returns Integer
> Handle hBitmap
> Variant vImageManager
> Handle hoImageIcons
> Integer iVoid eType
> Boolean bOk
> String sImageName
>
> Move sImage to sImageName
>
> If (iId=0) Begin
> Get piLastImageId to iId
> Increment iId
> Set piLastImageId to iId
> End
>
> Move (If(bIsIcon,IMAGE_ICON,IMAGE_BITMAP)) to eType
>
> Move (LoadImage(GetModuleHandle(0), sImage, eType, 0, 0, 0)) to hBitmap
> If (hBitmap =0) Begin // the bitmap was not in the EXE resource
> Get_File_Path sImage to sImage // find path in DFPATH, if
> appropriate
> If (sImage <>"") Begin // The image was found!
> Move (LoadImage(0, sImage, eType, 0, 0, LR_LOADFROMFILE)) to
> hBitmap
> End
> End
>
> If hBitmap Begin
> // if a bitmap it appears we must add this via an image manager
> If (not(bIsIcon)) Begin
> Get Create U_cCJImageManagerIcons to hoImageIcons
> Get ComIcons to vImageManager
> Set pvComObject of hoImageIcons to vImageManager
> Send ComAddBitmap of hoImageIcons hBitmap iId eImageType False
> Send destroy of hoImageIcons
> End
> Else Begin
> // First check if we can find the icon file.
> // Loading from file works much better with subset of icons
> Get_File_Path sImageName to sImageName // find path in DFPATH,
> if appropriate
> If (sImageName <>"") Begin // The image was found!
> Get Create U_cCJImageManagerIcons to hoImageIcons
> Get ComIcons to vImageManager
> Set pvComObject of hoImageIcons to vImageManager
> Send ComLoadIcon of hoImageIcons sImageName iId eImageType
> Send destroy of hoImageIcons
> End
> // We where not able to find the file, use original code.
> Else Begin
> // this works with alpha blends - even when passed false
> Send ComAddIconHandle hBitmap iId eImageType False
> End
> End
> Move (DeleteObject(hBitmap)) to iVoid
> End
> Function_Return (If(hBitmap<>0,iId,0))
> End_Procedure
>
>
> / Björn Thunvik

omintegui
22-Apr-2008, 12:13 PM
Björn,
Great Works, I implemented it already and it works great!

Thank you very much,
Oscar Mintegui


"Björn Thunvik" <bjorn.thunvik@exdesystems.se> wrote in message
news:M6oeg0GpIHA.5068@dacmail.dataaccess.com...
> If you add an icon with a subset of images to the CodeJock Commandbars, it
> will use the first icon in the set and in most cases it will look awful.
> This function will use a different approach and use CodeJock's imagelist
> to load the icon.
> The result is that the appropriate icon in the set will be used instead of
> the first.
>
> Just add the function below to your project (below "Use
> cCJCommandBarSystem.pkg" or such).
>
> Function AddImageType for cCJCommandBarSystem Boolean bIsIcon String
> sImage
> Integer iId Integer eImageType Returns Integer
> Handle hBitmap
> Variant vImageManager
> Handle hoImageIcons
> Integer iVoid eType
> Boolean bOk
> String sImageName
>
> Move sImage to sImageName
>
> If (iId=0) Begin
> Get piLastImageId to iId
> Increment iId
> Set piLastImageId to iId
> End
>
> Move (If(bIsIcon,IMAGE_ICON,IMAGE_BITMAP)) to eType
>
> Move (LoadImage(GetModuleHandle(0), sImage, eType, 0, 0, 0)) to hBitmap
> If (hBitmap =0) Begin // the bitmap was not in the EXE resource
> Get_File_Path sImage to sImage // find path in DFPATH, if
> appropriate
> If (sImage <>"") Begin // The image was found!
> Move (LoadImage(0, sImage, eType, 0, 0, LR_LOADFROMFILE)) to
> hBitmap
> End
> End
>
> If hBitmap Begin
> // if a bitmap it appears we must add this via an image manager
> If (not(bIsIcon)) Begin
> Get Create U_cCJImageManagerIcons to hoImageIcons
> Get ComIcons to vImageManager
> Set pvComObject of hoImageIcons to vImageManager
> Send ComAddBitmap of hoImageIcons hBitmap iId eImageType False
> Send destroy of hoImageIcons
> End
> Else Begin
> // First check if we can find the icon file.
> // Loading from file works much better with subset of icons
> Get_File_Path sImageName to sImageName // find path in DFPATH,
> if appropriate
> If (sImageName <>"") Begin // The image was found!
> Get Create U_cCJImageManagerIcons to hoImageIcons
> Get ComIcons to vImageManager
> Set pvComObject of hoImageIcons to vImageManager
> Send ComLoadIcon of hoImageIcons sImageName iId eImageType
> Send destroy of hoImageIcons
> End
> // We where not able to find the file, use original code.
> Else Begin
> // this works with alpha blends - even when passed false
> Send ComAddIconHandle hBitmap iId eImageType False
> End
> End
> Move (DeleteObject(hBitmap)) to iVoid
> End
> Function_Return (If(hBitmap<>0,iId,0))
> End_Procedure
>
>
> / Björn Thunvik

=?iso-8859-1?Q?Bj=F6rn_Thunvik?=
24-Apr-2008, 04:25 AM
I've added a page at vdfwiki now.
Someone with a little bit more knowledge of wiki might want to add/change
something to the page (cathegory?)..

/ Björn


"Wil van Antwerpen" <info@antwise.com> skrev i meddelandet
news:995NeFHpIHA.192@dacmail.dataaccess.com...
> Hi Björn!
>
> Cool stuff, would you mind adding this to vdfwiki? In my opinion it is a
> little easier to find/manage/update/extend things over there as in this
> group.
>
> --
> Wil
>
> Björn Thunvik wrote:
>> If you add an icon with a subset of images to the CodeJock Commandbars,
>> it will use the first icon in the set and in most cases it will look
>> awful.
>> This function will use a different approach and use CodeJock's imagelist
>> to load the icon.
>> The result is that the appropriate icon in the set will be used instead
>> of the first.
>>
>> Just add the function below to your project (below "Use
>> cCJCommandBarSystem.pkg" or such).
>>
>> Function AddImageType for cCJCommandBarSystem Boolean bIsIcon String
>> sImage
>> Integer iId Integer eImageType Returns Integer
>> Handle hBitmap
>> Variant vImageManager
>> Handle hoImageIcons
>> Integer iVoid eType
>> Boolean bOk
>> String sImageName
>>
>> Move sImage to sImageName
>>
>> If (iId=0) Begin
>> Get piLastImageId to iId
>> Increment iId
>> Set piLastImageId to iId
>> End
>>
>> Move (If(bIsIcon,IMAGE_ICON,IMAGE_BITMAP)) to eType
>>
>> Move (LoadImage(GetModuleHandle(0), sImage, eType, 0, 0, 0)) to
>> hBitmap
>> If (hBitmap =0) Begin // the bitmap was not in the EXE resource
>> Get_File_Path sImage to sImage // find path in DFPATH, if
>> appropriate
>> If (sImage <>"") Begin // The image was found!
>> Move (LoadImage(0, sImage, eType, 0, 0, LR_LOADFROMFILE)) to
>> hBitmap
>> End
>> End
>>
>> If hBitmap Begin
>> // if a bitmap it appears we must add this via an image manager
>> If (not(bIsIcon)) Begin
>> Get Create U_cCJImageManagerIcons to hoImageIcons
>> Get ComIcons to vImageManager
>> Set pvComObject of hoImageIcons to vImageManager
>> Send ComAddBitmap of hoImageIcons hBitmap iId eImageType False
>> Send destroy of hoImageIcons
>> End
>> Else Begin
>> // First check if we can find the icon file.
>> // Loading from file works much better with subset of icons
>> Get_File_Path sImageName to sImageName // find path in DFPATH,
>> if appropriate
>> If (sImageName <>"") Begin // The image was found!
>> Get Create U_cCJImageManagerIcons to hoImageIcons
>> Get ComIcons to vImageManager
>> Set pvComObject of hoImageIcons to vImageManager
>> Send ComLoadIcon of hoImageIcons sImageName iId eImageType
>> Send destroy of hoImageIcons
>> End
>> // We where not able to find the file, use original code.
>> Else Begin
>> // this works with alpha blends - even when passed false
>> Send ComAddIconHandle hBitmap iId eImageType False
>> End
>> End
>> Move (DeleteObject(hBitmap)) to iVoid
>> End
>> Function_Return (If(hBitmap<>0,iId,0))
>> End_Procedure
>>
>>
>> / Björn Thunvik

wila
24-Apr-2008, 05:38 AM
Very nice, thank you!
I've added the article to the category "Visual DataFlex" and "CodeJock"
and added a link under the group "advanced" in the visual dataflex
summary page.

--
Wil


Björn Thunvik wrote:
> I've added a page at vdfwiki now.
> Someone with a little bit more knowledge of wiki might want to
> add/change something to the page (cathegory?)..
>
> / Björn
>
>
> "Wil van Antwerpen" <info@antwise.com> skrev i meddelandet
> news:995NeFHpIHA.192@dacmail.dataaccess.com...
>> Hi Björn!
>>
>> Cool stuff, would you mind adding this to vdfwiki? In my opinion it is
>> a little easier to find/manage/update/extend things over there as in
>> this group.
>>
>> --
>> Wil
>>
>> Björn Thunvik wrote:
>>> If you add an icon with a subset of images to the CodeJock
>>> Commandbars, it will use the first icon in the set and in most cases
>>> it will look awful.
>>> This function will use a different approach and use CodeJock's
>>> imagelist to load the icon.
>>> The result is that the appropriate icon in the set will be used
>>> instead of the first.
>>>
>>> Just add the function below to your project (below "Use
>>> cCJCommandBarSystem.pkg" or such).
>>>
>>> Function AddImageType for cCJCommandBarSystem Boolean bIsIcon String
>>> sImage
>>> Integer iId Integer eImageType Returns Integer
>>> Handle hBitmap
>>> Variant vImageManager
>>> Handle hoImageIcons
>>> Integer iVoid eType
>>> Boolean bOk
>>> String sImageName
>>>
>>> Move sImage to sImageName
>>>
>>> If (iId=0) Begin
>>> Get piLastImageId to iId
>>> Increment iId
>>> Set piLastImageId to iId
>>> End
>>>
>>> Move (If(bIsIcon,IMAGE_ICON,IMAGE_BITMAP)) to eType
>>>
>>> Move (LoadImage(GetModuleHandle(0), sImage, eType, 0, 0, 0)) to
>>> hBitmap
>>> If (hBitmap =0) Begin // the bitmap was not in the EXE resource
>>> Get_File_Path sImage to sImage // find path in DFPATH, if
>>> appropriate
>>> If (sImage <>"") Begin // The image was found!
>>> Move (LoadImage(0, sImage, eType, 0, 0, LR_LOADFROMFILE)) to
>>> hBitmap
>>> End
>>> End
>>>
>>> If hBitmap Begin
>>> // if a bitmap it appears we must add this via an image manager
>>> If (not(bIsIcon)) Begin
>>> Get Create U_cCJImageManagerIcons to hoImageIcons
>>> Get ComIcons to vImageManager
>>> Set pvComObject of hoImageIcons to vImageManager
>>> Send ComAddBitmap of hoImageIcons hBitmap iId eImageType
>>> False
>>> Send destroy of hoImageIcons
>>> End
>>> Else Begin
>>> // First check if we can find the icon file.
>>> // Loading from file works much better with subset of icons
>>> Get_File_Path sImageName to sImageName // find path in
>>> DFPATH,
>>> if appropriate
>>> If (sImageName <>"") Begin // The image was found!
>>> Get Create U_cCJImageManagerIcons to hoImageIcons
>>> Get ComIcons to vImageManager
>>> Set pvComObject of hoImageIcons to vImageManager
>>> Send ComLoadIcon of hoImageIcons sImageName iId
>>> eImageType
>>> Send destroy of hoImageIcons
>>> End
>>> // We where not able to find the file, use original code.
>>> Else Begin
>>> // this works with alpha blends - even when passed false
>>> Send ComAddIconHandle hBitmap iId eImageType False
>>> End
>>> End
>>> Move (DeleteObject(hBitmap)) to iVoid
>>> End
>>> Function_Return (If(hBitmap<>0,iId,0))
>>> End_Procedure
>>>
>>>
>>> / Björn Thunvik
>