本人菜鸟,请大神帮我看下以下这个程序怎么实现:
我是搞电气的,想在PCANVIEW这个软件上进行重新开发,主要实现功能就不说了!主要说下我的程序:
1、原程序是这个单文档的MFC程序,在CMainfram的OnCreate()中创建了一个CChildview(BASEVIEW为CViewlist),这个视根据
CAN总线收发来ID的状态位,把CAN总线的信号显示出来。源代码如下:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{ int iRet, nIndex; m_pwndView = new CChildView();
if (m_pwndView == NULL)
{
iRet = -1;
goto Exit;
} if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
{
iRet = -1;
goto Exit;
} //create a view to occupy the client area of the frame
if (m_pwndView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL) == FALSE)
{
TRACE0("Failed to create view window\n");
iRet = -1;
goto Exit;
} // create status bar
iRet = m_wndStatusBar.Create (this);
if (iRet == FALSE)
{
iRet = -1;
goto Exit;
} // set indicators to status bar
iRet = m_wndStatusBar.SetIndicators (aStlIndicators_l, MAX_INDICATOR_ENTRIES);
if (iRet == FALSE)
{
iRet = -1;
goto Exit;
} for (nIndex = 1; nIndex < MAX_INDICATOR_ENTRIES; nIndex++)
{
m_wndStatusBar.SetPaneStyle (nIndex, SBPS_DISABLED);
} m_pUsbCanModul = new CUcanIntf (this);
if (m_pUsbCanModul != NULL)
{
// initialiize USB-CANmodul
m_fInitOk = m_pUsbCanModul->Initialize (USBCAN_ANY_MODULE, USBCAN_BAUD_1MBit);
} iRet = 0;Exit:
return iRet;
}我的想法是把这个窗口分割为四块,把CChlidView内的功能能在分割后的第四个视内全部实现,这里我重载了OnCreateClient()函数,并对窗口进行了分割,如下代码;
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if ( m_CSplitter_left.CreateStatic(this, 1, 2) == NULL )
{
return FALSE;
}
m_CSplitter_left.CreateView(0, 0, RUNTIME_CLASS(CLeftview),
CSize(700, 700), pContext);
if ( m_CSplitter_down.CreateStatic(&m_CSplitter_left, 3, 1, WS_CHILD | WS_VISIBLE,
m_CSplitter_left.IdFromRowCol(0, 1) ) == NULL )
{
return FALSE;
}
m_CSplitter_down.CreateView(0, 0, RUNTIME_CLASS(CSendView),
CSize(100, 200), pContext);
m_CSplitter_down.CreateView(1, 0, RUNTIME_CLASS(CReceiveView),
CSize(100, 200), pContext);
m_CSplitter_down.CreateView(2, 0, RUNTIME_CLASS(CChildView),
CSize(100, 200), pContext);
m_CSplitter_left.SetRowInfo(0, 100, 0);
m_CSplitter_left.SetActivePane(0, 0, NULL);
m_CSplitter_state = TRUE;
return TRUE;
return CFrameWnd::OnCreateClient(lpcs, pContext);
}
后续我就不知道该怎么处理了,请各位大神指点下,(备注:我创建了单文档得程序,分割都是成功的,但是这个是改原来的结构,所以不知道怎么搞了),怎么处理OnCreate内的内容,主要想把原来的CChildView功能继承下来,只是原来是整个窗口显示,现在想在分割后的第四个区域内显示,请大神指教下!
敬拜!!!!!!!!!!!!!!!!!!!
我是搞电气的,想在PCANVIEW这个软件上进行重新开发,主要实现功能就不说了!主要说下我的程序:
1、原程序是这个单文档的MFC程序,在CMainfram的OnCreate()中创建了一个CChildview(BASEVIEW为CViewlist),这个视根据
CAN总线收发来ID的状态位,把CAN总线的信号显示出来。源代码如下:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{ int iRet, nIndex; m_pwndView = new CChildView();
if (m_pwndView == NULL)
{
iRet = -1;
goto Exit;
} if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
{
iRet = -1;
goto Exit;
} //create a view to occupy the client area of the frame
if (m_pwndView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL) == FALSE)
{
TRACE0("Failed to create view window\n");
iRet = -1;
goto Exit;
} // create status bar
iRet = m_wndStatusBar.Create (this);
if (iRet == FALSE)
{
iRet = -1;
goto Exit;
} // set indicators to status bar
iRet = m_wndStatusBar.SetIndicators (aStlIndicators_l, MAX_INDICATOR_ENTRIES);
if (iRet == FALSE)
{
iRet = -1;
goto Exit;
} for (nIndex = 1; nIndex < MAX_INDICATOR_ENTRIES; nIndex++)
{
m_wndStatusBar.SetPaneStyle (nIndex, SBPS_DISABLED);
} m_pUsbCanModul = new CUcanIntf (this);
if (m_pUsbCanModul != NULL)
{
// initialiize USB-CANmodul
m_fInitOk = m_pUsbCanModul->Initialize (USBCAN_ANY_MODULE, USBCAN_BAUD_1MBit);
} iRet = 0;Exit:
return iRet;
}我的想法是把这个窗口分割为四块,把CChlidView内的功能能在分割后的第四个视内全部实现,这里我重载了OnCreateClient()函数,并对窗口进行了分割,如下代码;
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if ( m_CSplitter_left.CreateStatic(this, 1, 2) == NULL )
{
return FALSE;
}
m_CSplitter_left.CreateView(0, 0, RUNTIME_CLASS(CLeftview),
CSize(700, 700), pContext);
if ( m_CSplitter_down.CreateStatic(&m_CSplitter_left, 3, 1, WS_CHILD | WS_VISIBLE,
m_CSplitter_left.IdFromRowCol(0, 1) ) == NULL )
{
return FALSE;
}
m_CSplitter_down.CreateView(0, 0, RUNTIME_CLASS(CSendView),
CSize(100, 200), pContext);
m_CSplitter_down.CreateView(1, 0, RUNTIME_CLASS(CReceiveView),
CSize(100, 200), pContext);
m_CSplitter_down.CreateView(2, 0, RUNTIME_CLASS(CChildView),
CSize(100, 200), pContext);
m_CSplitter_left.SetRowInfo(0, 100, 0);
m_CSplitter_left.SetActivePane(0, 0, NULL);
m_CSplitter_state = TRUE;
return TRUE;
return CFrameWnd::OnCreateClient(lpcs, pContext);
}
后续我就不知道该怎么处理了,请各位大神指点下,(备注:我创建了单文档得程序,分割都是成功的,但是这个是改原来的结构,所以不知道怎么搞了),怎么处理OnCreate内的内容,主要想把原来的CChildView功能继承下来,只是原来是整个窗口显示,现在想在分割后的第四个区域内显示,请大神指教下!
敬拜!!!!!!!!!!!!!!!!!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货