我建了一个基于单文档的工程,然后单击工具条中一图标弹出一非模态对话框
想在此对话框中加入一视图显示,绘制一图表。来动态显示主视图区的相关操作。
我按照此方法添加。
1.创建CMDTestMyView类,从CView派生。
2.在对话框中
BOOL CMDTestPointsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CRuntimeClass* pClass=RUNTIME_CLASS(CMDTestMyView);
CMDTestMyView* pView=DYNAMIC_DOWNCAST(CMDTestMyView, pClass->CreateObject());
CRect rect;
GetClientRect(&rect);
pView->Create(NULL,NULL,WS_CHILD ¦WS_VISIBLE,CRect(0,0,rect.Width(),rect.Height()-40),this,100);
return TRUE;
// return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
可以正确显示,但是用鼠标点击对话框中的视图区域时,程序就会错,请问各位大侠,该如何解决。。
谢谢了。
想在此对话框中加入一视图显示,绘制一图表。来动态显示主视图区的相关操作。
我按照此方法添加。
1.创建CMDTestMyView类,从CView派生。
2.在对话框中
BOOL CMDTestPointsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CRuntimeClass* pClass=RUNTIME_CLASS(CMDTestMyView);
CMDTestMyView* pView=DYNAMIC_DOWNCAST(CMDTestMyView, pClass->CreateObject());
CRect rect;
GetClientRect(&rect);
pView->Create(NULL,NULL,WS_CHILD ¦WS_VISIBLE,CRect(0,0,rect.Width(),rect.Height()-40),this,100);
return TRUE;
// return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
可以正确显示,但是用鼠标点击对话框中的视图区域时,程序就会错,请问各位大侠,该如何解决。。
谢谢了。
1:直接在对话框上绘,2:自己做一窗口类也行.
class CDrawWnd : public CWnd
{
};
在对话框类定义
CDrawWnd m_DrawWnd;
在对话框的OnInitDialog()函数里
m_DrawWnd.Create();3:在对话框上放一Static文本控件
子类化CStatic
Public CDrawStatic : public CStatic
{}
响应WM_PAINT消息进行绘制就行了.