【发布时间】:2018-01-01 11:30:05
【问题描述】:
我在我的项目(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 并且正确显示。 我做错了什么?
【问题讨论】:
标签: c++ null mfc activex cview