⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_28095.htm

📁 一些关于vc的问答
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<p>
序号:28095 发表者:雪花 发表日期:2003-01-17 19:29:58
<br>主题:请高手指点
<br>内容:我在非模态对话框类中想获得文档档的数据变量<BR><BR>使用指针方式CMyDoc *pDoc,在对话框类头文件中可以使用前向声明,如:<BR><BR>class CMyDoc;<BR>class CMyDlg<BR>{<BR>&nbsp;&nbsp;CStudentDlg::CStudentDlg(CView* pView,CMyDoc* pDoc);//增加CMyDoc*参数,构造时传入初始化成员m_pDoc。<BR>.........<BR><BR>&nbsp;&nbsp;CMyDoc* m_pDoc;<BR>};<BR>对话框类cpp文件中:(应包含文档类的头文件)<BR>CMyDlg::CMyDlg(CWnd* pParent,CMyDoc* pDoc)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_pDoc = pDoc;<BR>}<BR>BOOL CStudentDlg::Create()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return CDialog::Create(CStudentDlg::IDD);<BR>}<BR>建立非模态对话框:<BR>class CMyView<BR>{<BR>.....<BR><BR>CMyDlg *m_pDlg;<BR>.....<BR>}<BR>在MyView.cpp中<BR>void CMyView::OnBuld() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(m_pDlg-&gt;GetSafeHwnd()==0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pDlg-&gt;Create();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR>然后在对话框类cpp文件中调用m_pDoc无法通过编译,为什么?<BR>应该如何解决??????????<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:在水一方 回复日期:2003-01-17 19:35:59
<br>内容:在MyDlg.h中加入CMyDoc的头生明<BR>&nbsp;&nbsp;&nbsp;&nbsp;#include "mydoc.h"<BR>VC对类的前项声明如class CMyDoc一般是不认可的。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:雪花 回复日期:2003-01-17 20:04:42
<br>内容:我试过不行!!!<BR><BR>在MyDlg.h的头声明中加入#include"mydoc.h"编译无法通过!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:雪花 回复日期:2003-01-17 20:08:55
<br>内容:在MyDlg.h的头声明中加入#include"mydoc.h"<BR>然后如下:<BR>class CMyDlg<BR>{<BR>&nbsp;&nbsp;CMyDoc* m_pDoc;<BR>};<BR>编译无法通过!<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:在水一方 回复日期:2003-01-17 20:15:39
<br>内容:方便把你的Project传上来吗?俺替你把把脉:)
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:雪花 回复日期:2003-01-17 20:27:22
<br>内容:#if !defined(AFX_STUDENTDLG_H__06D62361_21A0_11D7_A020_0010DC73EFC7__INCLUDED_)<BR>#define AFX_STUDENTDLG_H__06D62361_21A0_11D7_A020_0010DC73EFC7__INCLUDED_<BR><BR>#if _MSC_VER &gt; 1000<BR>#pragma once<BR><BR>#endif // _MSC_VER &gt; 1000<BR>// StudentDlg.h : header file<BR>//<BR>#define WM_GOODBYE WM_USER+5<BR>#define WM_ADDLIST WM_USER+6<BR>extern CView * m_pView;<BR>#include "stdafx.h"<BR>#include "MyStudentDoc.h"<BR>#include "student.h"<BR>/////////////////////////////////////////////////////////////////////////////<BR>// CStudentDlg dialog<BR><BR>class CStudentDlg : public CDialog<BR>{<BR>// Construction<BR>protected:<BR>&nbsp;&nbsp;&nbsp;&nbsp;POSITION m_position;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudentList *m_pList;<BR><BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudentDlg(CWnd* pParent = NULL);&nbsp;&nbsp; // standard constructor<BR><BR>// Dialog Data<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA(CStudentDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;enum { IDD = IDD_DIALOG1 };<BR>&nbsp;&nbsp;&nbsp;&nbsp;float&nbsp;&nbsp;&nbsp;&nbsp;m_dlg_data;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CString&nbsp;&nbsp;&nbsp;&nbsp;m_dlg_name;<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_dlg_number;<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA<BR>//public:<BR>//&nbsp;&nbsp;&nbsp;&nbsp;CMyStudentDoc* GetDo();<BR><BR><BR>// Overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;// ClassWizard generated virtual function overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_VIRTUAL(CStudentDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;protected:<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void DoDataExchange(CDataExchange* pDX);&nbsp;&nbsp;&nbsp;&nbsp;// DDX/DDV support<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_VIRTUAL<BR><BR>// Implementation<BR>protected:<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// Generated message map functions<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG(CStudentDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void OnCancel();<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void OnOK();<BR>&nbsp;&nbsp;&nbsp;&nbsp;afx_msg void OnUserOut();<BR>&nbsp;&nbsp;&nbsp;&nbsp;afx_msg void OnAddNew();<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_MESSAGE_MAP()<BR><BR>private:<BR>//&nbsp;&nbsp;&nbsp;&nbsp;CView* m_pView;<BR><BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudentDlg(CView * pView);<BR>&nbsp;&nbsp;&nbsp;&nbsp;BOOL Create();<BR>&nbsp;&nbsp;&nbsp;&nbsp;CMyStudentDoc * m_pdoc;<BR>};<BR><BR>//{{AFX_INSERT_LOCATION}}<BR>// Microsoft Visual C++ will insert additional declarations immediately before the previous line.<BR><BR>#endif // !defined(AFX_STUDENTDLG_H__06D62361_21A0_11D7_A020_0010DC73EFC7__INCLUDED_)<BR><BR><BR><BR>// StudentDlg.cpp : implementation file<BR>//<BR><BR>#include "stdafx.h"<BR>#include "MyStudent.h"<BR>#include "StudentDlg.h"<BR>#include "MyStudentDoc.h"<BR>#ifdef _DEBUG<BR>#define new DEBUG_NEW<BR>#undef THIS_FILE<BR>static char THIS_FILE[] = __FILE__;<BR>#endif<BR>CView* m_pView;<BR>#include "Student.h"<BR>//CMyStudentDoc m_pDoc;<BR>/////////////////////////////////////////////////////////////////////////////<BR>// CStudentDlg dialog<BR><BR><BR>CStudentDlg::CStudentDlg(CWnd* pParent /*=NULL*/)<BR>&nbsp;&nbsp;&nbsp;&nbsp;: CDialog(CStudentDlg::IDD, pParent)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA_INIT(CStudentDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_pView=NULL;<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA_INIT<BR>}<BR><BR>CStudentDlg::CStudentDlg(CView* pView)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_pView=pView;<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_dlg_data = 0.0f;<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_dlg_name = _T("");<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_dlg_number = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_position=NULL;<BR>//&nbsp;&nbsp;&nbsp;&nbsp;m_pDoc=NULL;<BR>//&nbsp;&nbsp;&nbsp;&nbsp;m_pDOC=NULL;<BR>}<BR><BR>void CStudentDlg::DoDataExchange(CDataExchange* pDX)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDialog::DoDataExchange(pDX);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA_MAP(CStudentDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;DDX_Text(pDX, IDC_DATA, m_dlg_data);<BR>&nbsp;&nbsp;&nbsp;&nbsp;DDX_Text(pDX, IDC_NAME, m_dlg_name);<BR>&nbsp;&nbsp;&nbsp;&nbsp;DDX_Text(pDX, IDC_NUMBER, m_dlg_number);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA_MAP<BR>}<BR><BR>BOOL CStudentDlg::Create()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return CDialog::Create(CStudentDlg::IDD);<BR>}<BR><BR><BR><BR>BEGIN_MESSAGE_MAP(CStudentDlg, CDialog)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG_MAP(CStudentDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_BN_CLICKED(IDC_USER_OUT, OnUserOut)<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_BN_CLICKED(IDC_ADD_NEW, OnAddNew)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CStudentDlg message handlers<BR><BR>void CStudentDlg::OnCancel() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add extra cleanup here<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(m_pView!=NULL)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp; m_pView-&gt;PostMessage(WM_GOODBYE,IDCANCEL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDialog::OnCancel();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR><BR>void CStudentDlg::OnOK() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add extra validation here<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(m_pView!=NULL)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateData(TRUE);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pView-&gt;PostMessage(WM_GOODBYE,IDOK);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDialog::OnOK();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR><BR>void CStudentDlg::OnUserOut() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your control notification handler code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR>void CStudentDlg::OnAddNew() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your control notification handler code here<BR>//&nbsp;&nbsp;&nbsp;&nbsp;UpdateData(true);<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(UpdateData(TRUE))<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CStudent*pStudent=new CStudent;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pStudent-&gt;m_nGrade=m_dlg_data;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pStudent-&gt;m_strName=m_dlg_name;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_position = m_pList-&gt;InsertAfter(m_position, pStudent);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR><BR><BR><BR><BR>// MyStudentDoc.h : interface of the CMyStudentDoc class<BR>//<BR>/////////////////////////////////////////////////////////////////////////////<BR><BR>#if !defined(AFX_MYSTUDENTDOC_H__67F618AD_20E5_11D7_A020_0010DC73EFC7__INCLUDED_)<BR>#define AFX_MYSTUDENTDOC_H__67F618AD_20E5_11D7_A020_0010DC73EFC7__INCLUDED_<BR><BR>#if _MSC_VER &gt; 1000<BR>#pragma once<BR>#endif // _MSC_VER &gt; 1000<BR>#include "StudentDlg.h"<BR>#include "student.h"<BR>class CMyStudentDoc : public CDocument<BR>{<BR>protected: // create from serialization only<BR>&nbsp;&nbsp;&nbsp;&nbsp;CMyStudentDoc();<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_DYNCREATE(CMyStudentDoc)<BR><BR>// Attributes<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudentList* GetList()<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return &amp; m_studentList;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>// Operations<BR>public:<BR><BR>// Overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;// ClassWizard generated virtual function overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_VIRTUAL(CMyStudentDoc)<BR>&nbsp;&nbsp;&nbsp;&nbsp;public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual BOOL OnNewDocument();<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void Serialize(CArchive&amp; ar);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_VIRTUAL<BR><BR>// Implementation<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudent m_studentdlg;<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual ~CMyStudentDoc();<BR>#ifdef _DEBUG<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void AssertValid() const;<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void Dump(CDumpContext&amp; dc) const;<BR>#endif<BR><BR>protected:<BR><BR>// Generated message map functions<BR>protected:<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG(CMyStudentDoc)<BR>&nbsp;&nbsp;&nbsp;&nbsp;afx_msg void OnDelData();<BR>&nbsp;&nbsp;&nbsp;&nbsp;afx_msg void OnDisplayNet();<BR>&nbsp;&nbsp;&nbsp;&nbsp;afx_msg void OnDisplayNumber();<BR>&nbsp;&nbsp;&nbsp;&nbsp;afx_msg void OnDisplayUp();<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_MESSAGE_MAP()<BR>private:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudentList m_studentList;<BR>};<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR><BR>//{{AFX_INSERT_LOCATION}}<BR>// Microsoft Visual C++ will insert additional declarations immediately before the previous line.<BR><BR>#endif // !defined(AFX_MYSTUDENTDOC_H__67F618AD_20E5_11D7_A020_0010DC73EFC7__INCLUDED_)<BR><BR><BR><BR><BR>// MyStudentDoc.cpp : implementation of the CMyStudentDoc class<BR>//<BR><BR>#include "stdafx.h"<BR>#include "MyStudent.h"<BR>#include "StudentDlg.h"<BR>#include "MyStudentDoc.h"<BR><BR>#ifdef _DEBUG<BR>#define new DEBUG_NEW<BR>#undef THIS_FILE<BR>static char THIS_FILE[] = __FILE__;<BR>#endif<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CMyStudentDoc<BR><BR>IMPLEMENT_DYNCREATE(CMyStudentDoc, CDocument)<BR><BR>BEGIN_MESSAGE_MAP(CMyStudentDoc, CDocument)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG_MAP(CMyStudentDoc)<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_BN_CLICKED(IDC_DEL_DATA, OnDelData)<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_BN_CLICKED(IDC_DISPLAY_NET, OnDisplayNet)<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_BN_CLICKED(IDC_DISPLAY_NUMBER, OnDisplayNumber)<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_BN_CLICKED(IDC_DISPLAY_UP, OnDisplayUp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CMyStudentDoc construction/destruction<BR><BR>CMyStudentDoc::CMyStudentDoc()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: add one-time construction code here<BR><BR>}<BR><BR>CMyStudentDoc::~CMyStudentDoc()<BR>{<BR>}<BR><BR>BOOL CMyStudentDoc::OnNewDocument()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (!CDocument::OnNewDocument())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return FALSE;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: add reinitialization code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;// (SDI documents will reuse this document)<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;return TRUE;<BR>}<BR><BR><BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CMyStudentDoc serialization<BR><BR>void CMyStudentDoc::Serialize(CArchive&amp; ar)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (ar.IsStoring())<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// TODO: add storing code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// TODO: add loading code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CMyStudentDoc diagnostics<BR><BR>#ifdef _DEBUG<BR>void CMyStudentDoc::AssertValid() const<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDocument::AssertValid();<BR>}<BR><BR>void CMyStudentDoc::Dump(CDumpContext&amp; dc) const<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDocument::Dump(dc);<BR>}<BR>#endif //_DEBUG<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CMyStudentDoc commands<BR><BR><BR>void CMyStudentDoc::OnDelData() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your control notification handler code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR>void CMyStudentDoc::OnDisplayNet() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your control notification handler code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR>void CMyStudentDoc::OnDisplayNumber() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your control notification handler code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR>void CMyStudentDoc::OnDisplayUp() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your control notification handler code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR><BR><BR>// student.h<BR><BR>#ifndef _INSIDE_VISUAL_CPP_MYSTUDENT<BR>#define _INSIDE_VISUAL_CPP_MYSTUDENT<BR>//#include "stdafx.h"<BR>#include &lt;afxtempl.h&gt;<BR>class CStudent : public CObject<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_DYNAMIC(CStudent)<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;int m_number;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CString m_strName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;float m_nGrade;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudent()<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_nGrade = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_number = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudent(const char* szName, float nGrade) : m_strName(szName)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_nGrade = nGrade;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;CStudent(const CStudent&amp; s) : m_strName(s.m_strName)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// copy constructor<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_nGrade = s.m_nGrade;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;const CStudent&amp; operator =(const CStudent&amp; s)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_strName = s.m_strName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_nGrade = s.m_nGrade;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return *this;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;BOOL operator ==(const CStudent&amp; s) const<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((m_strName == s.m_strName) &amp;&amp; (m_nGrade == s.m_nGrade)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return TRUE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return FALSE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;BOOL operator !=(const CStudent&amp; s) const<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Let's make use of the operator we just defined!<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return !(*this == s);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>#ifdef _DEBUG<BR>&nbsp;&nbsp;&nbsp;&nbsp;void Dump(CDumpContext&amp; dc) const;<BR>#endif // _DEBUG<BR>};<BR><BR>typedef CTypedPtrList&lt;CObList, CStudent*&gt; CStudentList;<BR><BR>#endif // _INSIDE_VISUAL_CPP_STUDENT<BR><BR><BR>上面是我工程中的对话框类和文档类及自定义STUDENT类的内容!!!!!!<BR>请指教!!!!!!!!!!<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:雪花 回复日期:2003-01-17 20:29:24
<br>内容:提示的错误是<BR>studentdlg.h(65) : error C2143: syntax error : missing ';' before '*'<BR>studentdlg.h(65) : error C2501: 'CMyStudentDoc' : missing storage-class or type specifiers<BR>studentdlg.h(65) : error C2501: 'm_pdoc' : missing storage-class or type specifiers
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:tjhe 回复日期:2003-01-17 20:54:58
<br>内容:将工程打包贴上来吧,这样看不方便。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:雪花 回复日期:2003-01-17 21:32:13
<br>内容:thank!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -