【NX二次开发】常用的标准对话框
1.uc1601 单按钮模态对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 uc1601("单选模态对话框!", 1);
- 6 UF_terminate();
- 7 }
2.UF_UI_message_dialog 多按钮模态对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 int response = 0;
- 6 char title_string[] = "王牌飞行员_里海";
- 7 char *sMessages = "多按钮模态对话框";
- 8 UF_UI_MESSAGE_DIALOG_TYPE dialog_type = UF_UI_MESSAGE_QUESTION;//对话框类型 UF_UI_MESSAGE_ERROR,UF_UI_MESSAGE_WARNING,UF_UI_MESSAGE_INFORMATION,UF_UI_MESSAGE_QUESTION
- 9 UF_UI_message_buttons_s button;
- 10 button.button1 = true;//是否显示
- 11 button.button2 = true;
- 12 button.button3 = true;
- 13 button.label1 = "是";//按钮名
- 14 button.label2 = "否";
- 15 button.label3 = "取消";
- 16 button.response1 = 1;//返回值
- 17 button.response2 = 2;
- 18 button.response3 = 3;
- 19 UF_UI_message_dialog(title_string, dialog_type, &sMessages, 1, 0, &button, &response);
- 20 switch (response)
- 21 {
- 22 case 1:
- 23 uc1601(button.label1, 1); break;
- 24 case 2:
- 25 uc1601(button.label2, 1); break;
- 26 case 3:
- 27 uc1601(button.label3, 1); break;
- 28 default:
- 29 uc1601("未知按钮", 1); break;
- 30 }
- 31 UF_terminate();
- 32 }
3.文件选择对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 //文件选择对话框
- 6 char sPromptStr[] = "部件选择对话框"; //快捷信息(在提示栏显示)
- 7 char sTitleStr[] = "部件选择对话框"; //对话框标题(如图)
- 8 char sFilterStr[] = ".prt"; //文件过滤器,即只处理某一种类型文件(如图)
- 9 char sDefaultStr[] = "*.prt"; //默认文件名(如图)
- 10 char sFilePath[256] = ""; //用户选择的文件全路径
- 11 int iRespones = 0; //函数返回值
- 12 UF_UI_create_filebox(sPromptStr, sTitleStr, sFilterStr, sDefaultStr, sFilePath, &iRespones);
- 13 uc1601(sFilePath, 1);
- 14
- 15 UF_terminate();
- 16 }
4.文件夹选择对话框
- 1 #include "Text.h"
- 2 #include <Windows.h>
- 3 #include <ShlObj.h>
- 4 #include <tchar.h>
- 5 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 6 void OnBnClickedButton1();
- 7
- 8 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 9 {
- 10 UF_initialize();
- 11 OnBnClickedButton1();
- 12 UF_terminate();
- 13 }
- 14 extern int ufusr_ask_unload(void)
- 15 {
- 16 return (UF_UNLOAD_IMMEDIATELY);
- 17 }
- 18
- 19 int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
- 20 {
- 21 switch (uMsg)
- 22 {
- 23 case BFFM_INITIALIZED: //选择目录对话框初始化时 选中指定目录
- 24 //BFFM_INITIALIZED表示浏览对话框已经初化结束,参数lParam为NULL
- 25 //设置初始选项
- 26
- 27 ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
- 28
- 29 //关于BFFM_SETSELECTION消息的说明
- 30 //wParam :标记lParam参数包含一个ITEMIDLIST结构(PIDL)还是一个目录路径名
- 31 // 如果为TRUE,lParam内容为路径名;否则lParam包含一个路径PIDL。
- 32 //lParam :内容为浏览对话框所选的路径。如果wParam为TRUE,lParam内容为一个
- 33 // 以NULL结尾的字符串的指针,否则为PIDL
- 34 break;
- 35 default:
- 36 break;
- 37 }
- 38 return 0;
- 39 }
- 40 void OnBnClickedButton1()
- 41 {
- 42 // TODO: 在此添加控件通知处理程序代码
- 43 BROWSEINFO bi;
- 44 char Buffer[MAX_PATH];
- 45 LPWSTR aaa = CA2W(Buffer);
- 46 //初始化入口参数bi开始
- 47 bi.hwndOwner = NULL;
- 48 bi.pidlRoot = NULL;//初始化制定的root目录很不容易
- 49 bi.pszDisplayName = aaa;//此参数如为NULL则不能显示对话框
- 50 bi.lpszTitle = _T("选择目标文件路径");
- 51 bi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE;
- 52 //CString file_puch=_T("D:\\HYS_tool_code\\code\\tihuan_excel\\x64\\Release\\data");
- 53 CString file_puch = _T("D:\\");//
- 54 bi.lParam = (long)(file_puch.GetBuffer(file_puch.GetLength()));//初始化路径,形如(_T("c:\\Symbian"));
- 55 bi.lpfn = BrowseCallbackProc;
- 56
- 57 //初始化入口参数bi结束
- 58 LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框
- 59
- 60 if (pIDList)
- 61
- 62 {
- 63 SHGetPathFromIDList(pIDList, aaa);
- 64 //取得文件夹路径到Buffer里
- 65 file_puch = aaa;//将路径保存在一个CString对象里
- 66
- 67 /*你的代码 */
- 68 char chArray[500];
- 69 CString2Char(file_puch, chArray); //CString转char
- 70 uc1601(chArray, 1);
- 71
- 72 }
- 73
- 74 // free memory used
- 75 IMalloc * imalloc = 0;
- 76
- 77 if (SUCCEEDED(SHGetMalloc(&imalloc)))
- 78 {
- 79 imalloc->Free(pIDList);
- 80 imalloc->Release();
- 81 }
- 82
- 83 }
5.单选菜单对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 char sPrompStr[] = "单选菜单对话框";//显示在提示栏中的信息
- 6 int iDefault = 0;//0:确定灰显 1:确定激活
- 7 char asOptions[][38] = { "菜单选项1", "菜单选项2","菜单选项3"};
- 8 int iNumOfOptions = 3;//最多包含14个菜单选项
- 9 uc1603(sPrompStr, iDefault, asOptions, iNumOfOptions);
- 10 UF_terminate();
- 11 }
6.多选菜单对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 char sPrompStr[] = "多选菜单对话框";//显示在提示栏中的信息
- 6 int iDefault = 0;//0:确定灰显 1:确定激活
- 7 char asOptions[][38] = { "菜单选项1", "菜单选项2","菜单选项3" };
- 8 int iRe = 0;
- 9 int iNumOfOptions = 3;//最多包含14个菜单选项
- 10 uc1605(sPrompStr, iDefault, asOptions, iNumOfOptions,&iRe);
- 11 UF_terminate();
- 12 }
7.单对象选择对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 int selectface();//选面
- 3 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 4 {
- 5 UF_initialize();
- 6 selectface();
- 7 UF_terminate();
- 8 }
- 9
- 10 extern int ufusr_ask_unload(void)
- 11 {
- 12 return (UF_UNLOAD_IMMEDIATELY);
- 13 }
- 14
- 15 int init_proc_face(UF_UI_selection_p_t select, void* user_data)//选面
- 16 {
- 17 int num_triples = 1;
- 18 UF_UI_mask_t mask_triples[] = { UF_solid_type,0,20 };
- 19
- 20 if (UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples) == 0) {
- 21 return (UF_UI_SEL_SUCCESS);
- 22 }
- 23
- 24 return (UF_UI_SEL_FAILURE);
- 25 }
- 26
- 27 int selectface()//选面
- 28 {
- 29 tag_t tagSeleceFaceOcc = 0;
- 30 int iReturn = 0;
- 31 int iSelResp = 0;
- 32 double pDblCursorPosTemp[3];
- 33 tag_t tagViewTemp;
- 34 tag_t pTagObjs;
- 35 iReturn = UF_UI_select_with_single_dialog("提示请选择面", "标题请选择面", UF_UI_SEL_SCOPE_NO_CHANGE,
- 36 init_proc_face, NULL, &iSelResp, &pTagObjs, pDblCursorPosTemp, &tagViewTemp);
- 37 if (!iReturn&&pTagObjs != NULL_TAG)
- 38 {
- 39 tagSeleceFaceOcc = pTagObjs;
- 40 UF_DISP_set_highlight(pTagObjs, false);
- 41 return 0;
- 42 }
- 43 else
- 44 {
- 45 return 1;
- 46 }
- 47 }
8.按类选择对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 int selectPartBody();//选择体;
- 3 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 4 {
- 5 UF_initialize();
- 6 selectPartBody();
- 7 UF_terminate();
- 8 }
- 9 extern int ufusr_ask_unload(void)
- 10 {
- 11 return (UF_UNLOAD_IMMEDIATELY);
- 12 }
- 13 static int face_sel_cb(int num_sel, tag_p_t sel_objects, int num_deselected, tag_p_t deselected_objs, void *user_data, UF_UI_selection_p_t select)
- 14 {
- 15 int i = 0;
- 16 tag_t tagObjTemp;
- 17 UF_OBJ_translucency_t TRANSLUCENCY = NULL;
- 18 for (i = 0; i < num_sel; i++)
- 19 {
- 20 if (UF_ASSEM_is_occurrence(sel_objects[i]))
- 21 {
- 22 tagObjTemp = UF_ASSEM_ask_prototype_of_occ(sel_objects[i]);
- 23 }
- 24 else
- 25 {
- 26 tagObjTemp = sel_objects[i];
- 27 }
- 28 UF_UI_remove_from_sel_list(select, 1, &sel_objects[i], true);
- 29 UF_OBJ_ask_translucency(tagObjTemp, &TRANSLUCENCY);
- 30 if (TRANSLUCENCY != 0)
- 31 {
- 32 (UF_OBJ_set_translucency(tagObjTemp, 0));
- 33 (UF_OBJ_set_translucency(sel_objects[i], 0));
- 34 }
- 35 else
- 36 {
- 37 (UF_OBJ_set_translucency(tagObjTemp, 50));
- 38 (UF_OBJ_set_translucency(sel_objects[i], 50));
- 39 }
- 40 }
- 41 return (UF_UI_CB_CONTINUE_DIALOG);
- 42 }
- 43 int init_proc_solid(UF_UI_selection_p_t select, void* user_data)
- 44 {
- 45 int iReturn = 0;
- 46 const int num_triples = 1;
- 47 UF_UI_mask_t mask_triples[num_triples];
- 48
- 49 mask_triples[0].object_type = UF_solid_type; //选择过滤
- 50 mask_triples[0].object_subtype = 0;
- 51 mask_triples[0].solid_type = 0;
- 52
- 53 iReturn = UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples);
- 54 if (!iReturn) iReturn = (UF_UI_set_sel_procs(select, NULL, face_sel_cb, NULL));
- 55 if (iReturn == 0)
- 56 {
- 57 return (UF_UI_SEL_SUCCESS);
- 58 }
- 59 return (UF_UI_SEL_FAILURE);
- 60 }
- 61
- 62 int selectPartBody()//选择体
- 63 {
- 64 int iReturn = 0;
- 65 int iSelResp = 0;
- 66 int iCountTemp = 0;
- 67 double pDblCursorPosTemp[3];
- 68 tag_t *pTagObjs = NULL; //选择的对象
- 69 while (!iReturn)
- 70 {
- 71 iReturn = (UF_UI_select_with_class_dialog("提示选择体", "标题选择体", UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, init_proc_solid, NULL, &iSelResp, &iCountTemp, &pTagObjs));
- 72 if (iSelResp == UF_UI_CANCEL) return 1;
- 73 }
- 74 return iReturn;
- 75 }
9.点构造器
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 char sCA[] = "点构造器";
- 6 UF_UI_POINT_base_method_t base_method = UF_UI_POINT_INFERRED;
- 7 tag_t tagPoint = NULL_TAG;
- 8 double douBasePoint[] = {0.0, 0.0, 0.0};
- 9 int iRes;
- 10 UF_UI_point_construct(sCA, &base_method, &tagPoint, douBasePoint, &iRes);
- 11 UF_terminate();
- 12 }
10.拾取向量对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 double douVec[3], pnt[3];
- 6 int iMode = UF_UI_INFERRED;
- 7 int iDispFlag = UF_UI_DISP_TEMP_VECTOR;
- 8 int iRes = 0;
- 9 UF_UI_specify_vector("选择一个矢量", &iMode, iDispFlag, douVec, pnt, &iRes);
- 10 UF_terminate();
- 11 }
11.点收集器
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 char cMessage[] = "点收集器";
- 6 bool boolCoincidentPoints = true;
- 7 UF_UI_chained_points_p_t chainedPoints;
- 8 int iCount;
- 9 int iRes;
- 10 UF_UI_select_point_collection(cMessage, boolCoincidentPoints, &chainedPoints, &iCount, &iRes);
- 11 UF_terminate();
- 12 }
12.拾取屏幕位置
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 char cMessage[] = "拾取屏幕位置";
- 6 double dOrigin[] = { 0.0, 0.0, 0.0 };
- 7 tag_t tagView;
- 8 int iRes;
- 9 UF_UI_specify_screen_position(cMessage, NULL, NULL, dOrigin, &tagView, &iRes);
- 10 //dOrigin为选择的屏幕位置
- 11 UF_terminate();
- 12 }
13.特征选择对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 char cMessage[] = "提示:特征选择对话框";
- 6 int iCount;
- 7 tag_t* tagFeature;
- 8 int iRes;
- 9 UF_UI_select_feature(cMessage, NULL, &iCount, &tagFeature, &iRes);
- 10 UF_terminate();
- 11 }
14.参数选择对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 UF_FEATURE_SIGN sign = UF_NULLSIGN;
- 6 double douBlockOrig[3] = { 0.0, 0.0, 0.0 };
- 7 char* cBlockLengh[3] = { "6", "66", "666" };
- 8 tag_t tagBlockObj;
- 9 char cMessage[] = "提示:参数选择对话框";
- 10 int iCount;
- 11 tag_t* tagExp;
- 12 int iRes;
- 13 UF_MODL_create_block1(sign, douBlockOrig, cBlockLengh, &tagBlockObj);
- 14 UF_UI_select_parameters(cMessage, tagBlockObj, &iCount, &tagExp, &iRes);
- 15 UF_free(tagExp);
- 16 UF_terminate();
- 17 }
15.拾取平面对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 double douOrientation[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- 6 double douOrigin[3] = { 0, 0, 0 };
- 7 double douPts[6] = { 0, 0, 0, 0, 0, 0 };
- 8 int iMode = 1, display = 0, response;
- 9 tag_t tagPlaneEid = NULL_TAG;
- 10 UF_UI_specify_plane("指定平面", &iMode, display, &response, douOrientation, douOrigin, &tagPlaneEid);
- 11 UF_terminate();
- 12 }
16.选择草图对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 char cMessage[] = "提示:选择草图对话框";
- 6 tag_t tagSketch;
- 7 int iRe;
- 8 UF_UI_select_sketch(cMessage, NULL, &tagSketch, &iRe);
- 9 UF_terminate();
- 10 }
17.拾取草图尺寸对话框
- 1 //来自“王牌飞行员_里海”的测试源码(qq群753801561)
- 2 extern DllExport void ufusr(char *param, int *returnCode, int rlen)
- 3 {
- 4 UF_initialize();
- 5 char cMessage[] = "提示:拾取草图尺寸对话框";
- 6 tag_t tagSketch;
- 7 int iCount;
- 8 tag_t* tagExps = NULL;
- 9 int iRes;
- 10 UF_SKET_ask_active_sketch(&tagSketch);
- 11 UF_UI_select_sketch_dimensions(cMessage, tagSketch, &iCount, &tagExps, &iRes);
- 12 UF_free(tagExps);
- 13 UF_terminate();
- 14 }
【NX二次开发】常用的标准对话框的更多相关文章
- NX二次开发-基于MFC界面对话框与NX交互的开发
打开VS2013 点击新建,选择MFC DLL 点击确定 点下一步 什么都不改,直接点完成 进来之后先编译一下,看是否编译成功 打开项目属性,更改这几处 $(UGII_BASE_DIR)\ugopen ...
- 【NX二次开发】修改dlx对话框标题的方法
修改dlx名称, 修改对话框标题的方法: theDialog->TopBlock()->FindBlock("Dialog")->GetProperties()- ...
- NX二次开发-UFUN单对象选择对话框UF_UI_select_with_single_dialog
#include <uf.h> #include <uf_ui.h> ], void* user_data, UF_UI_selection_p_t select) { if ...
- NX二次开发-UFUN文件选择对话框UF_UI_create_filebox
NX11+VS2013 #include <uf.h> #include <uf_ui.h> UF_initialize(); //文件选择对话框 char sPromptSt ...
- NX二次开发-UFUN单选菜单对话框uc1603
NX11+VS2013 #include <uf.h> #include <uf_ui.h> UF_initialize(); //单选菜单对话框 char sPromptSt ...
- NX二次开发-UFUN参数选择对话框UF_UI_select_parameters
#include <uf.h> #include <uf_ui.h> #include <uf_modl.h> UF_initialize(); //参数选择对话框 ...
- NX二次开发-UFUN选择草图对话框UF_UI_select_sketch
#include <uf.h> #include <uf_ui.h> UF_initialize(); //选择草图对话框 char sMessage[] = "选择 ...
- NX二次开发-UFUN拾取平面对话框UF_UI_specify_plane
#include <uf.h> #include <uf_ui.h> UF_initialize(); //拾取平面对话框 ] = { , , , , , , , , }; ] ...
- NX二次开发-UFUN拾取向量对话框UF_UI_specify_vector
#include <uf.h> #include <uf_ui.h> UF_initialize(); //拾取向量对话框 ], pnt[]; int mode = UF_UI ...
- NX二次开发-常用lib库文件
在项目属性->配置属性->链接器->输入->附加依赖项: libufun.lib UFUNC API 函数库 libugopenint.lib UFUNC 对话框 API 函数 ...
随机推荐
- 攻防世界Web刷题记录(进阶区)
攻防世界Web刷题记录(进阶区) 1.baby_web 发现去掉URLhttp://111.200.241.244:51461/1.php后面的1.php,还是会跳转到http://111.200.2 ...
- pr2019快键键
pr快捷键 平时用到就更新一下(持续更新),算是日积月累吧.虽然是pr2019,但是其他的版本估计差不多 视频剪辑的时候,快速预览--L(英文输入法).按一次,速度*2,如果想恢复原来速度,按空格键暂 ...
- pyhive的基本使用
安装 yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib # 解决报错:sasl/sasl.h: No such file or di ...
- 前端面试 CSS三大特性
CSS的三大特性 1.层叠性 代码由上向下执行,相同选择器设置到同一元素上,样式冲突的,会执行比较靠近html的样式,样式不冲突的情况下不影响 代码如下 <!DOCTYPE html> & ...
- CRM是什么意思,有哪些作用?
我们总会听到一些人提到CRM或CRM系统,但是通常不知道它的含义,所以今天小Z就来详细介绍一下CRM. GartnerGroup1993年首次提出了这一概念:所谓的客户关系管理就是为企业提供一个全面的 ...
- Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
selenium + java + mac + idea 报错分析: 网上搜的教程,配置selenium 自动化测试环境,都是只让导入 client-combined-3.141.59-sources ...
- ssh-的搭建和使用
ssh的作用 : 可实现远程客户端登录服务器并对服务器的文件进行操作 ssh服务器的安装 farsight@ubuntu:~$ sudo apt-get install openssh-server ...
- [OS] 汇编语言
操作系统 每个进程拥有一片连续的内存空间(地址空间),空间中的每个字节都可以用一个32位无符号整数定位,每个字节的位置称为地址 CPU 32位:能够处理的数据最大为32bit,地址空间2^32< ...
- Linux是一个基于POSIX和Unix的多用户、多任务、支持多线程和多CPU的性能稳定的操作系统,可免费使用并自由传播。
Linux是一个基于POSIX和Unix的多用户.多任务.支持多线程和多CPU的性能稳定的操作系统,可免费使用并自由传播. Linux是众多操作系统之一 , 目前流行的服务器和 PC 端操作系统有 L ...
- html原生js实现99乘法表
原生的js实现99乘法表实现选择下拉框颜色,改变背景颜色为选中的颜色 <!DOCTYPE html> <html> <head> <meta charset= ...