|
楼主 |
发表于 2014-12-17 16:44
|
显示全部楼层
本帖最后由 lwsh0289814 于 2014-12-17 16:53 编辑
这是我的学习过程。记录下来。
(1)菜单开发
ProE5二次开发--菜单设计 已有9人参与
开发环境:ProE5+VS2008
(1)环境设置:项目中设置添加依赖项,wscok32.lib mpr.lib psapi.lib protk_dllmd.lib netapi32.lib
(2)菜单文件的编写
user_menu_bar
新建菜单(&N)
#
#
user_menu_button_1
菜单按钮(&B)
#
#
user_menu_button_1_help
菜单按钮帮助
#
#
user_menu_button_2
新按钮(&C)
#
#
user_menu_button_2_help
新按钮帮助
#
#
(3)代码的编写
#include "stdafx.h"
#define PRO_USE_VAR_ARGS 1
#include
#include
#include
#include
#include
ProFileName UserMsg;
ProError status;
uiCmdCmdId cmd_id;
/*================================================================*\
FUNCTION: TestAccessDefault()
PURPOSE: Define the accessibility of menu buttons.
\*================================================================*/
static uiCmdAccessState TestAccessDefault (uiCmdAccessMode access_mode)
{
return (ACCESS_AVAILABLE);
}
/*================================================================*\
FUNCTION: MiscAction()
PURPOSE: Generic action function
\*================================================================*/
int MiscAction()
{
return (0);
}
int MyTest()
{
AfxMessageBox(_T("This is my Test!"),MB_OK,0);
return (0);
}
/*================================================================*\
FUNCTION: user_initialize()
PURPOSE: Pro/TOOLKIT standard initialize
\*================================================================*/
extern "C" int user_initialize (void)
{
AfxEnableControlContainer();
ProError err;
ProFileName usrmenufile;
ProFileName filename;
uiCmdCmdId uiCmdCmdIduser;
err=ProDirectoryChange(ProStringToWstring(filename,"F:\\Prolearn\\test"));
ProStringToWstring(usrmenufile,"text\\user_msg.txt");
err=ProMenubarMenuAdd("user_bar_name","user_menu_bar","Help",PRO_B_TRUE,usrmenufile);
err=ProCmdActionAdd("user_button_",(uiCmdCmdActFn)MiscAction,uiProeImmediate,TestAccessDefault,PRO_B_FALSE,PRO_B_FALSE,&uiCmdCmdIduser);
err=ProMenubarmenuPushbuttonAdd("user_bar_name","user_menu_button_1_","user_menu_button_1","user_menu_button_1_help"
,NULL,PRO_B_TRUE,uiCmdCmdIduser,usrmenufile);
err=ProCmdActionAdd("user_button_1",(uiCmdCmdActFn)MyTest,uiProeImmediate,TestAccessDefault,PRO_B_FALSE,PRO_B_FALSE,&uiCmdCmdIduser);
err=ProMenubarmenuPushbuttonAdd("user_bar_name","user_menu_button_2_","user_menu_button_2","user_menu_button_2_help",
"user_menu_button_1_",PRO_B_TRUE,uiCmdCmdIduser,usrmenufile);
return (0);
}
extern "C" void user_terminate()
{
}
生成一个菜单项,其中包括了两个菜单!经测试,在每个菜单中都应该包括菜单说明项。没有的话,创建不成功!
(转载的,直接输入地址不能提交,另外鉴于网址无法直接查看将内容拷贝过来了)
|
|