0
我在我的項目(Visual Studio 2015,MFC,C++)中使用了一個SmartGraph ActiveX控件。它已成功註冊。 我嘗試用這種控制,以適應一個對話框到的CFormViewC++無法在對話框CFormView中顯示ActiveX控件,控件變量爲NULL
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,並且顯示正確。 我做錯了什麼?
在「SmartGraph.h」中有兩個方法返回CreateControl(),但在作者的Demo Project中,他根本沒有使用這個方法。 –
我試過這種方法 - 調試斷言在occsite.cpp線faled 212號 –
Thew工作演示可能我們一個對話框模板是控制創建隱式在模板...無論如何,你需要創建的對象! – xMRi