代码如下:
#include "stdafx.h"
#include "Chat.h"
#include "ChatDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CChatApp, CWinApp)
//{{AFX_MSG_MAP(CChatApp)
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
CChatApp::CChatApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CChatApp object
CChatApp theApp;
// CChatApp initialization
BOOL CChatApp::InitInstance()
{
if(!AfxSocketInit())
{
AfxMessageBox("加载套接字库失败!");
return FALSE;
}
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls();
// Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic();
// Call this when linking to MFC statically
#endif
CChatDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
//
dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
//
dismissed with Cancel
}
return FALSE;
}