/***********************************************************************
*Copyright (c)2012 , 天际边工作室
*All rights reserved.
**
文件名称：	GameEng.cpp
*摘要：		游戏引擎类，开始游戏界面
**
*修改历史：
*	版本    日期     作者     改动内容和原因
*   ----------------------------------------------------
*	1.0    2012-10-5  wstjb     基本的功能完成
***********************************************************************/

#include "GameEng.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "Dialog.h" 

extern  PAINTSTRUCT ps;
extern 	HDC hdc;
extern 	HBITMAP hbmp; 
extern 	BITMAP bmp;
extern 	HBITMAP hbmp2; 
extern 	HDC hdcMem;
extern 	HDC hdcTmp;
extern 	RECT rect;
extern 	HWND hwnd;
extern HINSTANCE hInst;
extern int flag;
extern int tasknum;

extern int KeyReturn;
extern int KeyEsc;
extern int KeyHome;
extern int KeySpace;
extern int KeyLeft0;
extern int KeyUp0;
extern int KeyRight0;
extern int KeyDown0;
//extern SIZE size;
//extern HDC hdcPaint;

extern int MouseStartX ;//20170205
extern int MouseStartY ;//20170205
extern int MouseEndX ;//20170205
extern int MouseEndY ;//20170205
extern int MouseDown ;//左键已经按下
extern int MouseWheelLen;
extern int operateflag;
extern int useableskillnum2;
extern int version_now;
extern int MouseEnable;
/***********************************************************************
 * 说明:     Game类初始化函数
 * 输入参数: 无
 * 返回值  : 无
 * 功能	   : 初始化并获取DC
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Game::Game_Init()
{
	wlogfile(1,__FUNCTION__,"version = ",version_now);
	wlogfile(1,__FUNCTION__,GetVersionInfo(),0);
	stat=-1;//初始化
	ng=0;
	GetData();
	InitStrText();
	//newgame=new NewGame();
	//save_start=new Save();
}

/***********************************************************************
 * 说明:     Game类主函数
 * 输入参数: 无
 * 返回值  : 无
 * 功能	   : 用于控制当前显示的内容属于哪一个类并调用
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       完成基本功能
 *             wstjb          2012-10-13       增加功能
***********************************************************************/
void Game::Game_Main()
//void Game_Main(HWND &hwnd)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	switch(flag)
	{
		case 0:
		{
			GameCG();
			flag=1;
			break;
		}
		case 2:
		{
			newgame.History();
			break;
		}
		case 1:
		{
			ChoiceShow();
			break;
		}
		case 3:
		{
			newgame.who.Show();
			break;
		}
		case 4:
		{
			newgame.who.gamemap.Show(0);
			break;
		}
		case 5:
		{
			newgame.who.gamemap.escmenu.Show(0);
			break;
		}
		case 6:
		{
			newgame.who.gamemap.citymenu.Show(0);
			break;
		}
		case 7:
		{
			newgame.who.gamemap.secondmenu1.Show(0);
			break;
		}
		case 8:
		{
			newgame.who.gamemap.citylist.Show();
		}
		case 9:
		{
			newgame.who.gamemap.herolist.Show(0);
		}

	
	}
}

/***********************************************************************
 * 说明:     Game类释放资源函数
 * 输入参数: 无
 * 返回值  : 无
 * 功能	   : 释放资源
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Game::Game_Shutdown()
{
	ReleaseObjs();//释放资源
}

/***********************************************************************
 * 说明:     Game类显示函数
 * 输入参数: 无
 * 返回值  : 无
 * 功能	   : 显示游戏片头动画
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Game::GameCG()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	//ShowCGStart(200,"Res\\01.sbp");
	//InvalidateRect(hwnd,NULL,FALSE);
	ShowCGDirect(1,"Res\\black.sbp");
	ShowCGStart(300,"Res\\05.sbp");
	ShowCGStart(300,"Res\\06.sbp");
	ShowCGStart(300,"Res\\07.sbp");
	ShowCGStart(300,"Res\\08.sbp");
	ShowCGStart(300,"Res\\08.sbp");
	ShowCGStart(0,"Res\\01.sbp");
	ShowCGDirect(0,"Res\\01.sbp");
	ShowCGAdd(0,"Res\\ba.sbp","Res\\ba1.sbp",75,100);
	ShowCGAdd(1000,"Res\\ye.sbp","Res\\ye1.sbp",450,100);
	ShowCGStart(100,"Res\\01.sbp");
	ShowText("请按任意键继续",250,480,40);
	ShowText("基本按键如下：",0,50,20);
	ShowText("方向键——移动                      Enter（回车）——确认                   ",0,70,20);
	ShowText("Esc——退出、返回或菜单             Space（空格）——战争界面可查看武将信息 ",0,90,20);
	ShowText("Home——地图界面显示城市连接信息，战争界面显示当前战场情况                  ",0,110,20);
	ShowText("Tab ——地图界面设置高攻击概率      End ——调用窗口配置程序                ",0,130,20);
	ShowText("——————————————————————————————————————",0,150,20);
	Delay(100);

	
}

/***********************************************************************
 * 说明:     Game类显示函数
 * 输入参数: 无
 * 返回值  : 无
 * 功能	   : 显示游戏制作人员
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Game::About()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	//ShowCGDirect(0,"Res\\black.sbp",0,0);
	
	ShowCGDirect(0,"Res\\black.sbp",0,-50);
	ShowCGDirect(0,"Res\\black.sbp",0,50);
	ShowCGDirect(200,"Res\\maker.sbp",0,0);
	//ShowCG(0,"Res\\black.sbp",0,100);

}

/***********************************************************************
 * 说明:     Game类读档函数
 * 输入参数: 无
 * 返回值  : 无
 * 功能	   : 读档
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       未完成基本功能
***********************************************************************/
void Game::Load()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	ShowCG(0,"Res\\save.sbp",0,0);
	save_start.Init(-1,-1);//-1 -1表示读取数据
	save_start.Read(-1);//-1表示读取君主 年份信息
	save_start.Show();
	
}

/***********************************************************************
 * 说明:     Game类显示按键函数
 * 输入参数: 无
 * 返回值  : 无
 * 功能	   : 显示当前按键选择的选项
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Game::ChoiceShow()
{
	wlogfile(1,__FUNCTION__,"开始",0);
		if (stat==0	)
		{
		
			ShowCG(0,"Res\\gmstart.sbp");
			ShowCG(100,"Res\\gmnew.sbp",25,220);
		}
		else if	(stat==1)		
		{
			ShowCG(0,"Res\\gmstart.sbp");
			ShowCG(100,"Res\\gmback.sbp",410,220);
		}
		else if	(stat==2)		
		{
			ShowCG(0,"Res\\gmstart.sbp");
			ShowCG(100,"Res\\gmwork.sbp",25,350);
		}
		else if	(stat==3)		
		{
			ShowCG(0,"Res\\gmstart.sbp");
			ShowCG(100,"Res\\gmend.sbp",410,350);
			
		}
		InvalidateRect(hwnd,NULL,false);
}

/***********************************************************************
 * 说明:     Game类按键函数
 * 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
 * 返回值  : 无
 * 功能	   : 处理当前类的按键信息
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Game::KeyDown(WPARAM KeyCode)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	if(ng==1)
	{
		int rt=newgame.KeyDown(KeyCode);
		if(rt==-1)
		{
			ng=0;
			ChoiceShow();
		}
	}
	else if(ng==3)
	{
		//直接进入城市地图,未做
		/*flag=4;
		newgame.Int();
		newgame.who.InitWho(0);
		newgame.who.gamemap.InitMap(0,0);
		newgame.who.gamemap.Show(0);*/
		
		int rt=newgame.KeyDown(KeyCode);
		if(rt==-1)
		{
			ng=0;
			ChoiceShow();
		}
		//ng=1;

	}
	else if(ng==2)
	{
		int retval=save_start.KeyDown(KeyCode);
		if(retval==-1)//返回
		{
			ng=0;
			ChoiceShow();

		}
		else if(retval!=3)//选择存档
		{
			savefg=0;
			ng=3;
			//save_start.Read(retval);
			//flag=4;
			int rt=save_start.Read(retval);
			if(rt==-1)
			{
				savefg=1;
				ng=2;
				TimerMessage("无法读取空存档！","",50,280,12,1,1000);
				Load();
				return;
			}
			if(rt==-2)
			{
				savefg=1;
				ng=2;
				TimerMessage("存档版本错误！","",50,280,12,1,1000);
				Load();
				return;
			}

			newgame.Int();
			newgame.KeyDown(KeyReturn);
			newgame.KeyDown(KeyReturn);
			//newgame.KeyDown(VK_RETURN);
		
			//newgame.who.InitWho(0);
			//newgame.who.gamemap.InitMap(0,0);
			//newgame.who.gamemap.Show(0);
			//newgame.KeyDown(VK_RETURN);
			//newgame.who.KeyDown(VK_RETURN):
			

			TimerMessage(GetStrText("dReading"),"",50,280,12,1,1000);
			ChangeSaveToData();
			
			newgame.who.gamemap.Show(0);
			newgame.who.gamemap.ArrowSet();
			newgame.who.gamemap.Show(0);
		}
		
	}
	else if(ng==10)
	{
		ng=0;
		ChoiceShow();
	}
	else
	{
	if(KeyCode==KeyDown0)
	{
	
		stat++;
		if(stat==4)stat=0;
		ChoiceShow();
		return;
	}
	else if(KeyCode==KeyUp0)
	{
		stat--;
		if(stat==-1)stat=3;
		ChoiceShow();
		return;
	}
	else if(KeyCode==KeyReturn)
	{
		if(stat==0)
		{
			ng=1;
			flag=2;
			newgame.Int();
			newgame.History();
		}
		else if(stat==1)
		{
			Load();
			ng=2;
		}
		else if(stat==2)
		{
			About();
			ng=10;
		}
		else if(stat==3)
		{
			DeleteLog();
			PostQuitMessage(0);
			return;
		}
		else if(stat==-1)
		{	
			stat=0;
			ChoiceShow();
		}

	}
	else if(KeyCode==KeyEsc)
	{
		Game_Shutdown();
		DeleteLog();
		PostQuitMessage(0);
	}
	else if(KeyCode== 35 )//20161204增加调用窗口程序end
	{
			//ShellExecute(hwnd,"open","天际边三国霸业窗口配置程序.exe","","",SW_SHOW );
		DialogBox(hInst,LPCTSTR(IDD_WINDOW),hwnd,(DLGPROC)WindowCfgProc);
	}
	else
	{
		if(stat==-1)
		{	
			stat=0;
			ChoiceShow();
		}
		return;
	}

	/*switch(KeyCode)
	{
	case VK_DOWN:
		stat++;
		if(stat==4)stat=0;
		ChoiceShow();
		return;
	case VK_UP:
		stat--;
		if(stat==-1)stat=3;
		ChoiceShow();
		return;
	case VK_RETURN:
		if(stat==0)
		{
			ng=1;
			flag=2;
			newgame.Int();
			newgame.History();
		}
		else if(stat==1)
		{
			Load();
			ng=2;
		}
		else if(stat==2)
		{
			About();
			ng=10;
		}
		else if(stat==3)
		{
			PostQuitMessage(0);
			return;
		}
		else if(stat==-1)
		{	
			stat=0;
			ChoiceShow();
		}
			break;
	case VK_ESCAPE:
		Game_Shutdown();
		PostQuitMessage(0);
		break;
	default:
		if(stat==-1)
		{	
			stat=0;
			ChoiceShow();
		}
		return;
	}*/
	}
	return;

}

/***********************************************************************
 * 说明:     Game类新游戏函数
 * 输入参数: WPARAM KeyCode——按键信息
 * 返回值  : 无
 * 功能	   : 调用历史时期选择类
 * 修改历史:
 *               姓名            日期             说明
 *             ------          ----------      -------------
 *             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Game::NewGame1(WPARAM KeyCode)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	newgame.History();
	newgame.KeyDown(KeyCode);
}

void Game::ReleaseObjs()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	ReleaseDC(hwnd,hdc);
	ReleaseDC(hwnd,hdcMem);
	ReleaseDC(hwnd,hdcTmp);
	DeleteObject(hbmp);
	DeleteObject(hbmp2);

}

void Game::ChangeSaveToData()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	//将武将城市道具类中数据转换为sava类的数组数据
	int i;

	newgame.who.gamemap.ownernum=save_start.owner1;

	for(i=0;i<HEROMAX;i++)
	{
		newgame.who.gamemap.herolist.hero[i].no=save_start.herosave[i][0];
		newgame.who.gamemap.herolist.hero[i].owner=save_start.herosave[i][1];
		newgame.who.gamemap.herolist.hero[i].degree=save_start.herosave[i][2]>20?20:(save_start.herosave[i][2]<0?1:save_start.herosave[i][2]);
		newgame.who.gamemap.herolist.hero[i].wuli=save_start.herosave[i][3]>200?1:(save_start.herosave[i][3]<0?1:save_start.herosave[i][3]);
		newgame.who.gamemap.herolist.hero[i].zili=save_start.herosave[i][4]>200?1:(save_start.herosave[i][4]<0?1:save_start.herosave[i][4]);
		newgame.who.gamemap.herolist.hero[i].heart=save_start.herosave[i][5]>100?100:(save_start.herosave[i][5]<0?1:save_start.herosave[i][5]);
		newgame.who.gamemap.herolist.hero[i].charcter=save_start.herosave[i][6];
		newgame.who.gamemap.herolist.hero[i].experience=save_start.herosave[i][7];
		newgame.who.gamemap.herolist.hero[i].tili=save_start.herosave[i][8];
		newgame.who.gamemap.herolist.hero[i].style=save_start.herosave[i][9];
		newgame.who.gamemap.herolist.hero[i].bingli=save_start.herosave[i][10];
		newgame.who.gamemap.herolist.hero[i].goods1=save_start.herosave[i][11];
		newgame.who.gamemap.herolist.hero[i].goods2=save_start.herosave[i][12];
		newgame.who.gamemap.herolist.hero[i].age=save_start.herosave[i][13];
		newgame.who.gamemap.herolist.hero[i].hiscity=save_start.herosave[i][14]<0?0:save_start.herosave[i][14];
		//herolist.hero[i].number=save.herosave[i][15];
		newgame.who.gamemap.herolist.hero[i].inlistflag=save_start.herosave[i][15];
		newgame.who.gamemap.herolist.hero[i].speedup=save_start.herosave[i][16];
		newgame.who.gamemap.herolist.hero[i].hisfinder=save_start.herosave[i][17];
		if(newgame.who.gamemap.herolist.hero[i].owner>HEROMAX)newgame.who.gamemap.herolist.hero[i].iscaptive = 1;//20170508
	}
	for(i=0;i<CITYMAX;i++)
	{
		newgame.who.gamemap.citylist.city[i].no=save_start.citysave[i][0];
		newgame.who.gamemap.citylist.city[i].owner=save_start.citysave[i][1];
		newgame.who.gamemap.citylist.city[i].ownto=save_start.citysave[i][2];
		newgame.who.gamemap.citylist.city[i].agriculturemax=save_start.citysave[i][3];
		newgame.who.gamemap.citylist.city[i].agriculture=save_start.citysave[i][4];
		newgame.who.gamemap.citylist.city[i].businessmax=save_start.citysave[i][5];
		newgame.who.gamemap.citylist.city[i].business=save_start.citysave[i][6];
		newgame.who.gamemap.citylist.city[i].heart=save_start.citysave[i][7];
		newgame.who.gamemap.citylist.city[i].disease=save_start.citysave[i][8];
		newgame.who.gamemap.citylist.city[i].peoplemax=save_start.citysave[i][9];
		newgame.who.gamemap.citylist.city[i].people=save_start.citysave[i][10];
		newgame.who.gamemap.citylist.city[i].money=save_start.citysave[i][11]>99999?99999:save_start.citysave[i][11];
		newgame.who.gamemap.citylist.city[i].foods=save_start.citysave[i][12]>99999?99999:save_start.citysave[i][12];
		newgame.who.gamemap.citylist.city[i].soldierspace=save_start.citysave[i][13];
		newgame.who.gamemap.citylist.city[i].employers=save_start.citysave[i][14];
		newgame.who.gamemap.citylist.city[i].employnum=save_start.citysave[i][15];
		newgame.who.gamemap.citylist.city[i].goods=save_start.citysave[i][16];
		newgame.who.gamemap.citylist.city[i].goodnum=save_start.citysave[i][17];
		newgame.who.gamemap.citylist.city[i].statue=save_start.citysave[i][18];
		//citylist.city[i].number=save.citysave[i][19];
	}
	for(i=0;i<GOODMAX;i++)
	{
		newgame.who.gamemap.goodlist.good[i].no=save_start.goodsave[i][0];
		newgame.who.gamemap.goodlist.good[i].owner=save_start.goodsave[i][1];
		newgame.who.gamemap.goodlist.good[i].style=save_start.goodsave[i][2];
		newgame.who.gamemap.goodlist.good[i].wuliup=save_start.goodsave[i][3]>20?20:save_start.goodsave[i][3];
		newgame.who.gamemap.goodlist.good[i].ziliup=save_start.goodsave[i][4]>20?20:save_start.goodsave[i][4];
		newgame.who.gamemap.goodlist.good[i].speedup=save_start.goodsave[i][5]>10?20:save_start.goodsave[i][5];
		newgame.who.gamemap.goodlist.good[i].bingzhong=save_start.goodsave[i][6];
		//goodlist.good[i].number=save.goodsave[i][7];
		newgame.who.gamemap.goodlist.good[i].hiscity=save_start.goodsave[i][7];
		newgame.who.gamemap.goodlist.good[i].hisfinder=save_start.goodsave[i][8];
		newgame.who.gamemap.goodlist.good[i].finded=save_start.goodsave[i][9];

	}
	for(i=0;i<TASKLISTMAX;i++)
	{
		newgame.who.gamemap.tasklist[i].num=save_start.tasklistsave[i][0];
		newgame.who.gamemap.tasklist[i].citynum=save_start.tasklistsave[i][1];
		newgame.who.gamemap.tasklist[i].heronum=save_start.tasklistsave[i][2];
		newgame.who.gamemap.tasklist[i].event=save_start.tasklistsave[i][3];
		newgame.who.gamemap.tasklist[i].data[0]=save_start.tasklistsave[i][4];
		newgame.who.gamemap.tasklist[i].data[1]=save_start.tasklistsave[i][5];
		newgame.who.gamemap.tasklist[i].data[2]=save_start.tasklistsave[i][6];
		newgame.who.gamemap.tasklist[i].data[3]=save_start.tasklistsave[i][7];
		newgame.who.gamemap.tasklist[i].data[4]=save_start.tasklistsave[i][8];
		newgame.who.gamemap.tasklist[i].isend=save_start.tasklistsave[i][9];
	}

	newgame.who.gamemap.herolist.unx=save_start.herolistsave[0];
	newgame.who.gamemap.herolist.uny=save_start.herolistsave[1];
	newgame.who.gamemap.herolist.number=save_start.herolistsave[2];
	newgame.who.gamemap.herolist.choice=save_start.herolistsave[3];
	newgame.who.gamemap.herolist.heronum=save_start.herolistsave[4];
	newgame.who.gamemap.herolist.fulunum=save_start.herolistsave[5];
	newgame.who.gamemap.herolist.athomenum=save_start.herolistsave[6];
	newgame.who.gamemap.herolist.otherwjnum=save_start.herolistsave[7];
	newgame.who.gamemap.herolist.otherjznum=save_start.herolistsave[8];
	newgame.who.gamemap.herolist.count=save_start.herolistsave[9];
	newgame.who.gamemap.herolist.listno=save_start.herolistsave[10];
	newgame.who.gamemap.herolist.ownernum=save_start.herolistsave[11];
	
	newgame.who.gamemap.citylist.unx=save_start.citylistsave[0];
	newgame.who.gamemap.citylist.uny=save_start.citylistsave[1];
	newgame.who.gamemap.citylist.number=save_start.citylistsave[2];
	newgame.who.gamemap.citylist.choice=save_start.citylistsave[3];

	newgame.who.gamemap.goodlist.unx=save_start.goodlistsave[0];
	newgame.who.gamemap.goodlist.uny=save_start.goodlistsave[1];
	newgame.who.gamemap.goodlist.number=save_start.goodlistsave[2];
	newgame.who.gamemap.goodlist.choice=save_start.goodlistsave[3];
	newgame.who.gamemap.goodlist.goodnum=save_start.goodlistsave[4];
	newgame.who.gamemap.goodlist.herogoodnum=save_start.goodlistsave[5];
	newgame.who.gamemap.goodlist.count=save_start.goodlistsave[6];
	newgame.who.gamemap.goodlist.listno=save_start.goodlistsave[7];
	newgame.who.gamemap.goodlist.goodowner=save_start.goodlistsave[8];

	newgame.who.gamemap.unx=save_start.gamemapsave[0];
	newgame.who.gamemap.uny=save_start.gamemapsave[1];
	newgame.who.gamemap.currentcitynum=save_start.gamemapsave[2];
	newgame.who.gamemap.choice=save_start.gamemapsave[3];
	newgame.who.gamemap.fight.PubInit(save_start.gamemapsave[3]);
	newgame.who.gamemap.unum=save_start.gamemapsave[8];

	newgame.who.gamemap.citynumber=save_start.gamemapsave[4];
	newgame.who.gamemap.heronumber=save_start.gamemapsave[5];
	newgame.who.gamemap.ownernum=save_start.gamemapsave[6];
	newgame.who.gamemap.unum=save_start.gamemapsave[7];
	newgame.who.gamemap.choice=save_start.gamemapsave[8];

	newgame.who.gamemap.date.year=save_start.year1;
	newgame.who.gamemap.date.month=save_start.month;
	tasknum=save_start.tasknum;
	InitSSS(newgame.who.gamemap.choice);
}

void Game::GetData()
{
	wlogfile(1,__FUNCTION__,"开始",0);
}

void Game::DelMouseMsg(int style)
{
	if(MouseEnable == 0)return;
	if(style == 2)
	{
		if((ng == 1||ng == 3) && newgame.nga == 1 && newgame.who.ngb == 1)
		{
			if(newgame.who.gamemap.flagwar == 1 )//战斗地图
			{
				//else
				{
					int posx = newgame.who.gamemap.fight.fightmap.arrowx;
					int posy = newgame.who.gamemap.fight.fightmap.arrowy;
					int t_posx = (MouseEndX)/80;
					int t_posy = (MouseEndY-50)/80;
					if(posx < t_posx)
					{
						for(int i = 0 ; i < (t_posx-posx);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyRight0,0);
						}
					}
					if(posx > t_posx)
					{
						for(int i = 0 ; i < (posx-t_posx);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyLeft0,0);
						}
					}
					if(posy < t_posy)
					{
						for(int i = 0 ; i < (t_posy-posy);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						}
					}
					if(posy > t_posy)
					{
						for(int i = 0 ; i < (posy-t_posy);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						}
					}
					//SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeySpace,0);
			}
		}
	}
	else if(style == 1)
	{
		if(newgame.who.gamemap.flagwar == 1 && newgame.who.gamemap.fight.flagshowskill > 0)
		{
			if(MouseWheelLen < 30000) SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
			if(MouseWheelLen > 30000) SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
		}
		if(newgame.who.gamemap.flagwar == 1 && newgame.who.gamemap.fight.flagmenuhero > 0)
		{
			if(MouseWheelLen < 30000) SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
			if(MouseWheelLen > 30000) SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
		}
		if(newgame.who.gamemap.flagwar == 1 && newgame.who.gamemap.fight.flagmenu > 0)
		{
			if(MouseWheelLen < 30000) SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
			if(MouseWheelLen > 30000) SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
		}
		if((ng == 1||ng==3) && newgame.nga == 1 && newgame.who.ngb == 0)
		{
			if(MouseWheelLen < 30000) SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
			if(MouseWheelLen > 30000) SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
		}
		else if((ng == 1||ng==3) && newgame.nga == 1 && newgame.who.ngb == 1)
		{
			if(newgame.who.gamemap.ngc >0 )
			{
				if(MouseWheelLen < 30000) SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(MouseWheelLen > 30000) SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
			}
			
		}
		
		
	}
	else if(style == 0)
	{
		if(ng == 0)
		{
			if(MouseEndX >= 25 && MouseEndY >= 220 && MouseEndX <= (25 + 355) && MouseEndY <= (220+155) )
			{
				if(stat == 1)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(stat == 2)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(stat == 3)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 410 && MouseEndY >= 220 && MouseEndX <= (410 + 355) && MouseEndY <= (220+155) )
			{
				if(stat == 0)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				if(stat == 2)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(stat == 3)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 25 && MouseEndY >= 350 && MouseEndX <= (25 + 355) && MouseEndY <= (350+155) )
			{
				if(stat == 0)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(stat == 1)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				if(stat == 3)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 410 && MouseEndY >= 350 && MouseEndX <= (410 + 355) && MouseEndY <= (350+155) )
			{
				if(stat == 0)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(stat == 1)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(stat == 2)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
		
		}
		else if((ng == 1||ng == 3) && newgame.nga == 0)
		{
			if(MouseEndX >= 8 && MouseEndY >= 120 && MouseEndX <= (8 + 390) && MouseEndY <= (120+165) )
			{
				if(newgame.stata == 1)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(newgame.stata == 2)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.stata == 3)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 390) && MouseEndY <= (120+165) )
			{
				if(newgame.stata == 0)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.stata == 1)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				if(newgame.stata == 3)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 8 && MouseEndY >= 305 && MouseEndX <= ( 8 + 390) && MouseEndY <= (305+165) )
			{
				if(newgame.stata == 0)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				if(newgame.stata == 2)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(newgame.stata == 3)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 410 && MouseEndY >= 305 && MouseEndX <= (410 + 390) && MouseEndY <= (305+165) )
			{
				if(newgame.stata == 0)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(newgame.stata == 1)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.stata == 2)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 745 && MouseEndY >= 50 && MouseEndX <= (745 + 45) && MouseEndY <= (50+45) )
			{
				SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
			}
		}
		else if(ng == 2 )
		{
			if(MouseEndX >= 155 && MouseEndY >= 220 && MouseEndX <= (155 + 480) && MouseEndY <= (220+70) )
			{
				if(save_start.count == 1)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(save_start.count == 2)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 155 && MouseEndY >= 290 && MouseEndX <= (155 + 480) && MouseEndY <= (290+70) )
			{
				if(save_start.count == 0)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				if(save_start.count == 2)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 155 && MouseEndY >= 360 && MouseEndX <= ( 155 + 480) && MouseEndY <= (360+70) )
			{
				if(save_start.count == 0)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				if(save_start.count == 1)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 745 && MouseEndY >= 50 && MouseEndX <= (745 + 45) && MouseEndY <= (50+45) )
			{
				SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
			}
		}
		else if(ng == 10 )
		{
			SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
		}
		else if((ng == 1||ng == 3) && newgame.nga == 1 && newgame.who.ngb == 0)
		{
			if(MouseEndX >= 80 && MouseEndY >= 120 && MouseEndX <= (80 + 180) && MouseEndY <= (120+60) )
			{
				if(newgame.who.menu.tmpfx  == 1)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 2)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 3)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 4)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 5)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 80 && MouseEndY >= 180 && MouseEndX <= (80 + 180) && MouseEndY <= (180+60) )
			{
				if(newgame.who.menu.tmpfx  == 0)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 2)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 3)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 4)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 5)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 80 && MouseEndY >= 240 && MouseEndX <= (80 + 180) && MouseEndY <= (240+60) )
			{
				if(newgame.who.menu.tmpfx  == 0)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 1)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 3)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 4)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 5)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 80 && MouseEndY >= 300 && MouseEndX <= (80 + 180) && MouseEndY <= (300+60) )
			{
				if(newgame.who.menu.tmpfx  == 0)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 1)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 2)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 4)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				if(newgame.who.menu.tmpfx  == 5)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 80 && MouseEndY >= 360 && MouseEndX <= (80 + 180) && MouseEndY <= (360+60) )
			{
				if(newgame.who.menu.tmpfx  == 0)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 1)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 2)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 3)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 5)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 80 && MouseEndY >= 420 && MouseEndX <= (80 + 180) && MouseEndY <= (420+60) )
			{
				if(newgame.who.menu.tmpfx  == 0)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 1)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 2)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 3)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				if(newgame.who.menu.tmpfx  == 4)
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
			}
			else if(MouseEndX >= 745 && MouseEndY >= 50 && MouseEndX <= (745 + 45) && MouseEndY <= (50+45) )
			{
				SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
			}
		}
		else if((ng == 1||ng == 3) && newgame.nga == 1 && newgame.who.ngb == 1)
		{
			if(operateflag > 0)//400,100,530,230
			{
				if(newgame.who.gamemap.operate.style == -1)
				{
					if(MouseEndX >= 400 && MouseEndY >= 100 && MouseEndX <= (530) && MouseEndY <= (230) )
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
					}
					else
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
					}
				}
				else//200,200,600,400
				{
					if(MouseEndX >= 200 && MouseEndY >= 200 && MouseEndX <= (600) && MouseEndY <= (400) )
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
					}
					else
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
					}
				}
			}
			else if(newgame.who.gamemap.flagwar == 1 && newgame.who.gamemap.fight.flagshowskill == 1)//战斗技能菜单
			{
				int max = useableskillnum2;
				if(max >=1 && MouseEndX >= 420 && MouseEndY >= 220 && MouseEndX <= (420 + 120) && MouseEndY <= (220+60) )
				{
					if(newgame.who.gamemap.fight.menuspeed.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(max >=2 && MouseEndX >= 420 && MouseEndY >= (220+60) && MouseEndX <= (420 + 120) && MouseEndY <= (220+120) )
				{
					if(newgame.who.gamemap.fight.menuspeed.tmpfx == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else if(newgame.who.gamemap.flagwar == 1 &&  newgame.who.gamemap.fight.flagmenuhero== 1)//hero菜单
			{
				if(MouseEndX >= 400 && MouseEndY >= 200 && MouseEndX <= (400 + 240) && MouseEndY <= (200+60) )
				{
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menuhero.tmpfx == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 400 && MouseEndY >= (200+60) && MouseEndX <= (400 + 240) && MouseEndY <= (200+120) )
				{
					if(newgame.who.gamemap.fight.menuhero.tmpfx == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 400 && MouseEndY >=(200+120) && MouseEndX <= (400 + 240) && MouseEndY <= (200+180))
				{
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 400 && MouseEndY >= (200+180) && MouseEndX <= (400 + 240) && MouseEndY <= (200+240) )
				{
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menuhero.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				
				
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else if(newgame.who.gamemap.flagwar == 1 && newgame.who.gamemap.fight.flagmenushow == 1)//menushow
			{
				if(MouseEndX >= 290 && MouseEndY >= 200 && MouseEndX <= (290 + 120) && MouseEndY <= (200+60) )
				{
					if(newgame.who.gamemap.fight.menushow.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 290 && MouseEndY >= (200+60) && MouseEndX <= (290 + 120) && MouseEndY <= (200+120) )
				{
					if(newgame.who.gamemap.fight.menushow.tmpfx == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else if(newgame.who.gamemap.flagwar == 1 && newgame.who.gamemap.fight.flagmenuspeed == 1)//menuspeed 
			{
				if(MouseEndX >= 290 && MouseEndY >= 200 && MouseEndX <= (290 + 120) && MouseEndY <= (200+60) )
				{
					if(newgame.who.gamemap.fight.menuspeed.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 290 && MouseEndY >= (200+60) && MouseEndX <= (290 + 120) && MouseEndY <= (200+120) )
				{
					if(newgame.who.gamemap.fight.menuspeed.tmpfx == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else if(newgame.who.gamemap.flagwar == 1 && newgame.who.gamemap.fight.flagmenumov == 1)//menumove
			{
				if(MouseEndX >= 290 && MouseEndY >= 200 && MouseEndX <= (290 + 120) && MouseEndY <= (200+60) )
				{
					if(newgame.who.gamemap.fight.menumove.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 290 && MouseEndY >= (200+60) && MouseEndX <= (290 + 120) && MouseEndY <= (200+120) )
				{
					if(newgame.who.gamemap.fight.menumove.tmpfx == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else if(newgame.who.gamemap.flagwar == 1 &&  newgame.who.gamemap.fight.flagmenu == 1)//战斗主菜单
			{
				if(MouseEndX >= 30 && MouseEndY >= 80 && MouseEndX <= (30 + 300) && MouseEndY <= (80+60) )
				{
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 30 && MouseEndY >= (80+60) && MouseEndX <= (30 + 300) && MouseEndY <= (80+120) )
				{
					if(newgame.who.gamemap.fight.menufight.tmpfx == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 30 && MouseEndY >=(80+120) && MouseEndX <= (30 + 300) && MouseEndY <= (80+180))
				{
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 30 && MouseEndY >= (80+180) && MouseEndX <= (30 + 300) && MouseEndY <= (80+240) )
				{
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 30 && MouseEndY >= (80+240) && MouseEndX <= (30 + 300) && MouseEndY <= (80+300) )
				{
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					if(newgame.who.gamemap.fight.menufight.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else if(newgame.who.gamemap.flagwar == 1 && newgame.who.gamemap.fight.flagstat == 0 && newgame.who.gamemap.fight.flagmenu == 0)//战斗地图
			{
				//判断起始及结束坐标
				if((MouseEndX - MouseStartX) > 50)//滚动
				{
					int times = (MouseEndX - MouseStartX)/50;
					for(int i = 0 ; i < times;i++)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyLeft0,0);
					}
				}
				else if((MouseStartX - MouseEndX) > 50)//滚动
				{
					int times = (MouseStartX - MouseEndX)/50;
					for(int i = 0 ; i < times;i++)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyRight0,0);
					}
				}
				else if((MouseEndY - MouseStartY) > 50)//滚动
				{
					int times = (MouseEndY - MouseStartY)/50;
					for(int i = 0 ; i < times;i++)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
				}
				else if((MouseStartY - MouseEndY) > 50)//滚动
				{
					int times = (MouseStartY - MouseEndY)/50;
					for(int i = 0 ; i < times;i++)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
				}
				else if(MouseEndX >= FIGHTLEFTARROWX && MouseEndY >= (FIGHTLEFTARROWY+50) && MouseEndX <= (FIGHTLEFTARROWX + 24) && MouseEndY <= (FIGHTLEFTARROWY+50+32) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyLeft0,0);
				}
				else if(MouseEndX >= FIGHTRIGHTARROWX && MouseEndY >= (FIGHTRIGHTARROWY+50) && MouseEndX <= (FIGHTRIGHTARROWX + 24) && MouseEndY <= (FIGHTRIGHTARROWY+50+32) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyRight0,0);
				}
				else if(MouseEndX >= FIGHTUPARROWX && MouseEndY >= (FIGHTUPARROWY+50) && MouseEndX <= (FIGHTUPARROWX + 32) && MouseEndY <= (FIGHTUPARROWY+50+24) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				else if(MouseEndX >= FIGHTDOWNARROWX && MouseEndY >= (FIGHTDOWNARROWY+50) && MouseEndX <= (FIGHTDOWNARROWX + 32) && MouseEndY <= (FIGHTDOWNARROWY+50+24) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				else if(MouseEndX >= FIGHTMENUX && MouseEndY >= (FIGHTMENUY+50) && MouseEndX <= (FIGHTMENUX + 200) && MouseEndY <= (FIGHTMENUY+100) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
				else
				{
					int posx = newgame.who.gamemap.fight.fightmap.arrowx;
					int posy = newgame.who.gamemap.fight.fightmap.arrowy;
					int t_posx = (MouseEndX)/80;
					int t_posy = (MouseEndY-50)/80;
					if(posx < t_posx)
					{
						for(int i = 0 ; i < (t_posx-posx);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyRight0,0);
						}
					}
					if(posx > t_posx)
					{
						for(int i = 0 ; i < (posx-t_posx);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyLeft0,0);
						}
					}
					if(posy < t_posy)
					{
						for(int i = 0 ; i < (t_posy-posy);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						}
					}
					if(posy > t_posy)
					{
						for(int i = 0 ; i < (posy-t_posy);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						}
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
			}
			else if(newgame.who.gamemap.flagwar == 0 && newgame.who.gamemap.ngsave == 0 && newgame.who.gamemap.ngc == 0)//主地图
			{
				//判断起始及结束坐标
				if((MouseEndX - MouseStartX) > 50)//滚动
				{
					int times = (MouseEndX - MouseStartX)/50;
					for(int i = 0 ; i < times;i++)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyLeft0,0);
					}
				}
				else if((MouseStartX - MouseEndX) > 50)//滚动
				{
					int times = (MouseStartX - MouseEndX)/50;
					for(int i = 0 ; i < times;i++)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyRight0,0);
					}
				}
				else if((MouseEndY - MouseStartY) > 50)//滚动
				{
					int times = (MouseEndY - MouseStartY)/50;
					for(int i = 0 ; i < times;i++)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
				}
				else if((MouseStartY - MouseEndY) > 50)//滚动
				{
					int times = (MouseStartY - MouseEndY)/50;
					for(int i = 0 ; i < times;i++)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
				}
				else if(MouseEndX >= MAINLEFTARROWX && MouseEndY >= (MAINLEFTARROWY+50) && MouseEndX <= (MAINLEFTARROWX + 24) && MouseEndY <= (MAINLEFTARROWY+50+32) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyLeft0,0);
				}
				else if(MouseEndX >= MAINRIGHTARROWX && MouseEndY >= (MAINRIGHTARROWY+50) && MouseEndX <= (MAINRIGHTARROWX + 24) && MouseEndY <= (MAINRIGHTARROWY+50+32) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyRight0,0);
				}
				else if(MouseEndX >= MAINUPARROWX && MouseEndY >= (MAINUPARROWY+50) && MouseEndX <= (MAINUPARROWX + 32) && MouseEndY <= (MAINUPARROWY+50+24) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
				}
				else if(MouseEndX >= MAINDOWNARROWX && MouseEndY >= (MAINDOWNARROWY+50) && MouseEndX <= (MAINDOWNARROWX + 32) && MouseEndY <= (MAINDOWNARROWY+50+24) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				else if(MouseEndX >= MAINMENUX && MouseEndY >= (MAINMENUY+50) && MouseEndX <= (MAINMENUX + 100) && MouseEndY <= (MAINMENUY+100) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
				else
				{
					int posx = newgame.who.gamemap.unx-newgame.who.gamemap.zbx/90;
					int posy = newgame.who.gamemap.uny-newgame.who.gamemap.zby/80;
					int t_posx = (MouseEndX-12)/90;
					int t_posy = (MouseEndY-50-35)/80;
					if(posx < t_posx)
					{
						for(int i = 0 ; i < (t_posx-posx);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyRight0,0);
						}
					}
					if(posx > t_posx)
					{
						for(int i = 0 ; i < (posx-t_posx);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyLeft0,0);
						}
					}
					if(posy < t_posy)
					{
						for(int i = 0 ; i < (t_posy-posy);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						}
					}
					if(posy > t_posy)
					{
						for(int i = 0 ; i < (posy-t_posy);i++)
						{
							SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						}
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}

			}
			else  if(newgame.who.gamemap.ngc == 1 && newgame.who.gamemap.ngsave == 0)//escmenu
			{
				if(MouseEndX >= 300 && MouseEndY >= 100 && MouseEndX <= (300 + 240) && MouseEndY <= (100+60) )
				{
					if(newgame.who.gamemap.escmenu.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.escmenu.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 300 && MouseEndY >= 100 && MouseEndX <= (300 + 240) && MouseEndY <= (100+120) )
				{
					if(newgame.who.gamemap.escmenu.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.escmenu.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 300 && MouseEndY >= 100 && MouseEndX <= (300 + 240) && MouseEndY <= (100+180) )
				{
					if(newgame.who.gamemap.escmenu.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.escmenu.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else //if(MouseEndX >= 0 && MouseEndY >= 500 && MouseEndX <= (0 + 100) && MouseEndY <= (500+50) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else if(newgame.who.gamemap.ngsave == 1 )
			{
				if(MouseEndX >= 155 && MouseEndY >= 220 && MouseEndX <= (155 + 480) && MouseEndY <= (220+70) )
				{
					if(newgame.who.gamemap.save.count == 1)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					if(newgame.who.gamemap.save.count == 2)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 155 && MouseEndY >= 290 && MouseEndX <= (155 + 480) && MouseEndY <= (290+70) )
				{
					if(newgame.who.gamemap.save.count == 0)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					if(newgame.who.gamemap.save.count == 2)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 155 && MouseEndY >= 360 && MouseEndX <= ( 155 + 480) && MouseEndY <= (360+70) )
				{
					if(newgame.who.gamemap.save.count == 0)SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					if(newgame.who.gamemap.save.count == 1)SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 745 && MouseEndY >= 50 && MouseEndX <= (745 + 45) && MouseEndY <= (50+45) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else  if(newgame.who.gamemap.ngc == 2 && newgame.who.gamemap.ngsecond1 == 0)//citymenu
			{
				if(MouseEndX >= 300 && MouseEndY >= 100 && MouseEndX <= (300 + 240) && MouseEndY <= (100+60) )
				{
					if(newgame.who.gamemap.citymenu.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.citymenu.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.citymenu.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 300 && MouseEndY >= 100 && MouseEndX <= (300 + 240) && MouseEndY <= (100+120) )
				{
					if(newgame.who.gamemap.citymenu.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.citymenu.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.citymenu.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 300 && MouseEndY >= 100 && MouseEndX <= (300 + 240) && MouseEndY <= (100+180) )
				{
					if(newgame.who.gamemap.citymenu.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.citymenu.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.citymenu.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 300 && MouseEndY >= 100 && MouseEndX <= (300 + 240) && MouseEndY <= (100+240) )
				{
					if(newgame.who.gamemap.citymenu.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.citymenu.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.citymenu.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
				
			}
			else  if(newgame.who.gamemap.ngc == 2 && newgame.who.gamemap.ngsecond1 == 1 && newgame.who.gamemap.ngthird1 == 0)//neizhengmenu
			{
				if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+60) )
				{
					if(newgame.who.gamemap.secondmenu1.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+120) )
				{
					if(newgame.who.gamemap.secondmenu1.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+180) )
				{
					if(newgame.who.gamemap.secondmenu1.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+240) )
				{
					if(newgame.who.gamemap.secondmenu1.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+300) )
				{
					if(newgame.who.gamemap.secondmenu1.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+360) )
				{
					if(newgame.who.gamemap.secondmenu1.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else  if(newgame.who.gamemap.ngc == 2 && newgame.who.gamemap.ngsecond1 == 2 && newgame.who.gamemap.ngthird1 == 0)//外交menu
			{
				if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+60) )
				{
					if(newgame.who.gamemap.secondmenu2.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+120) )
				{
					if(newgame.who.gamemap.secondmenu2.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+180) )
				{
					if(newgame.who.gamemap.secondmenu2.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+240) )
				{
					if(newgame.who.gamemap.secondmenu2.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+300) )
				{
					if(newgame.who.gamemap.secondmenu2.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu2.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
				
			}
			
			else  if(newgame.who.gamemap.ngc == 2 && newgame.who.gamemap.ngsecond1 == 3 && newgame.who.gamemap.ngthird1 == 0)//军备menu
			{
				if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+60) )
				{
					if(newgame.who.gamemap.secondmenu3.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+120) )
				{
					if(newgame.who.gamemap.secondmenu3.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+180) )
				{
					if(newgame.who.gamemap.secondmenu3.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu1.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+240) )
				{
					if(newgame.who.gamemap.secondmenu3.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+300) )
				{
					if(newgame.who.gamemap.secondmenu3.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(MouseEndX >= 410 && MouseEndY >= 120 && MouseEndX <= (410 + 240) && MouseEndY <= (120+360) )
				{
					if(newgame.who.gamemap.secondmenu3.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.secondmenu3.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else  if(newgame.who.gamemap.ngc == 3)
			{
				if(MouseEndX >= 630 && MouseEndY >= 50 && MouseEndX <= (630 + 50) && MouseEndY <= (50+50) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
				else if(MouseEndX >= 140 && MouseEndY >= 50 && MouseEndX <= (140 + 690) && MouseEndY <= (50+450) )
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
				}
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
			else if(newgame.who.gamemap.ngthird1 >0)//武将列表
			{
				//10,55,785,heronu>5?475:(heronu+1)*60+55
				int heronu1 = newgame.who.gamemap.herolist.heronu;
				int max = heronu1>5?6:heronu1;
				//(heronu1>5?475:(heronu1+1)*60+55);
				if(max >= 1 && MouseEndX >= 10 && MouseEndY >= 115 && MouseEndX <= 785 && MouseEndY <= 175 )
				{
					if(newgame.who.gamemap.herolist.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(max >= 2 && MouseEndX >= 10 && MouseEndY >= 175 && MouseEndX <= 785 &&  MouseEndY <= 235  )
				{
					if(newgame.who.gamemap.herolist.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(max >= 3 && MouseEndX >= 10 && MouseEndY >= 235 && MouseEndX <= 785 &&  MouseEndY <= 295  )
				{
					if(newgame.who.gamemap.herolist.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(max >= 4 && MouseEndX >= 10 && MouseEndY >= 295 && MouseEndX <= 785 &&  MouseEndY <= 355  )
				{
					if(newgame.who.gamemap.herolist.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(max >= 5 && MouseEndX >= 10 && MouseEndY >= 355 && MouseEndX <= 785 &&  MouseEndY <= 415  )
				{
					if(newgame.who.gamemap.herolist.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 5)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyUp0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else if(max >= 6 && MouseEndX >= 10 && MouseEndY >= 415 && MouseEndX <= 785 &&  MouseEndY <= 475  )
				{
					if(newgame.who.gamemap.herolist.tmpfx  == 0)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 1)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 2)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 3)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					else if(newgame.who.gamemap.herolist.tmpfx  == 4)
					{
						SendMessage(hwnd,WM_KEYDOWN,KeyDown0,0);
					}
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
				else
				{
					SendMessage(hwnd,WM_KEYDOWN,KeyEsc,0);
				}
			}
		}
	}

}