ImageVerifierCode 换一换
格式:DOCX , 页数:5 ,大小:17.81KB ,
资源ID:16851048      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/16851048.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(网络程序设计课程设计vcmfc实现简单的聊天室程序Word文档格式.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

网络程序设计课程设计vcmfc实现简单的聊天室程序Word文档格式.docx

1、 / ChatRoomServerDlg.cpp : implementation file / #include “stdafx.h“ #include “ChatRoomServer.h“ #include “ChatRoomServerDlg.h“ #include “ListenSocket.h“ #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE = _FILE_; #endif / / CAboutDlg dialog used for App About class CAboutDl

2、g : public CDialog public: CAboutDlg(); / Dialog Data /AFX_DATA(CAboutDlg) enum IDD = IDD_ABOUTBOX ; /AFX_DATA / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support /AFX_VIRTUAL / Implementation protec

3、ted: /AFX_MSG(CAboutDlg) /AFX_MSG DECLARE_MESSAGE_MAP() ; CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD) /AFX_DATA_INIT(CAboutDlg) /AFX_DATA_INIT void CAboutDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CAboutDlg) /AFX_DATA_MAP BEGIN_MESSAGE_MAP(CAboutDlg, CDialog

4、) /AFX_MSG_MAP(CAboutDlg) / No message handlers /AFX_MSG_MAP END_MESSAGE_MAP() / / CChatRoomServerDlg dialog CChatRoomServerDlg:CChatRoomServerDlg(CWnd* pParent /*=NULL*/) : CDialog(CChatRoomServerDlg:IDD, pParent) /AFX_DATA_INIT(CChatRoomServerDlg) / NOTE: the ClassWizard will add member initializa

5、tion here /AFX_DATA_INIT / Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME); void CChatRoomServerDlg: /AFX_DATA_MAP(CChatRoomServerDlg) DDX_Control(pDX, IDC_BUTTON_STOP, m_IDC_BUTTON_STOP); DDX_Control(pDX, IDC_BUTTON_START, m_IDC_BU

6、TTON_START); /AFX_DATA_MAP BEGIN_MESSAGE_MAP(CChatRoomServerDlg, CDialog) /AFX_MSG_MAP(CChatRoomServerDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON_START, OnButtonStart) ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop) /AFX_MSG_MAP END_MESSAGE_MAP() / / CChatRoomSe

7、rverDlg message handlers BOOL CChatRoomServerDlg:OnInitDialog() CDialog:OnInitDialog(); / Add “About.“ menu item to system menu. / IDM_ABOUTBOX must be in the system command range. ASSERT(IDM_ABOUTBOX ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR); pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAbout

8、Menu); / Set the icon for this dialog. The framework does this automatically / when the application s main window is not a dialog SetIcon(m_hIcon, TRUE);/ Set big icon SetIcon(m_hIcon, FALSE);/ Set small icon / TODO: Add extra initialization here m_IDC_BUTTON_STOP.EnableWindow(FALSE); return TRUE; /

9、 return TRUE unless you set the focus to a control void CChatRoomServerDlg:OnSysCommand(UINT nID, LPARAM lParam) if (nID dlgAbout.DoModal(); else CDialog:OnSysCommand(nID, lParam); / If you add a minimize button to your dialog, you will need the code below / to draw the icon. For MFC applications us

10、ing the document/view model, / this is automatically done for you by the framework. void CChatRoomServerDlg:OnPaint() if (IsIconic() CPaintDC dc(this); / device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); / Center icon in client rectangle int cxIcon = GetSystemM

11、etrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect( int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; / Draw the icon dc.DrawIcon(x, y, m_hIcon);OnPaint(); / The system calls this to obtain the cursor to display while the user drag

12、s / the minimized window. HCURSOR CChatRoomServerDlg:OnQueryDragIcon() return (HCURSOR) m_hIcon;OnButtonStart() / TODO: Add your control notification handler code here m_IDC_BUTTON_START.EnableWindow(FALSE);/使启动按钮无效 ListenSocket.Create(6767);/创建监听套接字端口为6767 ListenSocket.Listen();/开始监听 m_IDC_BUTTON_S

13、TOP.EnableWindow(TRUE);/将停止按钮激活 void CChatRoomServerDlg:OnButtonStop() / TODO: Add your control notification handler code here m_IDC_BUTTON_STOP.EnableWindow(FALSE);/使停止按钮无效 ListenSocket.Close();/关闭监听套接字 m_IDC_BUTTON_START.EnableWindow(TRUE);/将启动按钮激活 / ChatRoomServer.h : main header file for the CHA

14、TROOMSERVER application / #if !defined(AFX_CHATROOMSERVER_H_680EC642_E19B_4D55_88DF_2C9E9B1B30FD_INCLUDED_) #define AFX_CHATROOMSERVER_H_680EC642_E19B_4D55_88DF_2C9E9B1B30FD_INCLUDED_ #if _MSC_VER 1000 #pragma once #endif / _MSC_VER 1000 #ifndef _AFXWIN_H_ #error include stdafx.h before including th

15、is file for PCH #endif #include “resource.h“/ main symbols / / CChatRoomServerApp: / See ChatRoomServer.cpp for the implementation of this class / class CChatRoomServerApp : public CWinApp public: CChatRoomServerApp(); / Overrides / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CChat

16、RoomServerApp) public: virtual BOOL InitInstance(); /AFX_VIRTUAL / Implementation /AFX_MSG(CChatRoomServerApp) / NOTE - the ClassWizard will add and remove member functions here. / DO NOT EDIT what you see in these blocks of generated code ! /AFX_MSG DECLARE_MESSAGE_MAP() ; / /AFX_INSERT_LOCATION /

17、Microsoft Visual C+ will insert additional declarations immediately before the previous line. #endif / !defined(AFX_CHATROOMSERVER_H_680EC642_E19B_4D55_88DF_2C9E9B1B30FD_INCLUDED_) / ChatRoomServerDlg.h : header file / #if !defined(AFX_CHATROOMSERVERDLG_H_5BE648B6_8A9C_4E90_BF1D_20FE943A525F_INCLUDE

18、D_) #define AFX_CHATROOMSERVERDLG_H_5BE648B6_8A9C_4E90_BF1D_20FE943A525F_INCLUDED_ #include “ClientSocketList.h“/ Added by ClassView #include “ListenSocket.h“/ Added by ClassView #if _MSC_VER 1000 / / CChatRoomServerDlg dialog class CChatRoomServerDlg : public CDialog / Construction public: CListenS

19、ocket ListenSocket; CChatRoomServerDlg(CWnd* pParent = NULL);/ standard constructor / Dialog Data /AFX_DATA(CChatRoomServerDlg) enum IDD = IDD_CHATROOMSERVER_DIALOG ; CButtonm_IDC_BUTTON_STOP; CButtonm_IDC_BUTTON_START; /AFX_DATA / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CChatR

20、oomServerDlg) protected:/ DDX/DDV support /AFX_VIRTUAL / Implementation protected: HICON m_hIcon; / Generated message map functions /AFX_MSG(CChatRoomServerDlg) virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon();

21、 afx_msg void OnButtonStart(); afx_msg void OnButtonStop(); /AFX_INSERT_LOCATION / Microsoft Visual C+ will insert additional declarations immediately before the previous line. #endif / !defined(AFX_CHATROOMSERVERDLG_H_5BE648B6_8A9C_4E90_BF1D_20FE943A525F_INCLUDED_) #if !defined(AFX_CLIENTSOCKET_H_5

22、B707F31_3AD5_4F47_B58E_ECFC99EB60F0_INCLUDED_) #define AFX_CLIENTSOCKET_H_5B707F31_3AD5_4F47_B58E_ECFC99EB60F0_INCLUDED_ #if _MSC_VER 1000 / ClientSocket.h : header file / / / CClientSocket command target class CClientSocketList; class CClientSocket : public CSocket / Attributes public: / Operations

23、 public: CClientSocket(CClientSocketList *); virtual CClientSocket(); / Overrides public: CClientSocketList *List; CClientSocket * Front; CClientSocket * Next; / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CClientSocket) public: virtual void OnReceive(int nErrorCode); virtual void

24、OnClose(int nErrorCode); /AFX_VIRTUAL / Generated message map functions /AFX_MSG(CClientSocket) / NOTE - the ClassWizard will add and remove member functions here. /AFX_MSG / Implementation protected: ;defined(AFX_CLIENTSOCKET_H_5B707F31_3AD5_4F47_B58E_ECFC99EB60F0_INCLUDED_) / ClientSocketList.h: i

25、nterface for the CClientSocketList class. / / #if !defined(AFX_CLIENTSOCKETLIST_H_E746355D_FA10_4D12_B544_2FF152C16414_INCLUDED_) #define AFX_CLIENTSOCKETLIST_H_E746355D_FA10_4D12_B544_2FF152C16414_INCLUDED_ #include “ClientSocket.h“ #if _MSC_VER 1000 class CClientSocketList public: BOOL Sends(CClie

26、ntSocket *); BOOL Add(CClientSocket *); CClientSocket * Head; CClientSocketList(); virtual CClientSocketList(); #endif / !defined(AFX_CLIENTSOCKETLIST_H_E746355D_FA10_4D12_B544_2FF152C16414_INCLUDED_) #if !defined(AFX_LISTENSOCKET_H_5D655304_370E_4680_A556_E417552D24EC_INCLUDED_) #define AFX_LISTENSOCKET_H_5D655304_370E_4680_A556_E417552D24EC_INCLUDED_ #if _MSC_VER 1000 / ListenSocket.h : header file / #include “ClientSocketList.h“ / / CListenSock

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1