BEGIN_MESSAGE_MAP(CTCPServerApp, CWinApp)
//{{AFX_MSG_MAP(CTCPServerApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CTCPServerApp::OnFileNew)
// ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTCPServerApp construction
CTCPServerApp::CTCPServerApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CTCPServerApp object
//WinSock初始化
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
m_pDocTemplate0 = new CMultiDocTemplate(
IDR_RECVPACKET,
RUNTIME_CLASS(CTCPServerDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CTCPServerView));
AddDocTemplate(m_pDocTemplate0);
m_pDocTemplate1 = new CMultiDocTemplate(
IDR_RECVCARD,
RUNTIME_CLASS(CTCPServerDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CTCPServerView));
AddDocTemplate(m_pDocTemplate1);
m_pDocTemplate2 = new CMultiDocTemplate(
IDR_RECVAGENT,
RUNTIME_CLASS(CTCPServerDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CTCPServerView));
AddDocTemplate(m_pDocTemplate2);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// Parse command line for standard shell commands, DDE, file open
// CCommandLineInfo cmdInfo;
ParseCommandLine(m_cmdInfo);
// 禁止应用程序启动时自动创建新文档
if (m_cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
m_cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
// Dispatch commands specified on the command line
if (!ProcessShellCommand(m_cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
if (!m_cmdInfo.m_bHideWindow)
{
pMainFrame->ShowWindow(SW_SHOW);
pMainFrame->UpdateWindow();
}
return TRUE;
}
//***************************************************************************
int CTCPServerApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
if (hDll) ::FreeLibrary(hDll);