MenuDlg.cpp
上传用户:sztlpcb
上传日期:2007-06-09
资源大小:741k
文件大小:4k
- // MenuDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "multiplayer.h"
- #include "MenuDlg.h"
- /////////////////
- #include<iostream>
- #include<string>
- #include<fstream>
- #include<iomanip>
- #include <stdio.h>
- #include <conio.h>
- #include <windows.h>
- #define BUFSIZE 1024
- using namespace std;
- ////////////////////////
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMenuDlg dialog
- CMenuDlg::CMenuDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CMenuDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMenuDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CMenuDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMenuDlg)
- DDX_Control(pDX, IDOK, m_load);
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_Control(pDX, IDC_BUTTON2, m_register);
- DDX_Control(pDX, IDC_BUTTON1, m_play);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMenuDlg, CDialog)
- //{{AFX_MSG_MAP(CMenuDlg)
- ON_BN_CLICKED(IDC_BUTTON1, OnPlay)
- ON_BN_CLICKED(IDC_BUTTON2, Onregister)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMenuDlg message handlers
- void CMenuDlg::OnPlay()
- {
- // TODO: Add your control notification handler code here
- CString buf;
- char itemname[50]="";
- char ch;
- int choose=-1;
- int recv_count=0;
-
-
- choose=m_list.GetCurSel();
- m_list.GetText(choose,buf);
- sprintf(itemname,"play %s",buf);
- //MessageBox(itemname,"play",MB_YESNO);
- switch(choose)
- {
- case 0:ch='A';break;
- case 1:ch='B';break;
- default:ch='X';break;
- }
- if(connect_sd!=NULL)
- send(connect_sd,&ch,1,0);
- else
- MessageBox("haven't register","error",MB_OK);
- recv_count=recv(connect_sd,sess_Addr,sizeof(sess_Addr),0);
- sess_Addr[recv_count]=' ';
- MessageBox(sess_Addr,"Session Address",MB_OK);
- }
- void CMenuDlg::Onregister()
- {
- // TODO: Add your control notification handler code here
- WSADATA wsadata;
- //SOCKET connect_sd;
- fd_set fdset;
- FILE *menufile;
- struct sockaddr_in src_addr; /* 跑计