I am trying to Export a TAdvGDIPCharView pane to EMF, using this function:
There are two issues:
The file contains the complete chart as awaited, but also a background and a border that has been added while using the CreateMetaFile function.
This is the original view as Delphi form:
After using the CreateMetafile it looks like this:
As you can see there is a small border around the pane which has also been exported to EMF.
If I open the emf file in an emf viewer, I get the following result:
you can see the pane in the upper left corner of the file. But there is also a background that is almost double in size.
Please advise what I can do to avoid both issues.
I'm able to reproduce this issue and will look into this as soon as possible
any news about this issue?
We'll investigate this as soon as possible. There were other urgencies that needed attention.
We have tested this with a default chart on the form and are not able to reproduce this. Are you sure the DPI settings of your application match the width & height of the chart?
I am not sure what you mean, Pieter. May it be helpful to send you the sources?
btw, it is Delphi 2007.
Yes, a sample would be helpful
Pieter, I prepared a zip file containing the project.
ChartTMS.zip (4.6 KB)
thank you for the sample. We have tested this here but don't see issues with the size.
I suppose this could be related to DPI settings of your project.
If I change the awareness to None, I get the following output:
Pieter, yes, this might be the cause. Unfortunately, there is no manifest editor in Delphi 2007.
If I create the manifest file manually and set dpiaware=true, the program starts like this:
the chart now looks different, much thinner and cropped.
but the wmf export seems to work correctly,
Opening your sample in Delphi 11 we can see this:
So it seems to be a high DPI / initialization issue in Delphi 2007. I noticed the size of the Y-Axis is forced to 100 pixels independant of the DPI, so you'll need to make sure the Y-Axis has the correct size as well when setting your application to be aware of DPI. The same applies to the X-Axis. The best approach would be to set AutoSize to true.
Hi Pieter, thank you for this tips. I now set the AutoSize for yaxis = true and get a much better result.
I cannot set both axis to autosize because I am painting the x-axis values by function and the years will then be displayed out of bounds. I don't have any idea how to put an extra offset to the bottom of the pane.
As you can see the y-axis values are painted directly to the y-axis without any space. This doesn't look good so I changed ValueFormat := '%.0n' to ValueFormat := '%.0n ' with two blank spaces behind the "n". This leads to:
Now it looks almost fine to me, but there is still the frame around the whole pane which is added when I use the chart.createmetafile command. I found out that this frame is also added if I use chart.setfocus. It seems to be the focus rectangle. How can I avoid this focus frame? The chart should look like this at the end
because I want to print it in our documents without any frame.
You can call Chart.DoExit; to remove the focus
this works well, thank you! Great support!
As I just want to print the charts in a document, is there a way to create it without having a TForm?
You can try passing nil as an owner, but it could be possible that the canvas needs a handle to paint and you will receive an error.