现在我用MFC模板改了个模拟程序,显示小车运动,但是老师要求我在窗口中同时显示方向盘控制。开始我的程序是布满整个窗口的,但是现在他的意思是最好分割为两个窗口,一个显示小车运动,另外一个显示方向盘,如果控制方向盘能实时显示在小车运动的那个图中……
如上是我现在遇到的问题,由于刚刚接触MFC,在网上查了哈CSplitterWnd分割窗口,但是都有错,不晓得是不是操作问题,求各位大神帮哈忙指点指点
如上是我现在遇到的问题,由于刚刚接触MFC,在网上查了哈CSplitterWnd分割窗口,但是都有错,不晓得是不是操作问题,求各位大神帮哈忙指点指点
1.在CMainFrame里加入一个CSplitterWnd 类型的变量
2.Override the parent frame's CFrameWnd::OnCreateClient member function.
2.重写CFrameWnd::OnCreateClient member function
3.From within the overridden OnCreateClient, call the Create or CreateStatic member function of CSplitterWnd.
3.调用Create或者CreateStatic方法 of CSplitterWnd。已经贴了好几遍了~
就是不晓得咋用~
开始找OnCreateClient函数都没有找到,最后就直接粘贴上去的BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// CG: The following block was added by the Splitter Bar component.
{
if (!m_wndSplitter.Create(this,
1, 2, // TODO: adjust the number of rows, columns
CSize(10, 10), // TODO: adjust the minimum pane size
pContext))
{
TRACE0("Failed to create splitter bar ");
return FALSE; // failed to create
} return TRUE;
}
}这个是网上一个人说的,但是运行后什么都没有
只是下面多了个拖动条而已
int CXDKNMS1View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rect;
GetClientRect(&rect);
//获得窗口的创建信息指针
CCreateContext *pContext = (CCreateContext*) lpCreateStruct->lpCreateParams; //产生二次静态切分
m_wndSplitter2.CreateStatic(this,1, 2);
//为第一个窗格产生视图
m_wndSplitter2.CreateView(0,0,// 窗格的行、列序数
RUNTIME_CLASS(CleftFormView),//视图类
CSize(3*(rect.Width())/10,rect.Height()),//初始化大小
pContext);//父窗口的创建参数
//为第二个窗格产生视图
m_wndSplitter2.CreateView(0,1,
RUNTIME_CLASS(CrightMainView),
CSize(1,1),
pContext);
return 0;
// TODO: Add your specialized creation code here
}