level 1
这也叫工程啊,
一个鼠标右击消息, 一个按钮命令消息, 显示一个对话框, 绘几个文字,搞定
2014年06月25日 09点06分
2
level 1
(3)调用对话框类 <?xml:namespace prefix="o" ns="urn:schemas-microsoft-com:office:office"></?xml:namespace>
首先在视图类的实现文件 TESTView.cpp 中添加对话框类头文件的包含命令:
#include "Input.h"
(注意,不能加在最前面,至少第三行或以后)
然后在文档类中添加一个公有的数据成员 total ,用于存放总分,并在文档类的OnNewDocument()中将其初始化为-1。
public:
double total;
最后编写 OnLButtonDown() 和 OnDraw() 函数。
…………………………………………………………
void CTESTView::OnDraw(CDC* pDC)
{ CTESTDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CString str;
if ( pDoc->total!=-1 )
{ str.Format(" 平均成绩: %.1f",pDoc->total/5);
pDC->TextOut(10,10,str);
str.Format(" 总 分: %.1f",pDoc->total);
pDC->TextOut(10,30,str);
}
}
…………………………………………………………
2014年06月30日 13点06分
4
level 1
void CTESTView::OnLButtonDown(UINT nFlags, CPoint point) <?xml:namespace prefix="o" ns="urn:schemas-microsoft-com:office:office"></?xml:namespace>
{
// TODO: Add your message handler code here and/or call default
CTESTDoc* pDoc=GetDocument();
CInput dlg;
if ( dlg.DoModal()==IDOK )
{ pDoc->total=dlg.m_English+dlg.m_Math+dlg.Chinese + dlg.m_Physics +dlg.m_Chemistry;
Invalidate();
}
CView::OnLButtonDown(nFlags, point);
}
2014年06月30日 13点06分
5