iCAx开思工具箱

标题: 大家看看 [打印本页]

作者: as592805473    时间: 2009-5-1 22:33
标题: 大家看看
源程序是下面的,为什么注册时连Pro/E也会关闭?
// Gan.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "Gan.h"
#define PRO_USE_VAR_ARGS 1
/*--------------------------------------------------------------------*\
Pro/TOOLKIT includes
\*--------------------------------------------------------------------*/
#include"ProMenu.h"
#include"ProUtil.h"
#include"ProMenubar.h"
#include <ProMessage.h>
/*--------------------------------------------------------------------*\
Functions declaration  函数声明
\*--------------------------------------------------------------------*/
int ShowMessage1();
int ShowMessage2();
int ShowMessage3();
static uiCmdAccessState AccessAvailable (uiCmdAccessMode);
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//
// Note!
//
//  If this DLL is dynamically linked against the MFC
//  DLLs, any functions exported from this DLL which
//  call into MFC must have the AFX_MANAGE_STATE macro
//  added at the very beginning of the function.
//
//  For example:
//
//  extern "C" BOOL PASCAL EXPORT ExportedFunction()
//  {
//   AFX_MANAGE_STATE(AfxGetStaticModuleState());
//   // normal function body here
//  }
//
//  It is very important that this macro appear in each
//  function, prior to any calls into MFC.  This means that
//  it must appear as the first statement within the
//  function, even before any object variable declarations
//  as their constructors may generate calls into the MFC
//  DLL.
//
//  Please see MFC Technical Notes 33 and 58 for additional
//  details.
//
/////////////////////////////////////////////////////////////////////////////
// CGanApp
BEGIN_MESSAGE_MAP(CGanApp, CWinApp)
//{{AFX_MSG_MAP(CGanApp)
  // NOTE - the ClassWizard will add and remove mapping macros here.
  //    DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGanApp construction
CGanApp::CGanApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CGanApp object
CGanApp theApp;
/*=======================================================================*\
FUNCTION: user_initialize()
\*=======================================================================*/
extern "C" int user_initialize()
{
    ProError status;
ProFileName MsgFile;
    uiCmdCmdId   PushButton_cmd_id1,PushButton_cmd_id2,PushButton_cmd_id3;
ProStringToWstring(MsgFile, "Message.txt");//设置菜单信息文件名
    /*=========================================================*\
     添加菜单条
    \*=========================================================*/
status=ProMenubarMenuAdd ("UserMenuBar", "UserMenu",
                        "Applications", PRO_B_TRUE, MsgFile);
    /*=========================================================*\
     菜单按钮设置1
    \*=========================================================*/
//设置菜单按钮的动作函数
status=ProCmdActionAdd("PushButtonAct1",(uiCmdCmdActFn)ShowMessage1,
              uiCmdPrioDefault,AccessAvailable,
        PRO_B_TRUE,PRO_B_TRUE,&PushButton_cmd_id1);
    //添加菜单按钮
status=ProMenubarmenuPushbuttonAdd("UserMenuBar", "PushButton", "PushButton1",
             "Adding a push button to the ProE menu bar", NULL,
           PRO_B_TRUE, PushButton_cmd_id1, MsgFile);
/*=========================================================*\
     菜单按钮设置2
    \*=========================================================*/
//设置菜单按钮的动作函数
status=ProCmdActionAdd("PushButtonAct2",(uiCmdCmdActFn)ShowMessage2,
              uiCmdPrioDefault,AccessAvailable,
        PRO_B_TRUE,PRO_B_TRUE,&PushButton_cmd_id2);
    //添加菜单按钮
status=ProMenubarmenuPushbuttonAdd("UserMenuBar", "PushButton", "PushButton2",
             "Adding a push button to the ProE menu bar", NULL,
           PRO_B_TRUE, PushButton_cmd_id2, MsgFile);
/*=========================================================*\
     菜单按钮设置3
    \*=========================================================*/
//设置菜单按钮的动作函数
status=ProCmdActionAdd("PushButtonAct3",(uiCmdCmdActFn)ShowMessage3,
              uiCmdPrioDefault,AccessAvailable,
        PRO_B_TRUE,PRO_B_TRUE,&PushButton_cmd_id3);
    //添加菜单按钮
status=ProMenubarmenuPushbuttonAdd("UserMenuBar", "PushButton", "PushButton3",
             "Adding a push button to the ProE menu bar", NULL,
           PRO_B_TRUE, PushButton_cmd_id3, MsgFile);

   return status;
}
/*===============================================================*\
FUNCTION: user_terminate()
\*===============================================================*/
extern "C" void user_terminate()
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());
}
/*================================================================*\
FUNCTION: AccessAvailable (菜单项的访问权限设置:可选)
\*================================================================*/
static uiCmdAccessState AccessAvailable (uiCmdAccessMode access_mode)
{
    return (ACCESS_AVAILABLE);
}
/*================================================================*\
FUNCTION: ShowMessage() 菜单按钮1的动作函数
\*================================================================*/
int ShowMessage1()
{
    AfxMessageBox("选择零件快速设计模块!",MB_OK);
return true;
}
int ShowMessage2()
{
    AfxMessageBox("选择三维CAPP系统模块!",MB_OK);
return true;
}
int ShowMessage3()
{
    AfxMessageBox("选择NC加工程序模块!",MB_OK);
return true;
}
作者: as592805473    时间: 2009-5-1 22:34
这是在Pro/E2.0的环境下
作者: 瀚嘉兰    时间: 2009-6-11 00:42
标题: 好贴,不错,顶
好贴不错,顶,

分析的这么透彻。





来自日本德国的超声波五金、模具、电路板清洗机、清洗剂。
15989382977,Q:305684675, 孙先生




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3