⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8_1view.cpp

📁 通讯录一个完美的程序努力实现自己的梦想我需要下载程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:

void CMy8_1View::OnUpdateView2(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(view==2);
	
}

void CMy8_1View::OnMenuTstart() 
{
	// TODO: Add your command handler code here
	AfxGetMainWnd() ->SetWindowPos(NULL,0,0,513,650,SWP_NOMOVE|SWP_NOZORDER );
	player=3;
    start=true;
    russia0.Start();
	SetTimer(1,50*(11-russia0.m_Speed ),NULL); 
	
}

void CMy8_1View::OnMenuStart() 
{
	// TODO: Add your command handler code here
	if(view==1)
		AfxGetMainWnd() ->SetWindowPos(NULL,0,0,500,590,SWP_NOMOVE|SWP_NOZORDER );
	if(view==2)
		AfxGetMainWnd() ->SetWindowPos(NULL,0,0,253,510,SWP_NOMOVE|SWP_NOZORDER );
	player=1;
    start=true;
    russia.Start();
	SetTimer(1,50*(11-russia.m_Speed ),NULL);    
	
}

void CMy8_1View::OnMenuDstart() 
{
	// TODO: Add your command handler code here
	if(view==1)
		AfxGetMainWnd() ->SetWindowPos(NULL,0,0,1000,590,SWP_NOMOVE|SWP_NOZORDER );
	if(view==2)
		AfxGetMainWnd() ->SetWindowPos(NULL,0,0,510,510,SWP_NOMOVE|SWP_NOZORDER );
	player=2;
	start=true;
    russia.Start();
	Sleep(300);
	russia2.Start();
	SetTimer(1,50*(11-russia.m_Speed ),NULL);    
	
}

void CMy8_1View::OnMenuPause() 
{
	// TODO: Add your command handler code here
	m_bPause=!m_bPause;
	if(m_bPause)
		KillTimer(1);
	else
	{
		SetTimer(1,50*(11-russia.m_Speed ),NULL);   
		if(player==4)
		{
			if(net==1)
				SetTimer(1,50*(11-russia2.m_Speed ),NULL);    
			else
				SetTimer(1,50*(11-russia.m_Speed ),NULL);    
		}
	}
	
}

//void CMy8_1View::OnEditPaste() 
//{
	// TODO: Add your command handler code here
	
//}
void CMy8_1View::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	//下移
	if(player==1)
		russia.Move(3);
	if(player==2)
	{
		russia.Move(3);
		russia2.Move(3);
	}
	if(player==3)
	{
		russia0.Move(3);
		russia0.Move(7);
	}
	if(player==4)
	{
		russia.Move(3);
		russia2.Move(3);
	}
	OnDraw(GetDC());
	CView::OnTimer(nIDEvent);
}
void CMy8_1View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
    //没有开始
	if(!start)
	{
		CRect rect;
		rect.left=170;
		rect.top=330;
		rect.right=340;
		rect.bottom=500;

		if(nChar==VK_DOWN)
		{
			if(ixuanze<4)
				ixuanze++;
			else
				ixuanze=1;
				InvalidateRect(&rect);
		}
		if(nChar==VK_UP)
		{
			if(ixuanze>1)
				ixuanze--;
			else
				ixuanze=4;
				InvalidateRect(&rect);
		}
		if(nChar==VK_SPACE)
		{	
			if(ixuanze==1)
				OnMenuStart();
			if(ixuanze==2)
				OnMenuDstart();
			if(ixuanze==3)
				OnMenuTstart();	
			if(ixuanze==4)
				OnNet();
		}
		return;
	}
    //暂停
   	if(m_bPause==TRUE)
		return;

	switch(nChar)
	{
	case VK_LEFT:
		russia.Move(1);russia0.Move(5);
		break;
	case VK_RIGHT:
		russia.Move(2);russia0.Move(6);
		break;		
	case VK_UP:
		russia.Move(4);russia0.Move(8);
		break;
	case VK_DOWN:
		russia.Move(3);russia0.Move(7);
		break;
	case 65:
		russia2.Move(1);russia0.Move(1);
		break;
	case 68:
		russia2.Move(2);russia0.Move(2);
		break;
	case 87:
		russia2.Move(4);russia0.Move(4);
		break;
	case 83:
		russia2.Move(3);russia0.Move(3);
		break;
	}
	//重画
/*//////////////////////////////////////////////
  if(player==4)
  {	   	
    	CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
	    char msg[10000];
        strcpy(msg,":");
		int i,j;

	if(pFrame->ynserver==1)
	{
//		for(i=0;i<4;i++)
//		  for(j=0;j<4;j++)
//		  {
//		     if(russia.Now[i][j]==0)
//			   strcat(msg,"0");
//            else
//			   strcat(msg,"1");
//          }
        for(i=0;i<4;i++)
		  for(j=0;j<4;j++)
		  {
		      if(russia.Will[i][j]==0)
			     strcat(msg,"0");
              else
			     strcat(msg,"1");
          }
		for(i=0;i<russia.m_RowCount;i++)
			for(j=0;j<russia.m_ColCount;j++)
			{
                if(russia.Russia[i][j]==0)
				  strcat(msg,"0");
                else
				  strcat(msg,"1");
             }

		char pMsg[10000];
		sprintf(pMsg,"%s",msg);
			CMy8_1App *App=( CMy8_1App * )AfxGetApp();
			if(App->pRequestSave!=NULL)
	    	pFrame->SendMsg(App->pRequestSave,pMsg);
		}
	 if(pFrame->ynserver==2)
		if(pFrame->m_pSocket)
		{
//		for(i=0;i<4;i++)
//		  for(j=0;j<4;j++)
//		  {
//		     if(russia.Now[i][j]==0)
//			   strcat(msg,"0");
//             else
//			   strcat(msg,"1");
//          }
        for(i=0;i<4;i++)
		  for(j=0;j<4;j++)
		  {
		      if(russia.Will[i][j]==0)
			     strcat(msg,"0");
              else
			     strcat(msg,"1");
          }
		for(i=0;i<russia.m_RowCount;i++)
			for(j=0;j<russia.m_ColCount;j++)
			{
                if(russia.Russia[i][j]==0)
				  strcat(msg,"0");
                else
				  strcat(msg,"1");
             }
    	char pMsg[10000];
		sprintf(pMsg,"%s",msg);
		CMy8_1App *App=( CMy8_1App * )AfxGetApp();
		pFrame->SendMsg(pFrame->m_pSocket,pMsg);
		}
  } 
*////////////////////////////////////////////////
	OnDraw(GetDC());
	CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CMy8_1View::OnUpdateMenuPause(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_bPause);
}
void CMy8_1View::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(point.x>200&&point.x<340&&point.y>350&&point.y<510)
	{
		if(ixuanze==1)
			OnMenuStart();
		if(ixuanze==2)
			OnMenuDstart();
		if(ixuanze==3)
			OnMenuTstart();
		if(ixuanze==4)
			OnNet();
	}
	CView::OnLButtonDown(nFlags, point);
}
void CMy8_1View::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(start)
		return;
	CRect rect;
	rect.left=170;
	rect.top=330;
	rect.right=340;
	rect.bottom=580;

	if(point.x>200&&point.x<350)
	{
		if(point.y>350&&point.y<390)
		{
			if(ixuanze!=1)
			{
				ixuanze=1;
				InvalidateRect(&rect);
			}
		}
		if(point.y>390&&point.y<430)
			if(ixuanze!=2)
			{
				ixuanze=2;
				InvalidateRect(&rect);
			}
		if(point.y>430&&point.y<470)
			if(ixuanze!=3)
			{
				ixuanze=3;
				InvalidateRect(&rect);
			}
		if(point.y>470&&point.y<510)
			if(ixuanze!=4)
			{
				ixuanze=4;
				InvalidateRect(&rect);
			}

	}
	CView::OnMouseMove(nFlags, point);
}

void CMy8_1View::OnNet() 
{
	// TODO: Add your command handler code here
    if(net>0)
	{
      russia2.Start();
    	SetTimer(1,50*(11-russia2.m_Speed ),NULL);    
      russia.Start();
      return;
//		delete m_pSocket;
//		m_pSocket=NULL;
	}

	/////////
 	CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
	pFrame->OnSorc();
	CMainFrame *pApp=(CMainFrame *)AfxGetApp();
    net=pFrame->ynserver;

	if(view==1)
		AfxGetMainWnd() ->SetWindowPos(NULL,0,0,1000,590,SWP_NOMOVE|SWP_NOZORDER );
	if(view==2)
		AfxGetMainWnd() ->SetWindowPos(NULL,0,0,510,510,SWP_NOMOVE|SWP_NOZORDER );
	player=4;
	start=true;
	if(net==1)
	{
      russia2.Start();
    	SetTimer(1,50*(11-russia2.m_Speed ),NULL);    
      russia.Start();
	}
	if(net==2)
	{
      russia.Start();
	SetTimer(1,50*(11-russia.m_Speed ),NULL);    
     russia2.Start();
	}

	Sleep(300);    
	
	
}

void CMy8_1View::OnContextMenu(CWnd*, CPoint point)
{
	// CG: This block was added by the Pop-up Menu component	{		if (point.x == -1 && point.y == -1){			//keystroke invocation			CRect rect;			GetClientRect(rect);			ClientToScreen(rect);			point = rect.TopLeft();			point.Offset(5, 5);		}		CMenu menu;		VERIFY(menu.LoadMenu(CG_IDR_POPUP_MY8_1_VIEW));		CMenu* pPopup = menu.GetSubMenu(0);		ASSERT(pPopup != NULL);		CWnd* pWndPopupOwner = this;		while (pWndPopupOwner->GetStyle() & WS_CHILD)			pWndPopupOwner = pWndPopupOwner->GetParent();		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,			pWndPopupOwner);	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -