creo vs环境搭建
note:配置Debug,release会失败
1.安装creo要安装ptoolkit
2.vs配置
包含目录
库目录
预处理定义PRO_USE_VAR_ARGS
链接器
wsock32.lib
psapi.lib
netapi32.lib
mpr.lib
protk_dllmd_NU.lib
ucore.lib
udata.lib
note:忽略特定默认库库中添加“msvcrt.lib(结合自己的环境)
3.代码
开头代码
#include <ProToolkit.h>
#include "ProMenubar.h"
#include "ProMenu.h"
#include "ProUtil.h"
末尾代码
static uiCmdAccessState AccessDefault(uiCmdAccessMode access_mode)
{
return(ACCESS_AVAILABLE);
}
void Test1()
{
AfxMessageBox(_T("测试按钮 A"));
}
void Test2()
{
AfxMessageBox(_T("测试按钮 B"));
}
extern "C" int user_initialize()
{
ProError status;
ProFileName MsgFile;
ProStringToWstring(MsgFile, "IconMessage.txt"); //注意此处的 IconMessage 与后面的text 文件夹下的 IconMessage.txt 文件名必须相同
uiCmdCmdId PushButton1_cmd_id, PushButton2_cmd_id;
status = ProMenubarMenuAdd("MainMenu", "Function", "Help", PRO_B_TRUE, MsgFile);
ProCmdActionAdd("PushButton1_Act", (uiCmdCmdActFn)Test1, 12, AccessDefault, PRO_B_TRUE, PRO_B_TRUE, &PushButton1_cmd_id);
ProMenubarmenuPushbuttonAdd("MainMenu", "PushButton", "FirstButton", "this button will show a message",NULL,PRO_B_TRUE,PushButton1_cmd_id,MsgFile);
ProCmdActionAdd("PushButton2_Act", (uiCmdCmdActFn)Test2, uiCmdPrioDefault, AccessDefault, PRO_B_TRUE, PRO_B_TRUE, &PushButton2_cmd_id);
ProMenubarmenuPushbuttonAdd("MainMenu", "PushButton2", "SecondButton", "this button will show a message", NULL, PRO_B_TRUE, PushButton2_cmd_id, MsgFile);
return status;
}
extern "C" void user_terminate()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
}
- protk.dat 文件,向文件添加如下内容:
NAME TestForCreo
EXEC_FILE E:/Creo/NewFile/TestForCreo.dll
TEXT_DIR E:/Creo/NewFile/text
STARTUP dll
REVISION Creo4.0
END
5.text文件夹下文档
IconMessage.txt
Function
UserFunction
FirstButton
A Button
secondbutton
B Button
this button will show a message
this button will show a message
show first button
show first button
参考(李世国 张继春 吴立军 王文波 王伟书籍)
标签:lib,show,PRO,cmd,Creo,二次开发,TRUE,button From: https://www.cnblogs.com/timapi/p/18349925