ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Does ChartDirector support resource paths for MFC icons?
Posted by David Wilson on Oct-25-2019 23:31
Many thanks for your kind help in the past.


I had to contact you recently to find out how to load MFC Bitmap resources into ChartDirector. I learned that the resource path is:

"@//<executable path>/bitmap/<resource id>"

I don't find this on the "Path Specification" page of the ChartDirector 6.3 documentation, perhaps it should be there.


Is it possible to load MFC Icon resources into CD as bitmaps as well?

"@//<executable path>/icon/<resource id>"

does not seem to work.


- Dave Wilson.

  Re: Does ChartDirector support resource paths for MFC icons?
Posted by Peter Kwan on Oct-27-2019 18:34
Hi David,

You are correct our documentation does not mentioned about the option to add an "executable path" or about "bitmap" resources. It is because at the time of the release, we have not tested these two features enough, so we did not documented them. We think it is now good enough to be of release quality.

Our original design is that if no such path is provided, it defaults to the entry point of the current process (usually the EXE that starts the process). However, it does not work for bitmap resources, so we need to specify the EXE. The next version with no longer required specifying the EXE if it is the entry point of the current process.

For the icon resources, ChartDirector currently cannot understand icon formats. An icon is not a single image, but a collection of images. For example, an ".ico" may contain 16x16, 32x32, 64x64 images. The images can look similar except of the size, or they can be different. The operating system (or the program that needs the icons) should pre-determined what size it needs. It would find an image in the icon that is of the nearest size and resize it to the required size.

For your case, if you compile the executable that contains the icons, you can always convert them to png image and use them instead. If you must use the provided icon resource, one method is:

(a) Load the icon image of the desired size with your own code (eg. using the Microsoft LoadImage API), the get the colors of every pixels using the GetPixel API.

(b) Create a DrawArea object, Create a "pattern color" with the pixel colors in (a) and use it as the background color of the DrawArea. The icon image will then be loaded into the DrawArea.

https://www.advsofteng.com/doc/cdcpp.htm#DrawArea.patternColor.htm
https://www.advsofteng.com/doc/cdcpp.htm#DrawArea.setSize.htm

If you must use some ChartDirector API that only accepts "paths", you can register the DrawArea as a resource of the object that uses the resource, then use the resource path syntax. See:

https://www.advsofteng.com/doc/cdcpp.htm#BaseChart.setResource2.htm
https://www.advsofteng.com/doc/cdcpp.htm#DrawArea.setResource2.htm

Hope this can help.

Regards
Peter Kwan

  Re: Does ChartDirector support resource paths for MFC icons?
Posted by David Wilson on Oct-28-2019 21:50
This is not an issue for us any more.

To explain, we wanted to include some Bitmap resource images in our charts, but to Visual Studio bitmap editor made it difficult for us to fix some problematic Bitmap images.  We were therefore hoping to use Icons resources instead.

Since I sent you the previous message, we were able to fix the Bitmap images, so we don't need Icon images for the foreseeable future. Apologies for the inquiry.

- Dave Wilson