NX二次开发-用户自定义资源栏选项卡RegisterActivationCallback

最近在研究UGOPEN文件夹里的例子,发现从NX10版开始可以用户自定义资源栏选项卡了,NX10以下也可以做,但是需要反编译DLL调内部函数,这个只有高手才会,我是不会弄。

以前看过有人把标准件库做到了这个选项卡里面。

在UGOPEN里有一个例子CustomResourceBarTab就介绍了怎么自定义资源栏选项卡。但是我发现例子中能实现的功能还是有限,有些功能接口并没有开放,可能还是要调内部函数才能实现。

就比如我想在选项卡里创建BlockUI的各种控件,我没研究出来怎么弄。但是这个例子我基本上知道怎么去创建选项卡以及做MFC控件。其实我觉得可以搭建个MFC项目,把MFC的界面通过获取

窗口句柄嵌套在选项卡里面去实现交互。例子也是通过获取NX窗口句柄注册选项卡的。

用到的几个NXOPEN方法https://docs.plm.automation.siemens.com/data_services/resources/nx/11/nx_api/custom/en_US/open_c++_ref/a05722.html

 

  1 // 描述:
  2 //这是一个允许第三方应用程序
  3 //将自己的工具或交互式窗口嵌入到选项卡中
  4 // NX资源栏。
  5 
  6 // Mandatory UF Includes
  7 #include <uf.h>
  8 #include <uf_object_types.h>
  9 
 10 // Internal Includes
 11 #include <NXOpen/ListingWindow.hxx>
 12 #include <NXOpen/NXMessageBox.hxx>
 13 #include <NXOpen/UI.hxx>
 14 
 15 // Internal+External Includes
 16 #include <NXOpen/Annotations.hxx>
 17 #include <NXOpen/Assemblies_Component.hxx>
 18 #include <NXOpen/Assemblies_ComponentAssembly.hxx>
 19 #include <NXOpen/Body.hxx>
 20 #include <NXOpen/BodyCollection.hxx>
 21 #include <NXOpen/Face.hxx>
 22 #include <NXOpen/Line.hxx>
 23 #include <NXOpen/NXException.hxx>
 24 #include <NXOpen/NXObject.hxx>
 25 #include <NXOpen/Part.hxx>
 26 #include <NXOpen/PartCollection.hxx>
 27 #include <NXOpen/Session.hxx>
 28 
 29 //头文件
 30 #include <NXOpen/Session.hxx>
 31 #include <NXOpen/UI.hxx>
 32 #include <NXOpen/ListingWindow.hxx>
 33 #include <afxwin.h>
 34 #include <WinUser.h>
 35 #include <map>
 36 #include <RichEdit.h>
 37 #include <NXOpen/NXObject.hxx>
 38 #include <NXOpen/TaggedObject.hxx>
 39 #include <NXOpen/Callback.hxx>
 40 #include <NXOpen/NXException.hxx>
 41 #include <NXOpen/ResourceBarManager.hxx>
 42 #include <uf.h>
 43 #include <uf_ui.h>
 44 #include <uf_exit.h>
 45 #include <uf_modl.h>
 46 
 47 
 48 //命名空间
 49 using namespace std;
 50 using namespace NXOpen;
 51 
 52 // Std C++ Includes
 53 #include <iostream>
 54 #include <sstream>
 55 
 56 using std::string;
 57 using std::exception;
 58 using std::stringstream;
 59 using std::endl;
 60 using std::cout;
 61 using std::cerr;
 62 
 63 
 64 //------------------------------------------------------------------------------
 65 // NXOpen c++ test class 
 66 //------------------------------------------------------------------------------
 67 class MyClass
 68 {
 69     // class members
 70 public:
 71 
 72     //用户代码
 73     static Session *theSession;
 74     static UI *theUI;
 75     static ListingWindow* listW;
 76     static HINSTANCE theInst;
 77 
 78     typedef std::map<int, int> StlRegisteredTabMap;
 79     static StlRegisteredTabMap g_TabMap;
 80 
 81     typedef std::map<int, HWND> StlChildWindowMap;
 82     static StlChildWindowMap g_ChildMap;
 83 
 84     BOOL InitApplication();//初始化应用程序
 85     BOOL InitInstance();//初始化函数
 86     HWND CreateChildWindow(HWND parent_handle);//创建子窗口
 87     int ActivationHandler(int tab_id);//激活Handler
 88 
 89     int GetRegisteredID(int id) const { return g_TabMap[id]; }//获取注册的ID
 90     void SetRegisteredID(int id, int tab_id) { g_TabMap[id] = tab_id; }//设置注册的ID
 91     void RemoveRegisteredID(int id) { g_TabMap.erase(id); }//移除注册的ID
 92     int GetLastRegisteredID() const;//获取最后一个注册的ID
 93     int GetRegisteredNumber(int tab_id) const;//获取注册的数量
 94 
 95     HWND GetChildWindow(int id) const { return g_ChildMap[id]; }//获取子窗口
 96     void SetChildWindow(int id, HWND handle) { g_ChildMap[id] = handle; }//设置子窗口
 97     void RemoveChildWindow(int id) { g_ChildMap.erase(id); }//移除子窗口
 98 
 99 
100     MyClass();
101     ~MyClass();
102 
103     void do_it();
104     void print(const NXString &);
105     void print(const string &);
106     void print(const char*);
107 
108 private:
109     Part *workPart, *displayPart;
110     NXMessageBox *mb;
111     ListingWindow *lw;
112     LogFile *lf;
113 
114     const char* theDlxFileName;
115     NXOpen::BlockStyler::BlockDialog* theDialog;
116 };
117 
118 
119 //------------------------------------------------------------------------------
120 // 初始化静态变量
121 //------------------------------------------------------------------------------
122 Session* MyClass::theSession = NULL;
123 UI* MyClass::theUI = NULL;
124 ListingWindow* MyClass::listW = NULL;
125 HINSTANCE MyClass::theInst = NULL;
126 static MyClass* theMyClass = NULL;
127 static HWND hAdd = NULL;
128 static HWND hActivate = NULL;
129 static HWND hHide = NULL;
130 static HWND hShow = NULL;
131 static HWND hRemove = NULL;
132 static HWND hMain = NULL;
133 static int tab_count = 0;
134 MyClass::StlChildWindowMap MyClass::g_ChildMap;
135 MyClass::StlRegisteredTabMap MyClass::g_TabMap;
136 
137 static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
138 
139 
140 //------------------------------------------------------------------------------
141 // Constructor 
142 //------------------------------------------------------------------------------
143 MyClass::MyClass()
144 {
145 
146     //初始化NX Open c++ API环境
147     MyClass::theSession = NXOpen::Session::GetSession();
148     MyClass::theUI = UI::GetUI();
149 
150     //初始化列表窗口
151     listW = MyClass::theSession->ListingWindow();
152 
153     //获取指定模块的句柄
154     theInst = GetModuleHandle(_T("CustomResourceBarTab.dll"));
155 
156     mb = theUI->NXMessageBox();
157     lw = theSession->ListingWindow();
158     lf = theSession->LogFile();
159 
160     workPart = theSession->Parts()->Work();
161     displayPart = theSession->Parts()->Display();
162 
163 }
164 
165 //------------------------------------------------------------------------------
166 // Destructor
167 //------------------------------------------------------------------------------
168 MyClass::~MyClass()
169 {
170     DestroyWindow(hMain);
171 }
172 
173 //------------------------------------------------------------------------------
174 // Print string to listing window or stdout
175 //------------------------------------------------------------------------------
176 void MyClass::print(const NXString &msg)
177 {
178     if (!lw->IsOpen()) lw->Open();
179     lw->WriteLine(msg);
180 }
181 void MyClass::print(const string &msg)
182 {
183     if (!lw->IsOpen()) lw->Open();
184     lw->WriteLine(msg);
185 }
186 void MyClass::print(const char * msg)
187 {
188     if (!lw->IsOpen()) lw->Open();
189     lw->WriteLine(msg);
190 }
191 
192 
193 //初始化应用程序
194 BOOL MyClass::InitApplication()
195 {
196     WNDCLASSEX wcx;
197 
198     //用参数填充窗口类结构
199     //描述主窗口。
200     wcx.cbSize = sizeof(wcx);            // size of structure 
201     wcx.style = CS_HREDRAW | CS_VREDRAW; // redraw if size changes 
202     wcx.lpfnWndProc = WndProc;           // points to window procedure 
203     wcx.cbClsExtra = 0;                  // no extra class memory 
204     wcx.cbWndExtra = 0;                  // no extra window memory 
205     wcx.hInstance = theInst;             // handle to instance 
206     wcx.hIcon = NULL;                                     // predefined app. icon 
207     wcx.hCursor = LoadCursor(NULL, IDC_ARROW);            // predefined arrow 
208     wcx.hbrBackground = ::GetSysColorBrush(COLOR_WINDOW); // white background brush 
209     wcx.lpszMenuName = NULL;                              // name of menu resource 
210     wcx.lpszClassName = L"TestWClass";                    // name of window class 
211     wcx.hIconSm = NULL;                                   // no small class icon
212 
213     //注册窗口类
214     return RegisterClassEx(&wcx);
215 }
216 
217 
218 //初始化函数
219 BOOL MyClass::InitInstance()
220 {
221     HINSTANCE hInst = MyClass::theInst;
222 
223     //创建主窗口 
224     hMain = CreateWindow(
225         L"TestWClass",       // name of window class 
226         L"Main",             // title-bar string 
227         WS_CAPTION | WS_SYSMENU | WS_OVERLAPPEDWINDOW, // top-level window
228         CW_USEDEFAULT,       // default horizontal position 
229         CW_USEDEFAULT,       // default vertical position 
230         220,                 // default width 
231         250,                 // default height 
232         (HWND)NULL,          // no owner if NULL
233         (HMENU)NULL,        // use class menu 
234         theInst,             // handle to application instance 
235         (LPVOID)NULL);      // no window-creation data 
236 
237     if (!hMain)
238         return FALSE;
239 
240     ShowWindow(hMain, SW_SHOW);
241     UpdateWindow(hMain);
242 
243     return TRUE;
244 }
245 
246 
247 //获取最后一个注册的ID
248 int MyClass::GetLastRegisteredID() const
249 {
250     StlRegisteredTabMap::const_iterator it;
251 
252     int tab_id = 0;
253     for (int i = tab_count; i > 0; i--)
254     {
255         it = g_TabMap.find(i);
256         if (it != g_TabMap.end())
257             return it->second;
258     }
259 
260     return 0;
261 }
262 
263 
264 //获取注册的数量
265 int MyClass::GetRegisteredNumber(int tab_id) const
266 {
267     int tab_num = 0;
268     for (StlRegisteredTabMap::const_iterator it = g_TabMap.begin(); it != g_TabMap.end(); ++it)
269     {
270 
271         if (tab_id == it->second)
272             return it->first;
273     }
274 
275     return tab_num;
276 }
277 
278 
279 //激活Handler
280 int MyClass::ActivationHandler(int tab_id)
281 {
282     try
283     {
284         //获取WindowHandle对象
285         WindowHandle *window_handle = MyClass::theUI->ResourceBarManager()->GetWindowHandle(tab_id);//返回与给定选项卡ID关联的NX停靠窗口
286         //获取真正的handle
287         HWND parent_handle = (HWND)window_handle->GetHandle();
288         BOOL is_window = ::IsWindow(parent_handle);
289 
290         char msg[256];
291         //打开打印信息窗口并打印消息
292         MyClass::listW->Open();
293         sprintf_s(msg, "Window Handle: %p %s", parent_handle, is_window ? "is a window" : "is not a window");
294         MyClass::listW->WriteLine(msg);
295 
296         //检查子窗口是否已经创建
297         HWND child_handle = theMyClass->GetChildWindow(tab_id);
298         if (is_window && child_handle == NULL)
299         {
300             HWND child_handle = CreateChildWindow(parent_handle);
301             theMyClass->SetChildWindow(tab_id, child_handle);
302         }
303     }
304     catch (const NXOpen::NXException& ex)
305     {
306         std::cerr << "Caught exception" << ex.Message() << std::endl;
307     }
308     return 0;
309 }
310 
311 
312 //创建子窗口
313 HWND MyClass::CreateChildWindow(HWND parent_handle)
314 {
315     RECT rcClient;
316     GetClientRect(parent_handle, &rcClient);
317     HWND hChild = NULL;
318     HINSTANCE hInst = MyClass::theInst;
319 
320     if (parent_handle != NULL)
321     {
322         //创建主窗口
323         hChild = CreateWindow(
324             L"TestWClass",       // name of window class 
325             L"Child",            // title-bar string 
326             WS_CHILD | WS_BORDER | WS_VSCROLL | WS_HSCROLL, // child window
327             CW_USEDEFAULT,       // default horizontal position 
328             CW_USEDEFAULT,       // default vertical position 
329             rcClient.right,      // default width
330             rcClient.bottom,     // default height 
331             (HWND)parent_handle, // parent window or no owner if NULL
332             (HMENU)NULL,        // use class menu 
333             hInst,               // handle to application instance 
334             (LPVOID)NULL);      // no window-creation data 
335     }
336 
337     if (!hChild)
338         return NULL;
339 
340     ShowWindow(hChild, SW_SHOW);
341     UpdateWindow(hChild);
342 
343     return hChild;
344 }
345 
346 
347 //创建对话框
348 static BOOL Cls_OnCreate(HWND hwnd, CREATESTRUCT FAR *lpCreateStruct)
349 {
350     WCHAR title[256];
351     GetWindowText(hwnd, title, 256);
352 
353     HINSTANCE hInst = MyClass::theInst;
354 
355     if (wcscmp(title, _T("Child")) == 0)
356     {
357         HWND hInsert = CreateWindow(_T("BUTTON"), _T("Insert Text"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
358             10, 10, 140, 30, hwnd, (HMENU)NULL, hInst, NULL);
359         HWND hEdit = CreateWindow(_T("EDIT"), TEXT("Edit"), WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
360             10, 45, 140, 30, hwnd, (HMENU)NULL, hInst, NULL);
361         //创建组合框控件
362         HWND hComboBox = CreateWindow(WC_COMBOBOX, TEXT("Combo"), CBS_DROPDOWN | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE | CBS_AUTOHSCROLL,
363             10, 80, 140, 140, hwnd, (HMENU)NULL, hInst, NULL);
364 
365         HWND hInsert1 = CreateWindow(_T("BUTTON"), _T("创建块"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
366             10, 280, 140, 30, hwnd, (HMENU)NULL, hInst, NULL);
367 
368         //用项目列表加载组合框
369         TCHAR Planets[9][10] =
370         {
371             TEXT("Mercury"), TEXT("Venus"), TEXT("Terra"), TEXT("Mars"),
372             TEXT("Jupiter"), TEXT("Saturn"), TEXT("Uranus"), TEXT("Neptune"),
373             TEXT("Pluto??")
374         };
375 
376         TCHAR A[16];
377         int  k = 0;
378         memset(&A, 0, sizeof(A));
379         for (k = 0; k <= 8; k += 1)
380         {
381             wcscpy_s(A, sizeof(A) / sizeof(TCHAR), (TCHAR*)Planets[k]);
382 
383             //添加字符串到combobox
384             SendMessage(hComboBox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)A);
385         }
386 
387         //发送CB_SETCURSEL消息以在选择字段中显示初始项
388         SendMessage(hComboBox, CB_SETCURSEL, (WPARAM)2, (LPARAM)0);
389 
390         LoadLibrary(TEXT("Riched20.dll"));
391         HWND hwndEdit = CreateWindowEx(0, RICHEDIT_CLASS, TEXT("Type here"),
392             ES_MULTILINE | WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP,
393             10, 115, 140, 140, hwnd, NULL, hInst, NULL);
394     }
395     else if (wcscmp(title, _T("Main")) == 0)
396     {
397         hAdd = CreateWindow(_T("BUTTON"), _T("Add New Tab"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
398             10, 10, 180, 30, hwnd, (HMENU)NULL, hInst, NULL);
399         hActivate = CreateWindow(_T("BUTTON"), _T("Activate New Tab"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
400             10, 45, 180, 30, hwnd, (HMENU)NULL, hInst, NULL);
401         hHide = CreateWindow(_T("BUTTON"), _T("Hide New Tab"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
402             10, 80, 180, 30, hwnd, (HMENU)NULL, hInst, NULL);
403         hShow = CreateWindow(_T("BUTTON"), _T("Show New Tab"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
404             10, 115, 180, 30, hwnd, (HMENU)NULL, hInst, NULL);
405         hRemove = CreateWindow(_T("BUTTON"), _T("Remove New Tab"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
406             10, 150, 180, 30, hwnd, (HMENU)NULL, hInst, NULL);
407     }
408 
409     return TRUE;
410 }
411 
412 LRESULT CALLBACK WndProc(HWND hwnd,     // handle to window
413     UINT Message,  // message identifier
414     WPARAM wParam, // first message parameter
415     LPARAM lParam  // second message parameter
416     )
417 {
418     switch (Message)
419     {
420     case WM_CREATE:
421         Cls_OnCreate(hwnd, NULL);
422         break;
423     case WM_DESTROY:
424         break;
425     case WM_PAINT:
426         break;
427     case WM_LBUTTONDOWN:
428         break;
429     case WM_CTLCOLOREDIT:
430         break;
431     case WM_MOUSEACTIVATE:
432         break;
433     case WM_SETCURSOR:
434         break;
435     case WM_CHILDACTIVATE:
436         break;
437     case WM_COMMAND:
438     {
439         WCHAR wStr[256];
440         HWND hControl = (HWND)lParam;
441 
442         //在测试对话框中单击按钮
443         if (HIWORD(wParam) == BN_CLICKED)
444         {
445             GetWindowText(hControl, wStr, 256);
446             if (wcscmp(wStr, L"Insert Text") == 0)
447             {
448                 HWND parent = GetParent(hControl);
449                 HWND edit = FindWindowEx(parent, NULL, L"Edit", L"Edit");
450                 // Apply button clicked
451                 if (edit)
452                     SetWindowText(edit, L"This is a Test");
453             }
454             if (wcscmp(wStr, L"创建块") == 0)
455             {
456                 //加锁
457                 UF_UI_lock_ug_access(UF_UI_FROM_CUSTOM);
458 
459                 //点构造器
460                 char sCue[] = "点构造器";
461                 UF_UI_POINT_base_method_t base_method = UF_UI_POINT_INFERRED;
462                 tag_t tPoint = NULL_TAG;
463                 double sBasePoint[] = { 0, 0, 0 };
464                 int iRespone;
465                 UF_UI_point_construct(sCue, &base_method, &tPoint, sBasePoint, &iRespone);
466 
467                 //解锁
468                 UF_UI_unlock_ug_access(UF_UI_FROM_CUSTOM);
469 
470                 //创建块
471                 UF_FEATURE_SIGN Sign = UF_NULLSIGN;//设置布尔
472                 double Corner_pt[3];
473                 Corner_pt[0] = sBasePoint[0];//设置原点
474                 Corner_pt[1] = sBasePoint[1];
475                 Corner_pt[2] = sBasePoint[2];
476                 char *Edge_Len[3] = { "100", "100", "100" };//设置长宽高
477                 tag_t BlkTag = NULL_TAG;
478                 UF_MODL_create_block(Sign, NULL_TAG, Corner_pt, Edge_Len, &BlkTag);
479             }
480 
481             if (hControl == hRemove)
482             {
483                 //删除最后添加的标签
484                 int tab_id = theMyClass->GetLastRegisteredID();
485 
486                 if (tab_id != 0)
487                 {
488                     int tab_num = theMyClass->GetRegisteredNumber(tab_id);
489 
490                     MyClass::theUI->ResourceBarManager()->Destroy(tab_id);//从资源栏区域中删除并销毁与给定选项卡ID关联的选项卡
491                     theMyClass->RemoveRegisteredID(tab_num);
492                     theMyClass->RemoveChildWindow(tab_id);
493                 }
494             }
495             else if (hControl == hAdd)
496             {
497                 //添加新选项卡
498                 tab_count++;
499                 char title[256];
500                 sprintf_s(title, "My Tab %d", tab_count);
501                 int tab_id = MyClass::theUI->ResourceBarManager()->ResourceBarManager::Create(title, "computer");//    通过注册标签数据来创建标签
502                 //注册一个回调,每当要激活自定义选项卡时将调用该回调
503                 MyClass::theUI->ResourceBarManager()->ResourceBarManager::RegisterActivationCallback(tab_id, make_callback(theMyClass, &MyClass::ActivationHandler));
504                 theMyClass->SetRegisteredID(tab_count, tab_id);
505             }
506             else if (hControl == hShow)
507             {
508                 //显示最后添加的标签
509                 int tab_id = theMyClass->GetLastRegisteredID();
510 
511                 if (tab_id != 0)
512                     MyClass::theUI->ResourceBarManager()->SetTabVisibility(tab_id, true);//在资源栏区域中设置选项卡的可见性
513             }
514             else if (hControl == hHide)
515             {
516                 //隐藏最后添加的标签
517                 int tab_id = theMyClass->GetLastRegisteredID();
518 
519                 if (tab_id != 0)
520                     MyClass::theUI->ResourceBarManager()->SetTabVisibility(tab_id, false);//在资源栏区域中设置选项卡的可见性
521             }
522             else if (hControl == hActivate)
523             {
524                 //激活最后添加的标签
525                 int tab_id = theMyClass->GetLastRegisteredID();
526 
527                 if (tab_id != 0)
528                     MyClass::theUI->ResourceBarManager()->ActivateTab(tab_id);//激活资源栏选项卡
529             }
530         }
531     }
532     break;
533     } /* switch */
534 
535     return DefWindowProc(hwnd, Message, wParam, lParam);
536 }
537 
538 
539 
540 
541 //------------------------------------------------------------------------------
542 // Do something
543 //------------------------------------------------------------------------------
544 void MyClass::do_it()
545 {
546 
547     // TODO: add your code here
548 
549 }
550 
551 //------------------------------------------------------------------------------
552 // Entry point(s) for unmanaged internal NXOpen C/C++ programs
553 //------------------------------------------------------------------------------
554 //  Explicit Execution
555 extern "C" DllExport void ufsta(char *parm, int *returnCode, int rlen)
556 {
557     try
558     {
559 
560         if (UF_initialize())
561         {
562             /* Failed to initialize */
563             return;
564         }
565 
566         if (theMyClass == NULL)
567             theMyClass = new MyClass();
568 
569         /* TODO: Add your application code here */
570         BOOL init = theMyClass->InitApplication();
571         if (init)
572             init = theMyClass->InitInstance();
573 
574         // Create NXOpen C++ class instance
575         theMyClass->do_it();
576 
577         /* Terminate the API environment */
578         UF_terminate();
579 
580 
581 
582     }
583     catch (const NXException& e1)
584     {
585         UI::GetUI()->NXMessageBox()->Show("NXException", NXOpen::NXMessageBox::DialogTypeError, e1.Message());
586     }
587     catch (const exception& e2)
588     {
589         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, e2.what());
590     }
591     catch (...)
592     {
593         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, "Unknown Exception.");
594     }
595 }
596 
597 
598 //------------------------------------------------------------------------------
599 // Unload Handler
600 //------------------------------------------------------------------------------
601 extern "C" DllExport int ufusr_ask_unload()
602 {
603     return (int)NXOpen::Session::LibraryUnloadOptionAtTermination;
604 }
605 
606 
607 extern void ufusr_cleanup()
608 {
609     try
610     {
611         //---- Enter your callback code here -----
612         char msg[256];
613         // Open the Print the Information window and print the message.
614         MyClass::listW->Open();
615         sprintf_s(msg, "ufusr clean up");
616         MyClass::listW->WriteLine(msg);
617 
618         if (theMyClass != NULL)
619         {
620             for (MyClass::StlRegisteredTabMap::const_iterator it = MyClass::g_TabMap.begin(); it != MyClass::g_TabMap.end(); ++it)
621             {
622                 int num = it->first;
623                 int tab_id = it->second;
624 
625                 if (tab_id > 0)
626                     MyClass::theUI->ResourceBarManager()->Destroy(tab_id);
627             }
628 
629             delete theMyClass;
630             theMyClass = NULL;
631         }
632     }
633     catch (const NXOpen::NXException& ex)
634     {
635         std::cerr << "Caught exception" << ex.Message() << std::endl;
636     }
637 }
638 
639 Caesar卢尚宇
640 2019年11月25日

原文地址:https://www.cnblogs.com/nxopen2018/p/11930766.html