?
Solved

save MSCHART as a gif or bmp

Posted on 2003-03-21
4
Medium Priority
?
672 Views
Last Modified: 2013-11-19
I would like to know the best way to save an MSChart in VB6 as a gif or bmp file?
0
Comment
Question by:ginag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 200 total points
ID: 8184192
in a form:


Option Explicit
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 Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long

Private Sub Form_Click()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Me.AutoRedraw = True
    EnumChildWindows Me.hwnd, AddressOf EnumChildProc, ByVal 0&
    With Picture1
        .Width = MSChart1.Width
        .Height = MSChart1.Height
        BitBlt .hDC, 0, 0, .Width, .Height, GetWindowDC(hwndChart), 0, 0, vbSrcCopy
        SavePicture .Image, "c:\mychart.bmp"
    End With
End Sub


'In a module:
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Public hwndChart As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
    Dim sSave As String, ret As Long
    'Get the windowtext length
    sSave = Space$(255)
    ret = GetClassName(hwnd, sSave, 255)
    'remove the last Chr$(0)
    sSave = Left$(sSave, InStr(1, sSave, Chr$(0), vbTextCompare) - 1)
    Debug.Print Chr$(34) & sSave & Chr$(34)
    If sSave = "MSChart20WndClass" Then hwndChart = hwnd
    'continue enumeration
    EnumChildProc = 1
End Function
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8184199
better:

Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
   Dim sSave As String, ret As Long
      sSave = Space$(255)
   ret = GetClassName(hwnd, sSave, 255)
   'remove the last Chr$(0)
   sSave = Left$(sSave, ret)
   If sSave = "MSChart20WndClass" Then hwndChart = hwnd
   'continue enumeration
   EnumChildProc = 1
End Function
0
 

Author Comment

by:ginag
ID: 8184349
Thanks very much for the complete input.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8186613
Glad to Help.Thanks for "A" grade.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Learn how to download your full Prezi presentation for offline presenting. Prezi doesn’t have to be viewed and shared in a web browser, even with a free account you can download your full presentation to share with others. Be sure to download any vi…
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question