现在我创建了一个全新的 SDI 项目,视图提供了一个函数:GetDocument(),它可以帮助我获取当前文档的数据
但是,当我调用 GetDocument() 函数时,VC 告诉我发生了一些错误:Debug Assertion Failed
以下是我的设置
class CHorse_programView : public CView
{
protected: // create from serialization only
CHorse_programView();
DECLARE_DYNCREATE(CHorse_programView)
// Attributes
public:
CHorse_programDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHorse_programView)
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 ~CHorse_programView();
CHorse_programDoc * GetDoc()
{
CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
return (CHorse_programDoc *) pFrame->GetActiveDocument();
}
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CHorse_programView)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
我想在这个函数中调用 GetDocument()
CHorse_programView::CHorse_programView()
{
GetDocument();
}
怎么了