CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 17

Thread: C++ MFC MSChart

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Posts
    8

    C++ MFC MSChart

    I am a beginner in C++.
    I have tried to implement a chart from a MFC dialog box by using MSChart.
    I didn't find any tutorial to learn how to link data with a MSChart and how to handle basic implementation.
    Is it because MSChart is only used in VB?

    Thanks for any help

    Kropcheck...

  2. #2
    Join Date
    Apr 1999
    Posts
    3,585

    Re: C++ MFC MSChart

    Since MSChart is an ActiveX control, it can be used with any language that speaks COM, including C++. Take a look at this article . It should help get you started.
    Gort...Klaatu, Barada Nikto!

  3. #3
    Join Date
    Oct 2005
    Posts
    8

    Re: C++ MFC MSChart

    Thanks for this quick reply, it is always nice to get support by advance user.

    I have tried this tutorial (even before sending my first mail) which seems fairly simple but nevertheless I had a problem to access to the following function:

    m_Chart.SetChartData(saRet.Detach());

    "SetChartData" doesn't belong to the CChart class when "Refresh" is perfectly recognised.

    with -> class CChart : public CWnd
    -> CChart m_Chart;

    I went through all the class members/functions of m_Chart but none looks like "SetChartData" or BindData. There is probably more than one way to link data with the chart. I am not used to too much advance variable type but I am opened to any possibilities.

    Kropchek

    PS: By the way, the problem could come from the version of MSChart: Microsoft Chart 6.0 (SP4) OLEDB with Microsoft Visual Studio C++.NET 2002.

  4. #4
    Join Date
    Apr 1999
    Posts
    3,585

    Re: C++ MFC MSChart

    Have you followed the steps to add the chart object to your dialog? The object should be of type CMSChart, not CWnd.
    Gort...Klaatu, Barada Nikto!

  5. #5
    Join Date
    Oct 2005
    Posts
    8

    Re: C++ MFC MSChart

    I think I did a stupid mistake when I used the "Variable Wizard", by mistake I modified the "Variable type". So by default the Wizard created a CWnd type class instead of CMSChart.

    I hope now everything will go OK.
    More news in a few minutes.

    Thanks for your patience.

    Kropcheck... which thinks that these wizards are great but never trusts them even when no error appears.

  6. #6
    Join Date
    Oct 2005
    Posts
    8

    Re: C++ MFC MSChart

    Obviously the wizard which create the variable doesn't work properly.
    Each time I create a variable linked to the component ID_MSCHART, I end up with a new class derivated from CWnd and not CMSChart.

    I have tried to change manually "class CChart : public CWnd" to "class CChart : public CMSChart" but CMSChart is undefined as class.

    Should I import the library as "#include Mschart.h" somewhere or could it be a problem of .dll (which seems strange because I managed to add MSChart in the toolbox of component).

    Kropcheck

  7. #7
    Join Date
    Apr 2013
    Posts
    5

    Re: C++ MFC MSChart

    Did you make the wrapper for the class?

    Try to use:

    #import <msdatsrc.tlb> no_namespace
    #import <mschrt20.ocx> no_namespace

    Then make a member variable for the chart, via Resources Dialog Designer, by assigning the chart to the class wrapper, something like CDMSChart class.

    Cheers,

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

Featured