以下是引用筱筱2022在2022-9-7 10:51:32的发言:
class CNELFormView : public CRCMFormView
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) //初始化工作
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_pAboutView=(CAboutView*)RUNTIME_CLASS(CAboutView)->CreateObject();
if(!m_pAboutView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_LAST))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
//m_pAboutView->ShowWindow(SW_HIDE);
//m_pCurrentWnd = m_pAboutView;
m_pOldWnd = NULL;
#if defined(BUILD_RCP9) || defined(BUILD_RCP6)
m_pRCPView = (CRCPFormView*)RUNTIME_CLASS(CRCPFormView)->CreateObject();
if(!m_pRCPView->Create(CRect(0, 0, 0, 0), this))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pCurrentWnd = m_pRCPView;
#elif defined(BUILD_RCM6)
m_pRCRView = (CRCRFormView*)RUNTIME_CLASS(CRCRFormView)->CreateObject();
if(!m_pRCRView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST + 20))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pRCRView->ShowWindow(SW_HIDE);
m_pNELView=(CNELFormView*)RUNTIME_CLASS(CNELFormView)->CreateObject();
if(!m_pNELView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST + 26))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pNELView->ShowWindow(SW_HIDE);
m_pRCMView=(CRCMFormView*)RUNTIME_CLASS(CRCMFormView)->CreateObject();
if(!m_pRCMView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST + 10))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pRCMView->ShowWindow(SW_HIDE);
m_pStartView = (CStartFormView*)RUNTIME_CLASS(CStartFormView)->CreateObject();
if(!m_pStartView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pCurrentWnd = m_pStartView;
#elif defined(BUILD_RCMP6)
m_pRCPView = (CRCPFormView*)RUNTIME_CLASS(CRCPFormView)->CreateObject();
if(!m_pRCPView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST + 21))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pRCPView->ShowWindow(SW_HIDE);
m_pRCRView = (CRCRFormView*)RUNTIME_CLASS(CRCRFormView)->CreateObject();
if(!m_pRCRView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST + 20))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pRCRView->ShowWindow(SW_HIDE);
m_pNELView=(CNELFormView*)RUNTIME_CLASS(CNELFormView)->CreateObject(); //202208
if(!m_pNELView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST + 22))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pNELView->ShowWindow(SW_HIDE);
m_pRCMView=(CRCMFormView*)RUNTIME_CLASS(CRCMFormView)->CreateObject();
if(!m_pRCMView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST + 10))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pRCMView->ShowWindow(SW_HIDE);
m_pStartView = (CStartFormView*)RUNTIME_CLASS(CStartFormView)->CreateObject();
if(!m_pStartView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pCurrentWnd = m_pStartView;
#endif
// 创建一个视图以占用框架的工作区
//if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
// CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
//{
// TRACE0("未能创建视图窗口\n");
// return -1;
//}
#ifdef WIN32_PLATFORM_PSPC
if (!m_wndCommandBar.Create(this) ||
!m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
!m_wndCommandBar.AddAdornments(dwAdornmentFlags) ||
!m_wndCommandBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("未能创建 CommandBar\n");
return -1; // 未能创建
}
m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() | CBRS_SIZE_FIXED);
#endif // WIN32_PLATFORM_PSPC
#if !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)
if (!m_wndCommandBar.Create(this) ||
!m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
!m_wndCommandBar.InsertSeparator() ||
!m_wndCommandBar.LoadToolBar(IDR_MAINFRAME) ||
!m_wndCommandBar.AddAdornments(dwAdornmentFlags))
{
TRACE0("未能创建 CommandBar\n");
return -1; // 未能创建
}
m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() | CBRS_SIZE_FIXED);
#endif // !WIN32_PLATFORM_PSPC && !WIN32_PLATFORM_WFSP
m_wndCommandBar.Show(FALSE);
return 0;
}
BOOL CRCMFormView::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类
if(!CFormView::Create(NULL,NULL, AFX_WS_DEFAULT_VIEW,rect, pParentWnd, nID, pContext)) {
return FALSE;
}
CTabCtrl *pTabWnd = (CTabCtrl*)((CDialog*)(this))->GetDlgItem(IDC_TAB_WND);
TC_ITEM ti;
ti.mask = TCIF_TEXT;
ti.pszText = _T("监控面板"); //插入新的标签控件
pTabWnd->InsertItem(0,&ti);
LPTSTR g_sTabs[] = {
_T("组一曲线"),
_T("组二曲线"),
_T("组三曲线")
};
for(int i = 1; i <= MAX_GROUP_NUMBER; i++) {
ti.pszText =g_sTabs1];
pTabWnd->InsertItem(i,&ti);
}
ti.pszText = _T("数据报表");
pTabWnd->InsertItem(MAX_GROUP_NUMBER + 1,&ti);
if(!m_Sheet.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CRect(),pTabWnd,99)) {
return FALSE;
}
m_Sheet.ShowWindow(SW_HIDE);
LPTSTR g_sTitles[] = {
_T("电流-时间曲线(组Ⅰ)"),
_T("电流-时间曲线(组Ⅱ)"),
_T("电流-时间曲线(组Ⅲ)")
};
for(int i = 0; i < MAX_GROUP_NUMBER; i++) {
m_Graph.Create(pTabWnd,CRect(0,0,0,0),100+i,WS_VISIBLE);
m_Graph.SetBackColor(RGB(245,245,245));
m_Graph.GetLegend()->SetVisible(true);
m_Graph.GetLegend()->SetFont(100,_T("黑体"));
m_Graph.GetTitle()->AddString(g_sTitles);
m_Graph.GetTitle()->SetFont(140,_T("黑体"));
m_Graph.ShowWindow(SW_HIDE);
CChartAxis* pAxisB = m_Graph.GetBottomAxis();
pAxisB->SetAutomatic(true);
//pAxisB->SetMinMax(0,500);
pAxisB->SetFont(100,_T("黑体"));
CChartAxis* pAxisL = m_Graph.GetLeftAxis();
pAxisL->SetAutomatic(true);
//pAxisL->SetMinMax(0,20);
pAxisL->SetFont(100,_T("黑体"));
//int NumberPoints = 500;
//double XValues[500];
//double YValues[500];
//for (int j = 0 ; j< NumberPoints ; j++)
//{
// XValues[j] = j;//XStart + i * Step;
// YValues[j] = 10 * (1+sin( 3.141592/180 * (j%360) ));
//}
CChartSerie* pSerie1 = m_Graph.AddSerie(0);
CChartSerie* pSerie2 = m_Graph.AddSerie(0);
CChartSerie* pSerie3 = m_Graph.AddSerie(0);
pSerie1->SetName(_T("试件①"));
pSerie2->SetName(_T("试件②"));
pSerie3->SetName(_T("试件③"));
//pSeries->SetPoints(XValues,YValues,NumberPoints);
}
if(!m_Grid.CreateGrid(WS_CHILD,CRect(0,0,0,0),pTabWnd,100 + MAX_GROUP_NUMBER)) {
return FALSE;
}
m_Grid.Invalidate();
m_Grid.ShowWindow(SW_HIDE);
m_pUpdateThread = AfxBeginThread(UpdateThread,this);
m_pExportThread = AfxBeginThread(ExportThread,this);
m_brBK.CreateSolidBrush(RGB(245,239,207));
return TRUE;
//return CFormView::Create(lpszClassName, lpszWindo ...
if(!m_pNELView->Create(CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST + 26))
{
TRACE0("未能创建视图窗口\n");
return -1;
}
m_pNELView->ShowWindow(SW_HIDE);
无论有没有此代码段都可正常生成可执行文件 但是将其拷贝到设备上时打不开此文件 将这段代码注释之后设备可打开可执行文件 但nel功能不可使用
CRCRFormView *m_pRCRView;
CNELFormView *m_pNELView;
CNELFormView、 CRCRFormView皆继承于CRCMFormView
m_pNELView->Create、m_pRCRView->Create皆调用的是BOOL CRCMFormView::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)函数
m_pRCRView->Create调用是没问题的