Example #1
0
void CChatCDlg::OnConnect()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.

	// 접속 ip 아이디 비번을 입력하는 대화상자
	CConnectDlg dlg;
	if(dlg.DoModal() != IDOK) return;

	// 클라이언트 소켓 생성
	if(!m_pDataSocket->Create())
	{
		AfxMessageBox(_T("클라이언트 소켓 생성 실패"));
		return;
	}

	// 서버에 접속 요청
	if(!m_pDataSocket->Connect(dlg.m_strServerIP, 3666)) // 서버아이피와 포트번호
	{
		AfxMessageBox(_T("서버를 찾을 수 없습니다."));
		m_pDataSocket->Close();
		return;
	}

	// 클라이언트 소켓 초기화
	m_pDataSocket->Init(this);

	// ID와 비밀번호 확인
	Send_LOGIN(dlg.m_strId,dlg.m_strPass);
}
Example #2
0
BOOL CXuser32App::InitInstance()
{
	CWaitCursor pCursor;
	
#ifndef _DEBUG
	if ( SetFirstInstance() == FALSE ) return FALSE;
#endif
	
	Enable3dControls();
	SetRegistryKey( gcszCopyright );
	
	AfxOleInit();
	AfxEnableControlContainer();
	
	WSADATA wsaData;
	WSAStartup( 0x0101, &wsaData );
	
	CString xUserId, xPassword;
	CheckUsage( xUserId, xPassword, m_bTestor );
	
	CConnectDlg pConnect;
	if ( pConnect.DoModal(xUserId, xPassword) != IDOK ) return FALSE;
	//if ( pConnect.DoModal() != IDOK ) return FALSE;
	
	CSplashDlg* dlgSplash = new CSplashDlg;
	dlgSplash->Topmost();
	
	dlgSplash->Step( _T("注册表") );
		Settings.Load();
		Skin.Apply();
		
	dlgSplash->Step( _T("GUI") );
		m_pMainWnd = new CMainWnd();
		CoolMenu.EnableHook();
#if 0
		CString strCaption;
		strCaption.LoadString( AFX_IDS_APP_TITLE );
		m_pMainWnd->SetWindowText( (LPCTSTR)strCaption );
#else
		m_pMainWnd->SetWindowText( _T("96031城市总机") );
#endif
		dlgSplash->Topmost();
		m_pMainWnd->ShowWindow( SW_SHOW );
		m_pMainWnd->UpdateWindow();
		
	dlgSplash->Step( _T("连接") );
		m_pMainWnd->SendMessage( WM_COMMAND, ID_TAB_CONNECT );
		
	dlgSplash->Hide();
	
	pCursor.Restore();
	
	return m_bInitialized = TRUE;
}
//=======================================================
// 추가된 코드 내용 
void CClientApp::Connect() // 서버에 연결한다.
{
	CConnectDlg  dlg;
	if(dlg.DoModal() == IDOK)
	{
		m_pClient = new CClientSock; // 클라이언트 소켓 객체
		m_pClient->Create(); // 클라이언트 소켓 생성
		// 서버의 IP 주소와 포트 번호를 설정하여 
		// 서버에 연결을 시도한다.
		m_pClient->Connect(dlg.m_strAddress, 7000); 
		m_pMainWnd->GetDlgItem(IDC_SEND)->EnableWindow(TRUE); // [보내기]버튼 활성화
		m_pMainWnd->GetDlgItem(IDC_CONNECT)->EnableWindow(FALSE); // [서버 연결...]버튼 비활성화
	}
}
////////////////////////////////
//void OnConnect()
//网络连接
void CRussiaRectView::OnConnect() 
{
	// TODO: Add your command handler code here
	//当联机
	if(!m_bConnectStatus && m_bGameEnd)
	{
		CConnectDlg dlg;
		DWORD dwIP;
		
		int command = dlg.DoModal();					//产生对话框
		dlg.m_iConnectStatus = m_iConnectStatus;		//联机状态的选择

		if(IDOK == command)								//确认联机
		{
			//m_bGameEnd = false;
			m_bConnectStatus = true;					//联机开始
			m_iConnectStatus = dlg.m_iConnectStatus;	//保存联机状态
			//做客户端
			if(m_iConnectStatus == 2)
			{
				//已经开始
				//if(m_bConnectReady)m_bGameEnd = false;
				((CIPAddressCtrl*)GetDlgItem(IDC_IP_HOST))->GetAddress(dwIP);
			}
			//做服务器
			else if(m_iConnectStatus == 1)
			{
				//if(m_bConnectReady)m_bGameEnd = true;
			}
		}
		else if(IDCANCEL == command)
		{
			m_bGameEnd = true;
			m_bConnectStatus = false;					//取消选择
		}  
	}
	else
	{
		m_bConnectStatus = false;
	}
}