- 积分
- 942
- 明经币
- 个
- 注册时间
- 2018-6-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2018-7-1 00:24:57
|
显示全部楼层
Building debug version of curveText.dbx to be used with non-debug/Prod AutoCAD
//自动菜单
//
// This use COM by itself (without MFC), to access
// the AutoCAD ActiveX Automation APIs. from sample <AsdkPlainComSamp.cpp>
//
#include "stdafx.h"
#include <rxregsvc.h>
#include <aced.h>
#include <adslib.h>
#include "tchar.h"
#include "WinRegister.h"
#ifdef CAD2008
#import "C:\\ObjectARX_2008\\inc\\acax17ENU.tlb" no_implementation raw_interfaces_only named_guids
#endif
#ifdef CAD2007
#import "C:\\ObjectARX_2007\\inc\\acax17ENU.tlb" no_implementation raw_interfaces_only named_guids
#endif
#ifdef CAD2006
#import "C:\\ObjectARX_2006\\inc\\acax16ENU.tlb" no_implementation raw_interfaces_only named_guids
#endif
#ifdef CAD2004
#import "C:\\ObjectARX_2004\\inc\\acax16ENU.tlb" no_implementation raw_interfaces_only named_guids
#endif
#ifdef CAD2010
#ifdef X64
#import "C:\\ObjectARX_2010\\inc-X64\\acax18ENU.tlb" no_implementation raw_interfaces_only named_guids
#else
#import "C:\\ObjectARX_2010\\inc-win32\\acax18ENU.tlb" no_implementation raw_interfaces_only named_guids
#endif
#endif
#ifdef CAD2012
#ifdef X64
#import "C:\\ObjectARX_2012\\inc-X64\\acax18ENU.tlb" no_implementation raw_interfaces_only named_guids
#else
#import "C:\\ObjectARX_2012\\inc-win32\\acax18ENU.tlb" no_implementation raw_interfaces_only named_guids
#endif
#endif
#ifdef CAD2013
#ifdef X64
#import "C:\\ObjectARX_2013\\inc-X64\\acax19ENU.tlb" no_implementation raw_interfaces_only named_guids
#else
#import "C:\\ObjectARX_2013\\inc-win32\\acax19ENU.tlb" no_implementation raw_interfaces_only named_guids
#endif
#endif
static bool bIsMenuLoaded = false;
void addMenuThroughCom()
{
AutoCAD::IAcadApplication *pAcad;
AutoCAD::IAcadMenuBar *pMenuBar;
AutoCAD::IAcadMenuGroups *pMenuGroups;
AutoCAD::IAcadMenuGroup *pMenuGroup;
AutoCAD::IAcadPopupMenus *pPopUpMenus;
AutoCAD::IAcadPopupMenu *pPopUpMenu;
AutoCAD::IAcadPopupMenuItem *pPopUpMenuItem;
int indexMenu = 0;
#ifdef CAD2004
HRESULT hr = NOERROR;
CLSID clsid;
LPUNKNOWN pUnk = NULL;
LPDISPATCH pAcadDisp = NULL;
hr = ::CLSIDFromProgID(L"AutoCAD.Application", &clsid);
if (FAILED(hr))
return;
if(::GetActiveObject(clsid, NULL, &pUnk) != S_OK)
return;
hr = pUnk->QueryInterface(IID_IDispatch, (LPVOID*) &pAcadDisp);
pUnk->Release();
if (FAILED(hr))
return;
#else
HRESULT hr = NOERROR;
LPUNKNOWN pUnk = NULL;
LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE);
if(pAcadDisp==NULL)
return;
#endif
hr = pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication,(void**)&pAcad);
pAcadDisp->Release();
if (FAILED(hr))
return;
pAcad->put_Visible(true);
pAcad->get_MenuBar(&pMenuBar);
pAcad->get_MenuGroups(&pMenuGroups);
pAcad->Release();
long numberOfMenus;
pMenuBar->get_Count(&numberOfMenus);
pMenuBar->Release();
VARIANT index;
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
pMenuGroups->Item(index, &pMenuGroup);
pMenuGroups->Release();
pMenuGroup->get_Menus(&pPopUpMenus);
pMenuGroup->Release();
WCHAR wstrMenuName[256];
#ifdef UNICODE
if(Global_ChineseVersion)
_tcscpy(wstrMenuName, L"二维码");
else
_tcscpy(wstrMenuName, L"QRCode");
#else
if(Global_ChineseVersion)
MultiByteToWideChar(CP_ACP, 0, "二维码", -1, wstrMenuName, 256);
else
MultiByteToWideChar(CP_ACP, 0, "QRCode", -1, wstrMenuName, 256);
#endif // !UNICODE
// Enables the menu to be loaded/unloaded with the same command.
if (!bIsMenuLoaded) {
pPopUpMenus->Add(wstrMenuName, &pPopUpMenu);
if (pPopUpMenu != NULL) {
WCHAR wstrMenuItemName[256];
WCHAR wstrMenuItemMacro[256];
#ifdef UNICODE
if(Global_ChineseVersion)
_tcscpy(wstrMenuItemName, L"绘制二维码");
else
_tcscpy(wstrMenuItemName, L"Draw QRCode");
_tcscpy(wstrMenuItemMacro, L"CADQR ");
#else // !UNICODE
if(Global_ChineseVersion)
MultiByteToWideChar(CP_ACP, 0, "绘制二维码", -1, wstrMenuItemName, 256);
else
MultiByteToWideChar(CP_ACP, 0, "Draw QRCode", -1, wstrMenuItemName, 256);
MultiByteToWideChar(CP_ACP, 0, "CADQR ", -1, wstrMenuItemMacro, 256);
#endif // !UNICODE
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = indexMenu; indexMenu++;
pPopUpMenu->AddMenuItem(index, wstrMenuItemName, wstrMenuItemMacro, &pPopUpMenuItem);
//-------------------------------
#ifdef UNICODE
_tcscpy(wstrMenuItemName, L"www.SummerCAD.com");
_tcscpy(wstrMenuItemMacro, L"gotoSummerCAD ");
#else // !UNICODE
MultiByteToWideChar(CP_ACP, 0, "www.SummerCAD.com", -1, wstrMenuItemName, 256);
MultiByteToWideChar(CP_ACP, 0, "gotoSummerCAD ", -1, wstrMenuItemMacro, 256);
#endif // !UNICODE
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = indexMenu; indexMenu++;
pPopUpMenu->AddMenuItem(index, wstrMenuItemName, wstrMenuItemMacro, &pPopUpMenuItem);
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = numberOfMenus - 2;
pPopUpMenu->InsertInMenuBar(index);
pPopUpMenuItem->Release();
bIsMenuLoaded = true;
} else {
acutPrintf(_T("\nMenu not created."));
}
} else {
VariantInit(&index);
V_VT(&index) = VT_BSTR;
V_BSTR(&index) = wstrMenuName;
pPopUpMenus->RemoveMenuFromMenuBar(index);
VariantClear(&index);
bIsMenuLoaded = false;
}
pPopUpMenus->Release();
}
void setExpertMode()
{
TCHAR reply[256];
_tcscpy(reply, _T("Yes"));
acedInitGet(NULL, _T("Yes No"));
int res;
if(Global_ChineseVersion)
res = acedGetKword(_T("\n启用专家模式菜单(Y/N)[Y]:"), reply);
else
res = acedGetKword(_T("\nUsing Expert Mode(Y/N)[Y]:"), reply);
if (res == RTNONE || reply[0] == _T('Y'))
{
RegPutInt(HKEY_CURRENT_USER,_T("Software\\SummerCAD\\SDWM"), _T("ExpertMode"), 1);
}else{
RegPutInt(HKEY_CURRENT_USER,_T("Software\\SummerCAD\\SDWM"), _T("ExpertMode"), 0);
}
acutPrintf(_T("\n重新启动AutoCAD后生效。"));
}
输出窗口
正在编译...
acrxEntryPoint.cpp
WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
Building debug version of curveText.dbx to be used with non-debug/Prod AutoCAD
AutoMenu.cpp
Building debug version of curveText.dbx to be used with non-debug/Prod AutoCAD
***\automenu.cpp(59) : error C2653: “AutoCAD”: 不是类或命名空间名称
***\automenu.cpp(59) : error C2065: “IAcadApplication”: 未声明的标识符
***\automenu.cpp(59) : error C2065: “pAcad”: 未声明的标识符
***\automenu.cpp(60) : error C2653: “AutoCAD”: 不是类或命名空间名称
***\automenu.cpp(60) : error C2065: “IAcadMenuBar”: 未声明的标识符
***\automenu.cpp(60) : error C2065: “pMenuBar”: 未声明的标识符
***\automenu.cpp(61) : error C2653: “AutoCAD”: 不是类或命名空间名称
***\automenu.cpp(61) : error C2065: “IAcadMenuGroups”: 未声明的标识符
***\automenu.cpp(61) : error C2065: “pMenuGroups”: 未声明的标识符
***\automenu.cpp(62) : error C2653: “AutoCAD”: 不是类或命名空间名称
***\automenu.cpp(62) : error C2065: “IAcadMenuGroup”: 未声明的标识符
***\automenu.cpp(62) : error C2065: “pMenuGroup”: 未声明的标识符
***\automenu.cpp(63) : error C2653: “AutoCAD”: 不是类或命名空间名称
***\automenu.cpp(63) : error C2065: “IAcadPopupMenus”: 未声明的标识符
***\automenu.cpp(63) : error C2065: “pPopUpMenus”: 未声明的标识符
***\automenu.cpp(64) : error C2653: “AutoCAD”: 不是类或命名空间名称
***\automenu.cpp(64) : error C2065: “IAcadPopupMenu”: 未声明的标识符
***\automenu.cpp(64) : error C2065: “pPopUpMenu”: 未声明的标识符
***\automenu.cpp(65) : error C2653: “AutoCAD”: 不是类或命名空间名称
***\automenu.cpp(65) : error C2065: “IAcadPopupMenuItem”: 未声明的标识符
***\automenu.cpp(65) : error C2065: “pPopUpMenuItem”: 未声明的标识符
崩溃啦 |
|