cad的菜單既能夠經過menu命令加載,也能夠經過代碼自動加載app
頭文件:#include "CAcadApplication.h" #include "CAcadMenuGroups.h"ui
//得到菜單路徑 TCHAR szFilePath[MAX_PATH+1]; memset(szFilePath, 0, MAX_PATH+1); GetModuleFileName(_hdllInstance, szFilePath, MAX_PATH); CString strPath(szFilePath); CLayerSelDlg dlg; dlg.GetParentPath(strPath); dlg.GetParentPath(strPath); strPath = strPath + _T("\\menu\\menu.cuix"); if (_taccess(strPath, 0) != -1) { CoInitialize(NULL); try { CAcadApplication appCAD(acedGetAcadWinApp()->GetIDispatch(TRUE)); VARIANT BaseMenu; //是否加載爲基礎菜單 VariantInit(&BaseMenu); BaseMenu.vt = VT_BOOL; BaseMenu.boolVal = TRUE; CAcadMenuGroups acadMenuGroups(appCAD.get_MenuGroups()); acadMenuGroups.Load(strPath, BaseMenu); acadMenuGroups.ReleaseDispatch(); } catch(COleDispatchException* e) { TCHAR szError[1024]; szError[0] = 0; e->GetErrorMessage(szError, 1023); //MessageBox(NULL, szError, _T("系統錯誤"), MB_ICONERROR); } catch(...) { return; } CoUninitialize(); }