我在主框架类里,写了一个新建函数,分割窗口,
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if (!m_Splitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
} // add the first splitter pane - the default view in column 0
if (!m_Splitter.CreateView(0, 0,
RUNTIME_CLASS(CTree), CSize(200, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
} if (!m_Splitter.CreateView(0, 1,
RUNTIME_CLASS(CBsis19View), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
// activate the input view
SetActiveView((CView*)m_Splitter.GetPane(0,0)); return TRUE;
//return CFrameWnd::OnCreateClient(lpcs, pContext);
}
然后在view类里写了一个画直线函数
void draw()
{
CMainFrame* pMain;
CBsis19View p;
CDC* dc=pMain->m_Splitter.GetPane(0,1)->GetDC();
}
编译正确,运行,报错。
调试是 CDC* dc=pMain->m_Splitter.GetPane(0,1)->GetDC();
一句出错。。
大家给看看是什么问题呀。
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if (!m_Splitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
} // add the first splitter pane - the default view in column 0
if (!m_Splitter.CreateView(0, 0,
RUNTIME_CLASS(CTree), CSize(200, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
} if (!m_Splitter.CreateView(0, 1,
RUNTIME_CLASS(CBsis19View), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
// activate the input view
SetActiveView((CView*)m_Splitter.GetPane(0,0)); return TRUE;
//return CFrameWnd::OnCreateClient(lpcs, pContext);
}
然后在view类里写了一个画直线函数
void draw()
{
CMainFrame* pMain;
CBsis19View p;
CDC* dc=pMain->m_Splitter.GetPane(0,1)->GetDC();
}
编译正确,运行,报错。
调试是 CDC* dc=pMain->m_Splitter.GetPane(0,1)->GetDC();
一句出错。。
大家给看看是什么问题呀。
解决方案 »
- 发送消息到窗口报错 error C2664: “SendMessageW”: 不能将参数 1 从“CWnd *”转换为“HWND”
- MCI错误 无法在指定的MCI设备上播放指定的文件,文件可能已损坏或格式不对,或没有次格式的文件处理程序可用。
- 急问用DialogBoxParam()打开窗口,但是如何得到窗口中的控件的句柄呢?
- 用菜单打开对话框,显示不了
- 用什么工具可以把 软件中的图标 全部提取出来??
- 谁知道visualassist到哪里可以down?
- 如何在客户程序中调用自己编写的DLL库函数
- 在线等待 请大家帮帮忙在线等待 请大家帮帮忙在线等待 请大家帮帮忙在线等待 请大家帮帮忙在线等待 请大家帮帮忙在线等待 请大家帮帮忙在
- 一定给分:谁有潘爱民的<<COM原理与应用>>一书的所附的源程序,可否发一份给我?
- 如何对声音波形进行频谱分析?
- 国外不断推出先进的开发工具主要目的之一是让他国使用者逐渐远离底层技术而让他们不自觉地、情愿地永远被自己牵着鼻子走!
- 怎么使自己的程序 拷贝文件的速度 比windows快?
CBsis19View p;
CDC* dc=pMain->m_Splitter.GetPane(0,1)->GetDC();
pMain=????
pMain=DYNAMIC_DOWNCAST(CMainFrame,AfxGetMainWnd());
ASSERT_VALID(pMain);
if(NULL!=pMain)
{
...
}
很基础的问题
CBsis19View p;
CDC* dc=pMain->m_Splitter.GetPane(0,1)->GetDC();
呵呵。
void draw()
{
CMainFrame* pMain;
CBsis19View p;
CDC* dc=pMain->m_Splitter.GetPane(0,1)->GetDC();
}不推荐这么做。通常的做法是通过调用共同的Document的UpdateAllViews方法来通知其他视图。
参见
http://msdn.microsoft.com/library/en-us/vccore/html/_core_drawing_in_a_view.asp
http://msdn.microsoft.com/msdnmag/issues/04/05/CQA/
(CMainFrame*)AfxGetApp()->m_pMainWnd;
CNewClassDoc * pNewDoc;
pNewDoc = (CNewClassDoc * )pFrame->GetActiveDocument();
CView * pView;
pView = (CView*) pFrame->m_Splitter.GetPane(0,2);
pNewDoc->UpdateAllViews(pView);如此,调用对应view里的OnDraw函数了。
我是把窗口分成了,两个窗口,左边显示一个树型结构,右边显示,我在点击左边的结点时,要在右边画个东西,
现在是画成了。但是一拖动窗口就,刷没了。不知道应该怎么办呀。