关于“MyHello应用程序”的问题?
因为下学期要学VC++,所以现在假期有时间就先预习了,谁知道看到第一章的试个最简单的程序都没弄出来,因为是照书打的,不过我打不出来的是因为书上说这个程序是“填空式”的,然而我不太清楚要填在哪,书上也没介绍清楚,所以就在这里提问咯,大家请别见怪哦。
// MyHello2View.h : interface of the CMyHello2View class
//
/////////////////////////////////////////////////////////////////////////////
void CMyHelloView::OnDraw(CDC*pDC)
{
CMyHelloDoc*pDoc=GetDocument();
ASSERT_VALID(pDoc);
//TODO:add draw code for native data here
pDC->TextOut(100,80,"Hello,我们开始VC++编程了!");
}
#if !defined(AFX_MYHELLO2VIEW_H__9A50B4C3_EF6B_4139_9983_4F8137A6098F__INCLUDED_)
#define AFX_MYHELLO2VIEW_H__9A50B4C3_EF6B_4139_9983_4F8137A6098F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMyHello2View : public CView
{
protected: // create from serialization only
CMyHello2View();
DECLARE_DYNCREATE(CMyHello2View)
// Attributes
public:
CMyHello2Doc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyHello2View)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMyHello2View();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMyHello2View)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in MyHello2View.cpp
inline CMyHello2Doc* CMyHello2View::GetDocument()
{ return (CMyHello2Doc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYHELLO2VIEW_H__9A50B4C3_EF6B_4139_9983_4F8137A6098F__INCLUDED_)
以上这程序是我已经填好的了,不过有错误,我查了代码,好像没有吧,请看下段这段代码是要填上去的:
void CMyHelloView::OnDraw(CDC*pDC)
{
CMyHelloDoc*pDoc=GetDocument();
ASSERT_VALID(pDoc);
//TODO:add draw code for native data here
pDC->TextOut(100,80,"Hello,我们开始VC++编程了!");
}
再看下面这段是没填上的在CMyHello2View窗口里的(也就是还没填上一段程序的代码):
// MyHello2View.h : interface of the CMyHello2View class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MYHELLO2VIEW_H__9A50B4C3_EF6B_4139_9983_4F8137A6098F__INCLUDED_)
#define AFX_MYHELLO2VIEW_H__9A50B4C3_EF6B_4139_9983_4F8137A6098F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMyHello2View : public CView
{
protected: // create from serialization only
CMyHello2View();
DECLARE_DYNCREATE(CMyHello2View)
// Attributes
public:
CMyHello2Doc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyHello2View)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMyHello2View();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMyHello2View)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in MyHello2View.cpp
inline CMyHello2Doc* CMyHello2View::GetDocument()
{ return (CMyHello2Doc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYHELLO2VIEW_H__9A50B4C3_EF6B_4139_9983_4F8137A6098F__INCLUDED_)