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

📄 mon.cpp

📁 monlibs
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// MON.cpp : 定义 DLL 的初始化例程。
//

#include "stdafx.h"
#include "MON.h"
#include "Asm1_1Dlg.h"
#include "Asm2_1Dlg.h"
#include "Asm7_1Dlg.h"
#include "SettingDlg.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define ACTION_TYPE( v, f )	\
    p_visit_action_type=v;	\
    p_filter_action_type=f;

static char             *p_visit_action_type = "";
static char             *p_filter_action_type = "";

/*-------------------------------------------------*\
	ENUM变量
\*-------------------------------------------------*/
enum{RETVAL_PRT1_1=100};	
enum{RETVAL_PRT2_1=110};
enum{RETVAL_PRT3_1=120};
enum{RETVAL_ASM1_1=200,RETVAL_ASM1_2,RETVAL_ASM1_3,RETVAL_ASM1_4,RETVAL_ASM1_5,RETVAL_ASM1_6
		,RETVAL_ASM1_7};	
enum{RETVAL_ASM2_1=290};
enum{RETVAL_ASM3_1=300};
enum{RETVAL_ASM4_1=310};
enum{RETVAL_ASM5_1=320};
enum{RETVAL_ASM6_1=330};
enum{RETVAL_ASM7_1=340};
enum{RETVAL_ASM8_1=350};
enum{RETVAL_ASM9_1=360,RETVAL_ASM9_2,RETVAL_ASM9_3,RETVAL_ASM9_4,RETVAL_ASM9_5,RETVAL_ASM9_6
		,RETVAL_ASM9_7,RETVAL_ASM9_8,RETVAL_ASM9_9,RETVAL_ASM9_10,RETVAL_ASM9_11};
enum{RETVAL_ASM10_1=380};
enum{RETVAL_ASM11_1=390};
enum{RETVAL_ASM12_1=400};

enum{ACTION_1=100,ACTION_2=200,ACTION_3=300,ACTION_4=400};
enum {WARN_EXIT=1,WARN_RETURN,NO_READ_FILE,NO_WRITE_FILE,NO_PART_SELECT,
	  PARAM_ERROR};

/*-------------------------------------------------*\
	全局变量
\*-------------------------------------------------*/
ProName UserMsg,MenuMsg;
//static char revcode[81];
static char RetChar[PRO_LINE_SIZE];
static char astr1[120];

//模型库文件的位置,从系统变量 PRO_LIBRARY_DIR 读取设置
CString libpath;

/*-------------------------------------------------*\
	prt模式下菜单
\*-------------------------------------------------*/
static char *MTitle_prt1 = "xc";//型材
static char *MIdent_prt1 = "xc";//型材
static char *MRefer_prt1 = "xc";//型材
static char *MFunc_prt1_1  = "gzg";//"工字钢";
static char *MFunc_prt1_2  = "cg";//"槽钢";
static char *MFunc_prt1_3  = "jg";//"角钢";
static char *MFunc_prt1_4  = "yg";//"圆钢";
static char *MFunc_prt1_5  = "fg";//"方钢";
static char *MFunc_prt1_6  = "ljg";//"六角钢";
static char *MFunc_prt1_7  = "hjgg";//"焊接钢管";

static char *MTitle_prt2 = "cl";//齿轮
static char *MIdent_prt2 = "cl";//齿轮
static char *MRefer_prt2 = "cl";//齿轮

static char *MTitle_prt3 = "th";//弹簧
static char *MIdent_prt3 = "th";//弹簧
static char *MRefer_prt3 = "th";//弹簧
/*-------------------------------------------------*\
	asm模式下菜单
\*-------------------------------------------------*/
static char *MTitle_asm1 = "ljyjgj";//"连接与紧固件";
static char *MIdent_asm1 = "ljyjgj";//"连接与紧固件";
static char *MRefer_asm1 = "ljyjgj";//"连接与紧固件";
static char *MFunc_asm1_1  = "ls";//"螺栓";
static char *MFunc_asm1_2  = "lm";//"螺母";
static char *MFunc_asm1_3  = "ld";//"螺钉";
static char *MFunc_asm1_4  = "dq";//"垫圈";
static char *MFunc_asm1_5  = "xz";//"销子";
static char *MFunc_asm1_6  = "md";//"铆钉";
static char *MFunc_asm1_7  = "zhj";//"组合件";

static char *MTitle_asm2 = "zc";//"轴承";
static char *MIdent_asm2 = "zc";//"轴承";
static char *MRefer_asm2 = "zc";//"轴承";

static char *MTitle_asm3 = "fl";//"法兰";
static char *MIdent_asm3 = "fl";//"法兰";
static char *MRefer_asm3 = "fl";//"法兰";

static char *MTitle_asm4 = "cl";//"齿轮";
static char *MIdent_asm4 = "cl";//"齿轮";
static char *MRefer_asm4 = "cl";//"齿轮";

static char *MTitle_asm5 = "th";//"弹簧";
static char *MIdent_asm5 = "th";//"弹簧";
static char *MRefer_asm5 = "th";//"弹簧";

static char *MTitle_asm6 = "mj";//"模架";
static char *MIdent_asm6 = "mj";//"模架";
static char *MRefer_asm6 = "mj";//"模架";

static char *MTitle_asm7 = "xc";//"型材";
static char *MIdent_asm7 = "xc";//"型材";
static char *MRefer_asm7 = "xc";//"型材";

static char *MTitle_asm8 = "yyqd";//"液压气动";
static char *MIdent_asm8 = "yyqd";//"液压气动";
static char *MRefer_asm8 = "yyqd";//"液压气动";

static char *MTitle_asm9 = "jj";//"夹具";
static char *MIdent_asm9 = "jj";//"夹具";
static char *MRefer_asm9 = "jj";//"夹具";
static char *MFunc_asm9_1  = "czj";//"操作件";
static char *MFunc_asm9_2  = "dxj";//"导向件";
static char *MFunc_asm9_3  = "dwj";//"定位件";
static char *MFunc_asm9_4  = "ddj";//"对刀件";
static char *MFunc_asm9_5  = "ddingj";//"对定件";
static char *MFunc_asm9_6  = "fzzc";//"辅助支撑";
static char *MFunc_asm9_7  = "jjj";//"夹紧件";
static char *MFunc_asm9_8  = "zzzj";//"支柱支脚";
static char *MFunc_asm9_9  = "qtj";//"其它件";
static char *MFunc_asm9_10  = "jq";//"夹钳";
static char *MFunc_asm9_11  = "mfq";//"密封圈";


static char *MTitle_asm10 = "dq";//"电气";
static char *MIdent_asm10 = "dq";//"电气";
static char *MRefer_asm10 = "dq";//"电气";

static char *MTitle_asm11 = "motor";//"电机";
static char *MIdent_asm11 = "motor";//"电机";
static char *MRefer_asm11 = "motor";//"电机";

static char *MTitle_asm12 = "qita";//"其它";
static char *MIdent_asm12 = "qita";//"其它";
static char *MRefer_asm12 = "qita";//"其它";

//static char *MTitle_drw1 = "drw1";//
//static char *MIdent_drw1 = "drw1";//
//static char *MRefer_drw1 = "drw1";//

BEGIN_MESSAGE_MAP(CMONApp, CWinApp)
END_MESSAGE_MAP()


// CMONApp 构造

CMONApp::CMONApp()
{
	// TODO: 在此处添加构造代码,
	// 将所有重要的初始化放置在 InitInstance 中
}


// 唯一的一个 CMONApp 对象

CMONApp theApp;


// CMONApp 初始化

BOOL CMONApp::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();
//	this->SetDialogBkColor(RGB(235,233,237));


	return TRUE;
}


int (*MenuButton1)(void * , int) = (int (__cdecl *)(void *,int))MakeSubMenu;
int (*MenuButton2)(void * , int) = (int (__cdecl *)(void *,int))MenuPick;


/////////////////////////////////////////////////////////
static uiCmdAccessState uiAccessAvailable (uiCmdAccessMode access_mode)
{
	return ACCESS_AVAILABLE;
}
void SettingFn()  //库参数设置消息响应函数
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	CSettingDlg dlg;
	dlg.DoModal();
	UsrActivateCurrentWindow();
}

///////////////////////////////////////////////////////////
extern "C"	int user_initialize(int argc,char *argv[],char *version,char *build,wchar_t errbuf[])	 
{
	int ProInt;

	//取得系统环境变量PRO_MONLIB_PATH值
	char * descr = getenv("MONLIBS_DIR"); 
	libpath=descr;
	
	if ( ProWcharSizeVerify ( sizeof(wchar_t) , &ProInt ))
	{
	  ProStringToWstring(errbuf, astr1);
	  return(-1);
	}  



	ProStringToWstring (UserMsg, "message.txt");
	if(libpath.Right(1)==_T("\\"))
	{
		libpath=libpath.Left(libpath.GetLength()-1);
	}
	/*-------------------------------------------------*\
		挂上库菜单
	\*-------------------------------------------------*/
	/*
	ProMenuFileRegister ("part", "part.mnu",NULL);
	ProMenuAuxfileRegister ("part","part.aux",NULL);
	ProMenubuttonActionSet ("part",MTitle_prt1,MenuButton2,RetChar,RETVAL_PRT1_1);
	ProMenubuttonActionSet ("part",MTitle_prt2,MenuButton2,RetChar,RETVAL_PRT2_1);
	ProMenubuttonActionSet ("part",MTitle_prt3,MenuButton2,RetChar,RETVAL_PRT3_1);
	ProMenubuttonActionSet ("part","part",MenuButton1,RetChar,0);
	*/

	ProMenuFileRegister ("assembly", "assembly.mnu",NULL);
	ProMenuAuxfileRegister ("assembly","assembly.aux",NULL);
	ProMenubuttonActionSet ("assembly",MTitle_asm1,MenuButton1,RetChar,10);//连接件与紧固件
	ProMenubuttonActionSet ("assembly",MTitle_asm2,MenuButton2,RetChar,RETVAL_ASM2_1);//轴承
	ProMenubuttonActionSet ("assembly",MTitle_asm3,MenuButton2,RetChar,RETVAL_ASM3_1);//法兰
	ProMenubuttonActionSet ("assembly",MTitle_asm4,MenuButton2,RetChar,RETVAL_ASM4_1);//齿轮
	ProMenubuttonActionSet ("assembly",MTitle_asm5,MenuButton2,RetChar,RETVAL_ASM5_1);//弹簧
	ProMenubuttonActionSet ("assembly",MTitle_asm6,MenuButton2,RetChar,RETVAL_ASM6_1);//模架
	ProMenubuttonActionSet ("assembly",MTitle_asm7,MenuButton2,RetChar,RETVAL_ASM7_1);//型材
	ProMenubuttonActionSet ("assembly",MTitle_asm8,MenuButton2,RetChar,RETVAL_ASM8_1);//液压气动
	ProMenubuttonActionSet ("assembly",MTitle_asm9,MenuButton1,RetChar,9);//夹具
	ProMenubuttonActionSet ("assembly",MTitle_asm10,MenuButton2,RetChar,RETVAL_ASM10_1);//电气
	ProMenubuttonActionSet ("assembly",MTitle_asm11,MenuButton2,RetChar,RETVAL_ASM11_1);//电机
	ProMenubuttonActionSet ("assembly",MTitle_asm12,MenuButton2,RetChar,RETVAL_ASM12_1);//其它
	ProMenubuttonActionSet ("assembly","assembly",MenuButton1,RetChar,0);

//	ProMenuFileRegister ("drawing", "draw.mnu",NULL);
//	ProMenuAuxfileRegister ("drawing","draw.aux",NULL);
//	ProMenubuttonActionSet ("drawing",MTitle_drw1,MenuButton2,RetChar,RETVAL_PRT1_1);



	return (0);
}

extern "C"	void user_terminate(void)
{
	return;
}

/////////////////////////////////////////////////////////
int MakeSubMenu(char *RetChar , int nothing)
{
	int MenuId;
	int ProcVal;

	switch(nothing){
		case 0:
			ProMenuDelete();
			break;
		case 10:
			//连接件与紧固件菜单
			ProMenuFileRegister (MIdent_asm1, "action_asm1.mnu",NULL);
			ProMenubuttonActionSet (MIdent_asm1,MFunc_asm1_1,MenuButton2,RetChar,RETVAL_ASM1_1);
			ProMenubuttonActionSet (MIdent_asm1,MFunc_asm1_2,MenuButton2,RetChar,RETVAL_ASM1_2);
			ProMenubuttonActionSet (MIdent_asm1,MFunc_asm1_3,MenuButton2,RetChar,RETVAL_ASM1_3);
			ProMenubuttonActionSet (MIdent_asm1,MFunc_asm1_4,MenuButton2,RetChar,RETVAL_ASM1_4);
			ProMenubuttonActionSet (MIdent_asm1,MFunc_asm1_5,MenuButton2,RetChar,RETVAL_ASM1_5);
			ProMenubuttonActionSet (MIdent_asm1,MFunc_asm1_6,MenuButton2,RetChar,RETVAL_ASM1_6);
			ProMenubuttonActionSet (MIdent_asm1,MFunc_asm1_7,MenuButton2,RetChar,RETVAL_ASM1_7);
			ProMenubuttonActionSet (MIdent_asm1,"OK",MenuButton2,RetChar,DONE);
			ProMenuCreate (PROMENUTYPE_MAIN,MRefer_asm1,&MenuId);
			ProMenuProcess (MRefer_asm1,&ProcVal);
			break;
		case 9:
			//夹具菜单
			ProMenuFileRegister (MIdent_asm9, "action_asm9.mnu",NULL);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_1,MenuButton2,RetChar,RETVAL_ASM9_1);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_2,MenuButton2,RetChar,RETVAL_ASM9_2);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_3,MenuButton2,RetChar,RETVAL_ASM9_3);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_4,MenuButton2,RetChar,RETVAL_ASM9_4);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_5,MenuButton2,RetChar,RETVAL_ASM9_5);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_6,MenuButton2,RetChar,RETVAL_ASM9_6);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_7,MenuButton2,RetChar,RETVAL_ASM9_7);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_8,MenuButton2,RetChar,RETVAL_ASM9_8);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_9,MenuButton2,RetChar,RETVAL_ASM9_9);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_10,MenuButton2,RetChar,RETVAL_ASM9_10);
			ProMenubuttonActionSet (MIdent_asm9,MFunc_asm9_11,MenuButton2,RetChar,RETVAL_ASM9_11);
			ProMenubuttonActionSet (MIdent_asm9,"OK",MenuButton2,RetChar,DONE);
			ProMenuCreate (PROMENUTYPE_MAIN,MRefer_asm9,&MenuId);
			ProMenuProcess (MRefer_asm9,&ProcVal);
			break;
		default:
			ProMenuDelete();
			break;

	}

	return(0);
}
int MenuPick(char *dummy,int action)
{
	switch(action)
	{	
		case RETVAL_PRT1_1://型材的各个子类
//		Func_prt1_1(dummy,action);
		break;
		case RETVAL_PRT2_1://设计齿轮
//		Func_prt2_1(dummy,action);
		break;

		case RETVAL_PRT3_1://设计弹簧
//		Func_prt3_1(dummy,action);
		break;
       /////////////////////////////
		//连接件与紧固件的各子类
		case RETVAL_ASM1_1:
		Func_asm1_1(dummy,action);
		break;
		case RETVAL_ASM1_2:
		Func_asm1_2(dummy,action);
		break;
		case RETVAL_ASM1_3:
		Func_asm1_3(dummy,action);
		break;
		case RETVAL_ASM1_4:
		Func_asm1_4(dummy,action);
		break;
		case RETVAL_ASM1_5:
		Func_asm1_5(dummy,action);
		break;
		case RETVAL_ASM1_6:
		Func_asm1_6(dummy,action);
		break;
		case RETVAL_ASM1_7:
		Func_asm1_7(dummy,action);
		break;

		case RETVAL_ASM2_1:  //轴承
		Func_asm2_1(dummy,action);
		break;
		case RETVAL_ASM3_1:  //法兰
		Func_asm3_1(dummy,action);
		break;
		case RETVAL_ASM4_1:  //齿轮
		Func_asm4_1(dummy,action);
		break;
		case RETVAL_ASM5_1:  //弹簧
		Func_asm5_1(dummy,action);
		break;
		case RETVAL_ASM6_1:  //模架
		Func_asm6_1(dummy,action);
		break;
		case RETVAL_ASM7_1:  //型材
		Func_asm7_1(dummy,action);
		break;
		case RETVAL_ASM8_1:  //液压气动
		Func_asm8_1(dummy,action);
		break;

		case RETVAL_ASM9_1:  //夹具
		Func_asm9_1(dummy,action);
		break;
		case RETVAL_ASM9_2:
		Func_asm9_2(dummy,action);
		break;
		case RETVAL_ASM9_3:
		Func_asm9_3(dummy,action);
		break;
		case RETVAL_ASM9_4:
		Func_asm9_4(dummy,action);
		break;
		case RETVAL_ASM9_5:
		Func_asm9_5(dummy,action);
		break;
		case RETVAL_ASM9_6:
		Func_asm9_6(dummy,action);
		break;
		case RETVAL_ASM9_7:
		Func_asm9_7(dummy,action);
		break;
		case RETVAL_ASM9_8:
		Func_asm9_8(dummy,action);
		break;
		case RETVAL_ASM9_9:
		Func_asm9_9(dummy,action);
		break;
		case RETVAL_ASM9_10:
		Func_asm9_10(dummy,action);
		break;
		case RETVAL_ASM9_11:

⌨️ 快捷键说明

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