<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dataflex.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bjorn.thunvik</id>
	<title>DataFlex Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://dataflex.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bjorn.thunvik"/>
	<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Special:Contributions/Bjorn.thunvik"/>
	<updated>2026-05-02T22:40:46Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://dataflex.wiki/index.php?title=Add_icons_with_subset_of_images_to_CodeJock_CommandBars&amp;diff=1883</id>
		<title>Add icons with subset of images to CodeJock CommandBars</title>
		<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Add_icons_with_subset_of_images_to_CodeJock_CommandBars&amp;diff=1883"/>
		<updated>2008-04-24T09:26:06Z</updated>

		<summary type="html">&lt;p&gt;Bjorn.thunvik: New page: How to add icons with subset of images to CodeJock CommandBars.  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 ...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to add icons with subset of images to CodeJock CommandBars.&lt;br /&gt;
&lt;br /&gt;
If you add an icon with a subset of images to the CodeJock Commandbars, it &lt;br /&gt;
will use the first icon in the set and in most cases it will look awful.&lt;br /&gt;
&lt;br /&gt;
This function will use a different approach and use CodeJock&#039;s imagelist to load the icon.&lt;br /&gt;
The result is that the appropriate icon in the set will be used instead of the first.&lt;br /&gt;
The drawback is that the icon files must be in the path, embedding the images in the exe-file is not enough.&lt;br /&gt;
&lt;br /&gt;
Just add the function below to your project (below &amp;quot;Use cCJCommandBarSystem.pkg&amp;quot; or such).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    Function AddImageType for cCJCommandBarSystem Boolean bIsIcon String sImage Integer iId Integer eImageType Returns Integer&lt;br /&gt;
        Handle hBitmap&lt;br /&gt;
        Variant vImageManager&lt;br /&gt;
        Handle hoImageIcons&lt;br /&gt;
        Integer iVoid eType &lt;br /&gt;
        Boolean bOk&lt;br /&gt;
        String sImageName&lt;br /&gt;
        &lt;br /&gt;
        Move sImage to sImageName&lt;br /&gt;
        &lt;br /&gt;
        If (iId=0) Begin&lt;br /&gt;
            Get piLastImageId to iId&lt;br /&gt;
            Increment iId&lt;br /&gt;
            Set piLastImageId to iId&lt;br /&gt;
        End&lt;br /&gt;
        &lt;br /&gt;
        Move (If(bIsIcon,IMAGE_ICON,IMAGE_BITMAP)) to eType&lt;br /&gt;
        &lt;br /&gt;
        Move (LoadImage(GetModuleHandle(0), sImage, eType, 0, 0, 0)) to hBitmap&lt;br /&gt;
        If (hBitmap =0) Begin // the bitmap was not in the EXE resource&lt;br /&gt;
            Get_File_Path sImage to sImage // find path in DFPATH, if appropriate&lt;br /&gt;
            If (sImage &amp;lt;&amp;gt;&amp;quot;&amp;quot;) Begin // The image was found!&lt;br /&gt;
                Move (LoadImage(0, sImage, eType, 0, 0, LR_LOADFROMFILE)) to hBitmap&lt;br /&gt;
            End&lt;br /&gt;
        End&lt;br /&gt;
    &lt;br /&gt;
        If hBitmap Begin&lt;br /&gt;
            // if a bitmap it appears we must add this via an image manager&lt;br /&gt;
            If (not(bIsIcon)) Begin&lt;br /&gt;
                Get Create U_cCJImageManagerIcons to hoImageIcons&lt;br /&gt;
                Get ComIcons to vImageManager&lt;br /&gt;
                Set pvComObject of hoImageIcons to vImageManager&lt;br /&gt;
                Send ComAddBitmap of hoImageIcons hBitmap iId eImageType False&lt;br /&gt;
                Send destroy of hoImageIcons&lt;br /&gt;
            End&lt;br /&gt;
            Else Begin&lt;br /&gt;
                // First check if we can find the icon file.&lt;br /&gt;
                // Loading from file works much better with subset of icons&lt;br /&gt;
                Get_File_Path sImageName to sImageName // find path in DFPATH, if appropriate&lt;br /&gt;
                If (sImageName &amp;lt;&amp;gt;&amp;quot;&amp;quot;) Begin // The image was found!&lt;br /&gt;
                    Get Create U_cCJImageManagerIcons to hoImageIcons&lt;br /&gt;
                    Get ComIcons to vImageManager&lt;br /&gt;
                    Set pvComObject of hoImageIcons to vImageManager&lt;br /&gt;
                    Send ComLoadIcon of hoImageIcons sImageName iId eImageType &lt;br /&gt;
                    Send destroy of hoImageIcons&lt;br /&gt;
                End&lt;br /&gt;
                // We where not able to find the file, use original code.&lt;br /&gt;
                Else Begin&lt;br /&gt;
                    // this works with alpha blends - even when passed false&lt;br /&gt;
                    Send ComAddIconHandle hBitmap iId eImageType False&lt;br /&gt;
                End&lt;br /&gt;
            End&lt;br /&gt;
            Move (DeleteObject(hBitmap)) to iVoid&lt;br /&gt;
        End&lt;br /&gt;
        Function_Return (If(hBitmap&amp;lt;&amp;gt;0,iId,0))&lt;br /&gt;
    End_Function&lt;/div&gt;</summary>
		<author><name>Bjorn.thunvik</name></author>
	</entry>
</feed>