Article ID: 197487
Article Last Modified on 5/13/2003
Option Explicit
Private Sub Form_Load()
' Set the chart legends to some text value
MSChart1.Plot.SeriesCollection.Item(1).LegendText = "Total Space"
MSChart1.Plot.SeriesCollection.Item(2).LegendText = "Used Space"
' Call the EditCopy method to send the chart to the clipboard
MSChart1.EditCopy
' Save the data on the clipboard as a bitmap
' you can also use clipboard viewer to see everything
SavePicture Clipboard.GetData, "c:\test1.bmp"
End Sub
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4& ' Draw the window's client area.
Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows.
Private Const PRF_OWNED = &H20& ' Draw all owned windows.
Private Sub Command1_Click()
Dim rv As Long
' Make sure picturebox is same size as the chart.
With Picture1
.Height = MSChart1.Height
.Width = MSChart1.Width
End With
Picture1.AutoRedraw = True
rv = SendMessage(MSChart1.hwnd, WM_PAINT, Picture1.hDC, 0)
Picture1.Picture = Picture1.Image
Picture1.AutoRedraw = False
' Sent the picture to the clipboard.
Clipboard.Clear
Clipboard.SetData Picture1.Picture
' Save the picture on disk.
SavePicture Form1.Picture1.Picture, "c:\testpic.bmp"
End Sub
Private Sub Form_Load()
' Set our legends.
With MSChart1
.Plot.SeriesCollection.Item(1).LegendText = "Total Disk Space"
.Plot.SeriesCollection.Item(2).LegendText = "Used Disk Space"
End With
Picture1.Visible = False
End Sub
188006 BUG: EditCopy Incorrectly Copies Series Edge/Line Color of Chart
178076 HOWTO: Use a PictureBox to Control Orientation Printing a Form
Keywords: kbbug kbapi kbctrl kbpending kbcode KB197487