Printing PicBoxes.

alt_255
01-09-2005, 03:49 PM
I have a series of MSChart controls, which have been set as child windows of two picboxes. I then used SavePicture to save the contents of each to a temporary bmp file, the use PrintPicture to print it.

The problem is that the Charts aren't being saved or printed!! If my concept is correct, being child windows, they should be drawn on the picbox's DC..

Any thoughts?

zelg37
01-09-2005, 07:21 PM
If my concept is correct, being child windows, they should be drawn on the picbox's DC..Any thoughts?
I think your "concept" may be a bit skewed because, unlike forms and other controls in Visual Basic (as PictureBox, TextBox, etc), the MsChart control doesn't expose either an .hDC or a .Picture property to work with:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mschrt/html/vbobjvtchartobjectpme.asp

However, if you do a search of the forum (using "MsChart print") you'll find several posts recommending the EditCopy approach. Something like:

MSChart1.EditCopy
Printer.Print "MSChart print"
Printer.PaintPicture Clipboard.GetData(), 0, 0
Printer.EndDoc


Here's another approach:
http://www.angelfire.com/realm/vb-shared/Chart2Pic.htm

And if all else fails, as long as the whole of the chart is visible at one time, you can use the brute force method - looping through all the pixels with GetPixel API and using the SetPixel API to transfer the pixels to another form/picturebox, but try using other approachs listed above first.

There are many ActiveX controls that have graphical output, but do not expose an hDC property, but shame on Microsoft for setting such a bad example. (Hopefully, though, you are using the controls in Service Pack 6 of VB6 though--some of them where updated, but I don't know if this is one of them..)

passel
01-09-2005, 09:05 PM
I have a series of MSChart controls, which have been set as child windows of two picboxes. I then used SavePicture to save the contents of each to a temporary bmp file, the use PrintPicture to print it.

The problem is that the Charts aren't being saved or printed!! If my concept is correct, being child windows, they should be drawn on the picbox's DC..

Any thoughts?

The Charts are probably being drawn on the picbox's "Screen" DC.
SavePicture will save one of the stdPicture objects of the picbox, accessed
either by the .Picture property or the .Image property. It won't save the
Screen Image.
Another option would be to use bitblt to access the image as it exist on the
screen. The EditCopy method is probably best though.

alt_255
01-10-2005, 03:41 PM
Thankyou all. You have both been a great help.

alt_255
01-10-2005, 04:19 PM
Another question, I'm using the EditCopy method, and it is transferring the charts fine. BUT the LegendText for the series on each chart are missing, and is set at the default C1 Why would this be?

alt_255
01-12-2005, 06:04 PM
Panicked bump

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum