Results 1 to 3 of 3

Thread: capture chart control

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    The Netherlands
    Posts
    12

    Question

    Can anyone tell me how I can capture a chart made by MSChart. I want to save the chart as a image to a file.

  2. #2
    Guest
    Code:
    Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    
    Private Sub Command1_Click()
            
        Dim hDC_Chart As Long
        
        Picture1.AutoRedraw = True
        hDC_Chart = GetWindowDC(MSChart1.hwnd)
        BitBlt Picture1.hDC, 0, 0, MSChart1.Width / Screen.TwipsPerPixelX, MSChart1.Height / Screen.TwipsPerPixelY, hDC_Chart, 0, 0, vbSrcCopy
        Picture1.Refresh
        Picture1 = Picture1.Image
        SavePicture Picture1, "C:\MyChart.bmp"
        
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    The Netherlands
    Posts
    12

    Smile chart

    Thanks for your code, I am going to try it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width