473,486 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How I Print an MSChart

It took me so long to figure this out, I thought I would share it.

This prints an MSChart using the metafilepict format after copying the
chart to the clipboard. This provides a high-resolution image rather
than the rough bitmap format.

Note: chtPlot is the name of the MSChart object and "e" is the
PrintPageEventArgs passed by the PrintPage event.
'Print MSChart control in high resolution using metafile
chtPlot.EditCopy() 'save graphic chart to clipboard

'read in metafilepict from clipboard and construct metafile
from this
Dim myStream As IO.MemoryStream =
Clipboard.GetDataObject.GetData(DataFormats.Metafi lePict)

Dim br As New BinaryReader(myStream) 'used to read in values from
memory stream

Dim mapMode As Integer = br.ReadInt32 'not used
Dim xExt As Integer = br.ReadInt32 'not used
Dim yExt As Integer = br.ReadInt32 'not used
Dim hMF As New IntPtr(br.ReadInt32) 'This is what we need

Dim myHeader As New WmfPlaceableFileHeader

Dim myMF As New Metafile(hMF, myHeader)

'define size and position of chart
Dim X, Y, Width, Height As Single

X = 1 'In inches
Y = 1
Width = 5
Height = 4
Dim rect As New Rectangle(X, Y, Width, Height)
e.Graphics.DrawImage(myMF, rect)

'print metafile
e.Graphics.PageUnit = GraphicsUnit.Inch
Hope this helps someone,

Clin

Nov 21 '05 #1
0 2988

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1902
by: Gerhard Swart | last post by:
Good Morning, I have a licensed .Net product. Meaning I can develop and deploy my projects. I want to use MSChart in my latest project. Now I am not sure about the licensing of MSChart. As far...
1
2255
by: arc | last post by:
My web application is using MSChart for reporting. (until i port it to some decent reporting tool) How to make sure all the web clients (IE atleast) have MSChart on their system to view these...
1
508
by: Jaime Lucci | last post by:
Has anybody any documentation about MSChart? Thanks.
1
3412
by: perspolis | last post by:
Hi all I want to print content of a MsChart.. I think I can do that by getting an image from that.. How can I do that?or is there any better way to print MsChart? thanks in advance
5
5014
by: Richard | last post by:
I don't know any thing about c#, I really need to do this in visual c++. I don't manually wrap the dll but since it's called AxInterop.OWC10.dll I assume visual studio has done that for me. ...
0
1419
by: Richard | last post by:
When I try adding a MSChart control from the toolbox I get an error message telling me it can't find AxInterop.OWC10.dll. I was given the advice below but i'm not sure where to add the class...
1
1909
by: wayne | last post by:
hi, i understand that i m able to use mschart to plot a line graph. i got list of values (jus one column) to b plotted into a line graph. how ca i do it using mschart in visual c++?? thanks...
2
3379
by: andrew | last post by:
I have an application that requires graphical output. I have added a MSChart to the application and want to be able to print this out. I have a form which allows me to print, and zoom in etc for...
0
1318
by: Nina | last post by:
Is there anybody knows how to print a mschart? Please help. Nina
0
7100
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.