mfc基于对话框 使用html对话框是什么?,NX二次开发-基于MFC界面对话框与NX交互的开发...

打开VS2013

点击新建,选择MFC DLL

点击确定

点下一步

什么都不改,直接点完成

进来之后先编译一下,看是否编译成功

打开项目属性,更改这几处

1 $(UGII_BASE_DIR)\ugopen

1 libufun.lib2

3 libufun_cae.lib4

5 libufun_cam.lib6

7 libufun_die.lib8

9 libufun_vdac.lib10

11 libufun_weld.lib12

13 libnxopencpp.lib14

15 libnxopencpp_annotations.lib16

17 libnxopencpp_assemblies.lib18

19 libnxopencpp_bodydes.lib20

21 libnxopencpp_cae.lib22

23 libnxopencpp_cam.lib24

25 libnxopencpp_diagramming.lib26

27 libnxopencpp_diagramminglibraryauthor.lib28

29 libnxopencpp_die.lib30

31 libnxopencpp_display.lib32

33 libnxopencpp_drafting.lib34

35 libnxopencpp_drawings.lib36

37 libnxopencpp_facet.lib38

39 libnxopencpp_features.lib40

41 libnxopencpp_fields.lib42

43 libnxopencpp_formboard.lib44

45 libnxopencpp_gateway.lib46

47 libnxopencpp_geometricanalysis.lib48

49 libnxopencpp_geometricutilities.lib50

51 libnxopencpp_issue.lib52

53 libnxopencpp_layer.lib54

55 libnxopencpp_layout2d.lib56

57 libnxopencpp_markup.lib58

59 libnxopencpp_mechanicalrouting.lib60

61 libnxopencpp_mechatronics.lib62

63 libnxopencpp_mfg.lib64

65 libnxopencpp_modldirect.lib66

67 libnxopencpp_motion.lib68

69 libnxopencpp_openxml.lib70

71 libnxopencpp_optimization.lib72

73 libnxopencpp_options.lib74

75 libnxopencpp_partfamily.lib76

77 libnxopencpp_pdm.lib78

79 libnxopencpp_physmat.lib80

81 libnxopencpp_placement.lib82

83 libnxopencpp_plas.lib84

85 libnxopencpp_positioning.lib86

87 libnxopencpp_preferences.lib88

89 libnxopencpp_report.lib90

91 libnxopencpp_routing.lib92

93 libnxopencpp_shapesearch.lib94

95 libnxopencpp_sheetmetal.lib96

97 libnxopencpp_shipdesign.lib98

99 libnxopencpp_sim.lib100

101 libnxopencpp_tooling.lib102

103 libnxopencpp_userdefinedobjects.lib104

105 libnxopencpp_userdefinedtemplate.lib106

107 libnxopencpp_validate.lib108

109 libnxopencpp_visualreporting.lib110

111 libnxopencpp_weld.lib112

113 libugopenint.lib114

115 libugopenint_cae.lib116

117 libugopenint_cam.lib118

119 libnxopenuicpp.lib

然后点确定

添加头文件

添加ufusr入口函数和卸载方式

1 extern "C" DllExport void ufusr(char *param, int *retcod, intparam_len)2 {3

4 if(UF_initialize())5 {6 /*Failed to initialize*/

7 return;8 }9 //The following method shows the dialog immediately

10

11

12

13 UF_terminate();14 }15

16 extern "C" DllExport intufusr_ask_unload()17 {18 return(UF_UNLOAD_UG_TERMINATE);19 //return (UF_UNLOAD_IMMEDIATELY);20 //return UF_UNLOAD_SEL_DIALOG;

21 }

将项目改成64位的

打开配置管理器

编译项目,成功

添加对话框,找到资源视图,右键添加资源

选择Dialog,点新建

添加类

对话框右键-添加类

随便取名字,CFirstMFCDialog,点完成

编译项目成功

添加对话框初始化虚函数

对话框点右键-添加类向导

然后点确定

在编译项目成功

添加头文件

在去ufusr入口函数里获取UG窗口句柄,设置对话框。写的内容固定格式

1 AFX_MANAGE_STATE(AfxGetStaticModuleState());2

3

4

5 HWND UGHwnd = (HWND)UF_UI_get_default_parent();//获取UG窗口句柄

6

7 CWnd *ugwindow =CWnd::FromHandle(UGHwnd);8

9

10

11 CFirstMFCDialog *dlg = newCFirstMFCDialog(ugwindow);12

13 if (dlg !=NULL)14

15 {16

17 BOOL ret = dlg->Create(IDD_DIALOG1, ugwindow);18

19 dlg->ShowWindow(SW_SHOW);20

21 //dlg->SetWindowPos(ugwindow, 300, 220, 200, 200, SWP_NOSIZE);//设置对话框固定位置

22

23 }

在编译项目成功

打开UG去调对话框就出来了

提示,因为选择的卸载方式,需求每次修改代码重新编译,都要关闭UG。来卸载掉。

截止到这个MFC+NX二次开发的这个环境搭建就结束了

下面做一个实例。

选择位置,创建块。(大概演示,不在详细写步骤)

对话框

对话框初始化代码

1 BOOL CFirstMFCDialog::OnInitDialog()2 {3 CDialogEx::OnInitDialog();4

5 //TODO: 在此添加额外的初始化6

7 //对话框初始值

8 m_edit1.SetWindowText("100");9 m_edit2.SetWindowText("50");10 m_edit3.SetWindowText("25");11

12 return TRUE; //return TRUE unless you set the focus to a control13 //异常: OCX 属性页应返回 FALSE

14 }

点构造器代码

1 voidCFirstMFCDialog::OnBnClickedButton1()2 {3 //TODO: 在此添加控件通知处理程序代码

4

5 UF_initialize();6

7 UF_UI_lock_ug_access(UF_UI_FROM_CUSTOM);//对话框加锁

8

9 char sCue[] = "点构造器";10 UF_UI_POINT_base_method_t base_method =UF_UI_POINT_INFERRED;11 tag_t tPoint =NULL_TAG;12 double sBasePoint[3];13 intiResponse;14 UF_UI_point_construct(sCue, &base_method, &tPoint, sBasePoint, &iResponse);15

16 UF_UI_unlock_ug_access(UF_UI_FROM_CUSTOM);//对话框解锁

17

18 UF_terminate();19 }

点确定的代码

1 voidCFirstMFCDialog::OnBnClickedOk()2 {3 //TODO: 在此添加控件通知处理程序代码

4 CDialogEx::OnOK();5

6 UF_initialize();7

8 //获取对话框里的输入值

9 CString length;10 m_edit1.GetWindowTextA(length);11

12 CString width;13 m_edit2.GetWindowTextA(width);14

15 CString high;16 m_edit3.GetWindowTextA(high);17

18 //转换19 //CString转char*

20 USES_CONVERSION;21 char* length1 = T2A(length.GetBuffer(0));22 length.ReleaseBuffer();23

24 char* width1 = T2A(width.GetBuffer(0));25 width.ReleaseBuffer();26

27 char* high1 = T2A(high.GetBuffer(0));28 high.ReleaseBuffer();29

30 UF_FEATURE_SIGN sign =UF_NULLSIGN;31 char * edge_len[3] ={ length1, width1, high1 };32 tag_t blk_obj_id =NULL_TAG;33 UF_MODL_create_block1(sign, sBasePoint, edge_len, &blk_obj_id);34

35 UF_terminate();36 }

源代码下载

链接:https://pan.baidu.com/s/1Pjveurp-tEDUiqMI5uDhGA 密码:mvqq

Caesar卢尚宇

2019年7月13日

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值