#include "StdAfx.h"
#include "eb_api.h"		//	CAXA EB API 函数
#include "funcdef.h"	//	包含用户消息响应函数声明的头文件
#include "resource.h"
	
FUNTABLE  ft[] = {
//	TODO:	添加消息响应函数与对应ID值的对应组并删除下面的NULL
	{ID_GENTWOEDGEGROOVE,AppGenerateGrooveByTwoEdge},
	{ID_GENONEEDGEGROOVE,AppGenerateGrooveByOneEdge},
	{ID_GENTWOEDGEHOLE,AppGenerateHoleByTwoEdge},
	{ID_GENONEEDGEHOLE,AppGenerateHoleByOneEdge},
	{ID_GENHOLEENDGROOVE,AppGenerateGrooveOnEndSurface},
	{ID_GENHOLEMIDGROOVE,AppGenerateGrooveOnMid},
	{ID_GENHOLEMIDARCGROOVE,AppGenerateArcGrooveOnMid},
	{ID_GENAXISENDGROOVE,AppGenerateGrooveOnAxisEnd},
	{ID_GENAXISMIDGROOVE,AppGenerateGrooveOnAxisMid},
	{ID_GENAXISMIDARCGROOVE,AppGenerateArcGrooveOnAxisMid},
	{ID_GENAXISMIDANGGROOVE,AppGenerateAngGrooveOnAxisMid}
};

CMDDTABLE  pCmd[] = {
//	TODO:	添加执行消息响应函数的命令名与对应ID值的对应组并删除下面的NULL
	NULL
};

void STARTUP()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

	AfxGetApp()->m_pMainWnd=new CFrameWnd;
	AfxGetApp()->m_pMainWnd->m_hWnd=ebGetMainFrame()->m_hWnd;

	for(int i=0; i<ELEMENTS(ft); i++)
		ebRegistFunc(&ft[i]);

	for(i=0; i<ELEMENTS(pCmd); i++)
		ebRegistCmd(&pCmd[i]);

	//	TODO:	定制用户界面,例如加载用户自定义的菜单等

	//	TODO:	添加其他初始化信息

}

void FINISH()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
	
	for(int i=0; i<ELEMENTS(ft); i++)
		ebDelFunc(&ft[i]);

	for(i=0; i<ELEMENTS(pCmd); i++)
		ebDelCmd(&pCmd[i]);

	//	TODO:	添加应用程序终止时的处理,如删除掉在STARTUP()
	//			函数中加载的用户自定义菜单


	ASSERT(AfxGetMainWnd()!=NULL);
	AfxGetMainWnd()->m_hWnd=NULL;
	delete AfxGetMainWnd();
}


////////////////////////////////////////////////////////////////////
//	注册构件库

struct CONITEM	//	构件描述结构
{
	int m_iCmdID;	//	命令ID
	int m_iNameID;	//	名字字符串资源ID
	int m_iBmpID;	//	位图资源ID
	int m_iFuncID;	//	功能说明字符串资源ID
};

CONITEM pCon[]= {
//	TODO:	添加构件库描述数组并删除下面的NULL
	{ID_GENTWOEDGEGROOVE,IDS_NAME_STRING1,IDB_BITMAP1,IDS_EXP_STRING1},
	{ID_GENONEEDGEGROOVE,IDS_NAME_STRING2,IDB_BITMAP2,IDS_EXP_STRING2},
	{ID_GENTWOEDGEHOLE,IDS_NAME_STRING3,IDB_BITMAP3,IDS_EXP_STRING3},
	{ID_GENONEEDGEHOLE,IDS_NAME_STRING4,IDB_BITMAP4,IDS_EXP_STRING4},
	{ID_GENHOLEENDGROOVE,IDS_NAME_STRING5,IDB_BITMAP5,IDS_EXP_STRING5},
	{ID_GENHOLEMIDGROOVE,IDS_NAME_STRING6,IDB_BITMAP6,IDS_EXP_STRING6},
	{ID_GENHOLEMIDARCGROOVE,IDS_NAME_STRING7,IDB_BITMAP7,IDS_EXP_STRING7},
	{ID_GENAXISENDGROOVE,IDS_NAME_STRING8,IDB_BITMAP8,IDS_EXP_STRING8},
	{ID_GENAXISMIDGROOVE,IDS_NAME_STRING9,IDB_BITMAP9,IDS_EXP_STRING9},
	{ID_GENAXISMIDARCGROOVE,IDS_NAME_STRING10,IDB_BITMAP10,IDS_EXP_STRING10},
	{ID_GENAXISMIDANGGROOVE,IDS_NAME_STRING11,IDB_BITMAP11,IDS_EXP_STRING11}
};

LPCTSTR WINAPI REGCON(CONITEM** pConArray,int* iConNum)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

	*pConArray=pCon;
	*iConNum=ELEMENTS(pCon);

	//	TODO:	设置构件库的描述
	return _T("构件库实例(洁角、止锁孔、退刀槽)");
}
