📄 subject_59516.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> 我自己用应用程序向导做出来的代码和他们的源代码的不同主要如下:(好象就这两处不太一样)<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 > 1000<BR>#pragma once<BR>#endif // _MSC_VER > 1000<BR> 上面这些语句他们每个类的头文件中都没有,而我的几个类(有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> 上面的这些语句他们同样没有,我的类(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 > 1000<BR>#pragma once<BR>#endif // _MSC_VER > 1000<BR><BR>#ifndef __AFXWIN_H__<BR> #error include 'stdafx.h' before including this file for PCH<BR>#endif<BR><BR>#include "resource.h" // 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> CDfsApp();<BR><BR>// Overrides<BR> // ClassWizard generated virtual function overrides<BR> //{{AFX_VIRTUAL(CDfsApp)<BR> public:<BR> virtual BOOL InitInstance();<BR> //}}AFX_VIRTUAL<BR><BR>// Implementation<BR> //{{AFX_MSG(CDfsApp)<BR> afx_msg void OnAppAbout();<BR> // NOTE - the ClassWizard will add and remove member functions here.<BR> // DO NOT EDIT what you see in these blocks of generated code !<BR> //}}AFX_MSG<BR> 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 "stdafx.h"<BR>#include "chatsrvr.h"<BR><BR>#include "mainfrm.h"<BR>#include "srvrdoc.h"<BR>#include "srvrvw.h"<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> //{{AFX_MSG_MAP(CServerApp)<BR> ON_COMMAND(ID_APP_ABOUT, OnAppAbout)<BR> // NOTE - the ClassWizard will add and remove mapping macros here.<BR> // DO NOT EDIT what you see in these blocks of generated code!<BR> //}}AFX_MSG_MAP<BR> // Standard file based document commands<BR> ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)<BR> 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> if (!AfxSocketInit())<BR> {<BR> AfxMessageBox(IDP_SOCKETS_INIT_FAILED);<BR> return FALSE;<BR> }<BR> <BR> // Standard initialization<BR> // If you are not using these features and wish to reduce the size<BR> // of your final executable, you should remove from the following<BR> // the specific initialization routines you do not need.<BR><BR> // Initialize static members of CSocketThread<BR><BR>#ifdef _WIN32<BR> Enable3dControls();<BR>#endif<BR><BR> LoadStdProfileSettings(); // Load standard INI file options (including MRU)<BR><BR> // Register the application's document templates. Document templates<BR> // serve as the connection between documents, frame windows and views.<BR><BR> CSingleDocTemplate* pDocTemplate;<BR> pDocTemplate = new CSingleDocTemplate(<BR> IDR_MAINFRAME,<BR> RUNTIME_CLASS(CServerDoc),<BR> RUNTIME_CLASS(CMainFrame), // main SDI frame window<BR> RUNTIME_CLASS(CServerView));<BR> AddDocTemplate(pDocTemplate);<BR><BR> // Parse command line for standard shell commands, DDE, file open<BR> CCommandLineInfo cmdInfo;<BR> ParseCommandLine(cmdInfo);<BR><BR> // Dispatch commands specified on the command line<BR> if (!ProcessShellCommand(cmdInfo))<BR> return FALSE;<BR><BR> // The one and only window has been initialized, so show and update it.<BR> m_pMainWnd->SetIcon(LoadIcon(IDR_MAINFRAME), FALSE);<BR> m_pMainWnd->ShowWindow(SW_HIDE);<BR> m_pMainWnd->CenterWindow(NULL);<BR> m_pMainWnd->UpdateWindow();<BR><BR> // create a new (empty) document<BR> //OnFileNew();<BR><BR> return TRUE;<BR>}<BR><BR>int CServerApp::ExitInstance() <BR>{<BR> return CWinApp::ExitInstance();<BR>}<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CAboutDlg dialog used for App About<BR><BR>class CAboutDlg : public CDialog<BR>{<BR>public:<BR> CAboutDlg();<BR><BR>// Dialog Data<BR> //{{AFX_DATA(CAboutDlg)<BR> enum { IDD = IDD_ABOUTBOX };<BR> //}}AFX_DATA<BR><BR>// Implementation<BR>protected:<BR> virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support<BR> //{{AFX_MSG(CAboutDlg)<BR> // No message handlers<BR> //}}AFX_MSG<BR> DECLARE_MESSAGE_MAP()<BR>};<BR><BR>CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)<BR>{<BR> //{{AFX_DATA_INIT(CAboutDlg)<BR> //}}AFX_DATA_INIT<BR>}<BR><BR>void CAboutDlg::DoDataExchange(CDataExchange* pDX)<BR>{<BR> CDialog::DoDataExchange(pDX);<BR> //{{AFX_DATA_MAP(CAboutDlg)<BR> //}}AFX_DATA_MAP<BR>}<BR><BR>BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)<BR> //{{AFX_MSG_MAP(CAboutDlg)<BR> // No message handlers<BR> //}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()<BR><BR>// App command to run the dialog<BR>void CServerApp::OnAppAbout()<BR>{<BR> CAboutDlg aboutDlg;<BR> 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>内容: #if !defined(AFX_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_)<BR>#define AFX_DFS_H__627EA4FF_D182_490F_96C8_5CA0D96B3772__INCLUDED_<BR><BR> 这是用来标是文件的唯一性的,那一大串数是一个全局唯一标识符。一般来说,VC帮助生成的文件里都带这个。<BR>_MSC_VER 表示C++编译器的版本>1000表示是VC++6.0的编译器<BR>#pragma once这是预编译指令,表示告诉编译器这个文件只编译一次。<BR> 如果文件里没有,那就表示可能这个文件是用记事本手工建立的。再加到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 兄真是令人感激涕零!<BR><BR>
<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 + -