0

我在我的项目(Visual Studio 2015、MFC、C++)中使用了SmartGraph ActiveX 控件。它已成功注册。我尝试将带有此控件的对话框放入 CFormView

MyAppView.h:

#pragma once
#include "SmartGraph.h"
#include "afxwin.h"

class CMyAppView : public CFormView
{
protected: // create from serialization only
    CMyAppView();
    DECLARE_DYNCREATE(CMyAppView)

    enum { IDD = IDD_DIALOG1 };

    CSmartGraph m_Graph; //!!!!! ActiveX control variable
    CButton m_ctrlOK;
....
}

MyAppView.cpp:

....

void CMyAppView::DoDataExchange(CDataExchange* pDX)
{
    CFormView::DoDataExchange(pDX);
    DDX_Control(pDX, IDOK, m_ctrlOK);
    DDX_Control(pDX, IDC_SMARTGRAPH1, m_Graph);
}

void CMyAppView::OnInitialUpdate()
{
    CFormView::OnInitialUpdate();
    ResizeParentToFit();

    m_Graph.SetParentWnd(this->m_hWnd);
    m_Graph.SetPlotType(0);
    m_Graph.put_xLable(_T("Time"));
    m_Graph.put_yLable(_T("Amplitude"));
    m_Graph.put_Title(_T("Graph Test"));
}
...

因此 m_Graph 为 NULL 并且 SmartGraph 不会显示在对话框中。同时 OK 按钮变量不是 NULL 并且显示正确。我做错了什么?

4

1 回答 1

0

您需要创建此对象的实例。m_Graph.CreateControl(...);

于 2017-07-26T09:11:34.163 回答