none
How to plot line chart with Real-time data at Dialog-base application? RRS feed

  • Question

  • Hi, Sir:

    I would like to create MFC Dialog-base application for ploting realtime data

    I found many free sample code from website, like "Draw or display Real-time data plot Chart"
    ,"Simple Real-time Class for Advanced Charts and Plotting", it is good for ploting.

    But they are all base Doc/View, not Dialog-base

    I download source code from "Draw or display Real-time data plot Chart"
    But it is fail to run "Create" function

    How to modify code to match my necessary?

    ((CButton *)GetDlgItem(IDC_CHART_REALTIME))->GetClientRect(&clientRect); // IDC_CHART_REALTIME is Picture Control
    m_Plot.Create(WS_VISIBLE, clientRect, this, 12000, TRUE);

    BOOL clPlot::Create(DWORD dwstyle, CRect &rect, CWnd *pParent, UINT id)
    {
     DWORD style = dwstyle & (~WS_BORDER);
     if(dwstyle & WS_BORDER)
      m_bctlBorder=TRUE;
     else
      m_bctlBorder=FALSE;

     if (!CWnd::Create(NULL, "", style, rect, pParent, id, NULL))
      return FALSE;
     
     m_ctlRect = rect;
     pParent->ClientToScreen(m_ctlRect);
     ScreenToClient(m_ctlRect);

     ComputeRects(TRUE);
     return TRUE;
    }

    void clPlot::ComputeRects(BOOL bInitialization)
    {
     CClientDC dc(this);
     ...
    }

    void clPlot::OnPaint()
    {
            CPaintDC dc(this); // device context for painting
     ...
    }
    void clPlot::MoveWindow(CRect & Rect)
    {
     m_ctlRect = Rect;
     GetParent()->ClientToScreen(m_ctlRect);
     ScreenToClient(m_ctlRect);
     ComputeRects(TRUE);
     CWnd::MoveWindow(Rect);
    }


    ps:
    Simple Real-time Class for Advanced Charts and Plotting:
    http://www.codeguru.com/cpp/controls/controls/chartingandanaloguecontrols/article.php/c2223/Simple-Realtime-Class-for-Advanced-Charts-and-Plotting.htm
    Draw or display Real-time data plot Chart:
    http://www.ucancode.net/Visual_C_MFC_Samples/Draw_Display_Real_Time_data_Plot_Chart_vc_example.htm

    Thanks!!!

    BR,
    Alan

    Thursday, June 4, 2015 1:56 AM

Answers

  • Hi alan.emc,

    I have downloaded that sample - Draw or display Real-time data plot Chart. And it works well after I resolved some dependency issue.

    So What do you mean it is fail on "create" function? Does the function didn't get invoked or one line code in that function fails? What error message do you get?Please explain more details.

    I try to make the real- time data plot chart display on a dialog, so I create a MFC dialog based project. Copy the code in demoview.cpp to my dialog class cpp file(add clPlot m_Plot, OnTimer, Onsize OnEraseBkgnd) , and add refencence to clPlot project. check this screenshot:

    Hope this helps some.

    Shu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Shu 2017 Friday, June 5, 2015 6:03 AM
    • Marked as answer by Shu 2017 Tuesday, June 16, 2015 12:12 PM
    Friday, June 5, 2015 3:37 AM

All replies

  • Hi alan.emc,

    I have downloaded that sample - Draw or display Real-time data plot Chart. And it works well after I resolved some dependency issue.

    So What do you mean it is fail on "create" function? Does the function didn't get invoked or one line code in that function fails? What error message do you get?Please explain more details.

    I try to make the real- time data plot chart display on a dialog, so I create a MFC dialog based project. Copy the code in demoview.cpp to my dialog class cpp file(add clPlot m_Plot, OnTimer, Onsize OnEraseBkgnd) , and add refencence to clPlot project. check this screenshot:

    Hope this helps some.

    Shu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Shu 2017 Friday, June 5, 2015 6:03 AM
    • Marked as answer by Shu 2017 Tuesday, June 16, 2015 12:12 PM
    Friday, June 5, 2015 3:37 AM
  • I have same issue when built in release mode. May I know what you change to make it run in release mode? Thanks
    Thursday, November 30, 2017 8:25 AM