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

📄 subject_59516.htm

📁 vc
💻 HTM
字号:
<p>
序号:59516 发表者:badboy 发表日期:2003-11-08 11:16:28
<br>主题:大家帮我看看人家的源代码是怎么做出来的?谢谢!!
<br>内容:我这里有个用VC做出来的MFC程序,我打开工程文件,可以看到有这么几个类 CAboutDlg CCleanDlg CClientSocket CListeningSocket CMainFrame CMessage CServerApp CServerDoc CServerView<BR>通过这几个类,应该可以判断应该是用应用程序向导做出来的单文挡应用程序。可是当我自己用向导做的,和他们的源代码不太一样。比如,我列出他们其中的一个类的头文件和执行文件的源代码在下面。<BR>&nbsp;&nbsp;&nbsp;&nbsp;我自己用应用程序向导做出来的代码和他们的源代码的不同主要如下:(好象就这两处不太一样)<BR>1、<BR>#if !defined(AFX_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_)<BR>#define AFX_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_<BR><BR>#if _MSC_VER &gt; 1000<BR>#pragma once<BR>#endif // _MSC_VER &gt; 1000<BR>&nbsp;&nbsp;&nbsp;&nbsp;上面这些语句他们每个类的头文件中都没有,而我的几个类(有CServerApp CServerDoc CServerView CMainFrame)的头文件的开始处都有?请问这些语句是干什么用的?他们的源文件没有是不是给删除了?<BR>2、<BR>//{{AFX_INSERT_LOCATION}}<BR>// Microsoft Visual C++ will insert additional declarations immediately before the previous line.<BR><BR>#endif // !defined(AFX_MAINFRM_H__F1C64827_4086_4020_A1C3_BCD3B40CAB1B__INCLUDED_)<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;上面的这些语句他们同样没有,我的类(CServerApp CServerDoc CServerView CMainFrame)同样都有?<BR><BR>??<BR><BR><BR><BR><BR>// dfs.h : main header file for the DFS application<BR>//<BR><BR>#if !defined(AFX_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_)<BR>#define AFX_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_<BR><BR>#if _MSC_VER &gt; 1000<BR>#pragma once<BR>#endif // _MSC_VER &gt; 1000<BR><BR>#ifndef __AFXWIN_H__<BR>&nbsp;&nbsp;&nbsp;&nbsp;#error include 'stdafx.h' before including this file for PCH<BR>#endif<BR><BR>#include &#34;resource.h&#34;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // main symbols<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CDfsApp:<BR>// See dfs.cpp for the implementation of this class<BR>//<BR><BR>class CDfsApp : public CWinApp<BR>{<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDfsApp();<BR><BR>// Overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;// ClassWizard generated virtual function overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_VIRTUAL(CDfsApp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual BOOL InitInstance();<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_VIRTUAL<BR><BR>// Implementation<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG(CDfsApp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;afx_msg void OnAppAbout();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// NOTE - the ClassWizard will add and remove member functions here.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;DO NOT EDIT what you see in these blocks of generated code !<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_MESSAGE_MAP()<BR>};<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_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_)<BR><BR><BR><BR>// chatsrvr.cpp : Defines the class behaviors for the application.<BR>//<BR>// This is a part of the Microsoft Foundation Classes C++ library.<BR>// Copyright (C) 1992-1997 Microsoft Corporation<BR>// All rights reserved.<BR>//<BR>// This source code is only intended as a supplement to the<BR>// Microsoft Foundation Classes Reference and related<BR>// electronic documentation provided with the library.<BR>// See these sources for detailed information regarding the<BR>// Microsoft Foundation Classes product.<BR><BR>#include &#34;stdafx.h&#34;<BR>#include &#34;chatsrvr.h&#34;<BR><BR>#include &#34;mainfrm.h&#34;<BR>#include &#34;srvrdoc.h&#34;<BR>#include &#34;srvrvw.h&#34;<BR><BR>#ifdef _DEBUG<BR>#undef THIS_FILE<BR>static char BASED_CODE THIS_FILE[] = __FILE__;<BR>#endif<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CServerApp<BR><BR>BEGIN_MESSAGE_MAP(CServerApp, CWinApp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG_MAP(CServerApp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_COMMAND(ID_APP_ABOUT, OnAppAbout)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// NOTE - the ClassWizard will add and remove mapping macros here.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;DO NOT EDIT what you see in these blocks of generated code!<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG_MAP<BR>&nbsp;&nbsp;&nbsp;&nbsp;// Standard file based document commands<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)<BR>&nbsp;&nbsp;&nbsp;&nbsp;ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)<BR>END_MESSAGE_MAP()<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CServerApp construction<BR><BR>CServerApp::CServerApp()<BR>{<BR>}<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// The one and only CServerApp object<BR><BR>CServerApp theApp;<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CServerApp initialization<BR><BR>BOOL CServerApp::InitInstance()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (!AfxSocketInit())<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(IDP_SOCKETS_INIT_FAILED);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return FALSE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;// Standard initialization<BR>&nbsp;&nbsp;&nbsp;&nbsp;// If you are not using these features and wish to reduce the size<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;of your final executable, you should remove from the following<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;the specific initialization routines you do not need.<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// Initialize static members of CSocketThread<BR><BR>#ifdef _WIN32<BR>&nbsp;&nbsp;&nbsp;&nbsp;Enable3dControls();<BR>#endif<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;LoadStdProfileSettings();&nbsp;&nbsp;// Load standard INI file options (including MRU)<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// Register the application's document templates.&nbsp;&nbsp;Document templates<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;serve as the connection between documents, frame windows and views.<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;CSingleDocTemplate* pDocTemplate;<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDocTemplate = new CSingleDocTemplate(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IDR_MAINFRAME,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RUNTIME_CLASS(CServerDoc),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RUNTIME_CLASS(CMainFrame),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // main SDI frame window<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RUNTIME_CLASS(CServerView));<BR>&nbsp;&nbsp;&nbsp;&nbsp;AddDocTemplate(pDocTemplate);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Parse command line for standard shell commands, DDE, file open<BR>&nbsp;&nbsp;&nbsp;&nbsp;CCommandLineInfo cmdInfo;<BR>&nbsp;&nbsp;&nbsp;&nbsp;ParseCommandLine(cmdInfo);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// Dispatch commands specified on the command line<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (!ProcessShellCommand(cmdInfo))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return FALSE;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// The one and only window has been initialized, so show and update it.<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_pMainWnd-&gt;SetIcon(LoadIcon(IDR_MAINFRAME), FALSE);<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_pMainWnd-&gt;ShowWindow(SW_HIDE);<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_pMainWnd-&gt;CenterWindow(NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_pMainWnd-&gt;UpdateWindow();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// create a new (empty) document<BR>&nbsp;&nbsp;&nbsp;&nbsp;//OnFileNew();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;return TRUE;<BR>}<BR><BR>int CServerApp::ExitInstance() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return CWinApp::ExitInstance();<BR>}<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CAboutDlg dialog used for App About<BR><BR>class CAboutDlg : public CDialog<BR>{<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CAboutDlg();<BR><BR>// Dialog Data<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;enum { IDD = IDD_ABOUTBOX };<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA<BR><BR>// Implementation<BR>protected:<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void DoDataExchange(CDataExchange* pDX);&nbsp;&nbsp;&nbsp;&nbsp;// DDX/DDV support<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// No message handlers<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_MESSAGE_MAP()<BR>};<BR><BR>CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA_INIT(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA_INIT<BR>}<BR><BR>void CAboutDlg::DoDataExchange(CDataExchange* pDX)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDialog::DoDataExchange(pDX);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA_MAP(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA_MAP<BR>}<BR><BR>BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG_MAP(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// No message handlers<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()<BR><BR>// App command to run the dialog<BR>void CServerApp::OnAppAbout()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CAboutDlg aboutDlg;<BR>&nbsp;&nbsp;&nbsp;&nbsp;aboutDlg.DoModal();<BR>}<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-11-08 11:30:28
<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>
<font color=red>答案被接受</font><br>回复者:michael 回复日期:2003-11-08 12:03:34
<br>内容:&nbsp;&nbsp;&nbsp;&nbsp;#if !defined(AFX_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_)<BR>#define AFX_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;这是用来标是文件的唯一性的,那一大串数是一个全局唯一标识符。一般来说,VC帮助生成的文件里都带这个。<BR>_MSC_VER 表示C++编译器的版本&gt;1000表示是VC++6.0的编译器<BR>#pragma once这是预编译指令,表示告诉编译器这个文件只编译一次。<BR>&nbsp;&nbsp;&nbsp;&nbsp;如果文件里没有,那就表示可能这个文件是用记事本手工建立的。再加到VC里来的。其实这些东东没有也没什么大不了的。一般不会对工程造成什么影响。但也不排除手工删除的可能,但是如果是我,我肯定不删,别人绑自己做了好事,我干吗还不领情呢?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:iwill 回复日期:2003-11-08 12:06:14
<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>
回复者:badboy 回复日期:2003-11-08 13:33:18
<br>内容:michael&nbsp;&nbsp;兄真是令人感激涕零!<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

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