- UID
- 246950
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-4-20
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
听了老大们的建议。开始研究用vc71。欢迎大家指正
我实在不想装vc2003.
vc71好象有4个关键部分。
1. bin目录(要外加 mspdb71.dll, msvcp71.dll)
2.atlmfc;
3.include + lib
4.platformSDK.
把这几个作到dos set上。
改acedapi.lib 和rxapi.lib 中的mfc70.lib 到mfc71.lib(我实在是找不到mfc70.lib), 或用DLL to Lib 转mfc70.dll 得到mfc70.lib的静态库。
这样就能骗过arx了。
编译:肯定是在dos下,kukuku.
副作用。不能用mfc,放入cad2004报不能识别,点加载居然能用。hehehehe. 看来要上钩子了。如果有mfc70.lib + mfcs70.lib估计这条作废。
测试:除了不能用mfc外,其他DB功能OK.
附相关文件。
rem //////////设置cl路径;
path D:\vc7\Vc7\bin;d:\vc7\vc7\bin\z999999;D:\vc7\Common7\IDE;%PATH%
rem ////设置别的路径;
rem set EL1=D:\SDK\openDWG20\include;
rem set EL2=D:\SDK\openDWG20\lib;
rem set LL1=adv6Nt.lib
set EL1=D:\SDK\Dx81sdk\include;
set EL2=D:\SDK\Dx81sdk\lib;
set LL1=d3d8.lib d3dx8.lib
set include=F:\download\arx_sdk2004\inc;D:\vc7\Vc7\PlatformSDK\Include;D:\vc7\Vc7\atlmfc\include;D:\vc7\Vc7\include;d:\vc6\vc98\atl\include;d:\SDK\wtl70\include;d:\vc6\vc98\include;%EL1% %PATH%
set lib=F:\download\arx_sdk2004\lib;D:\vc7\Vc7\PlatformSDK\Lib;D:\vc7\Vc7\atlmfc\lib;D:\vc7\Vc7\lib;d:\vc6\vc98\lib;%EL2% %PATH%;
rem /////////[GX:能异常处理][Zi:能调试][LD:编译DLL][Fm:创造map][O1:小码] [MD:与 MSVCRT.LIB 链接,避免联接libcp.lib错误] /nodefaultlib:"msvcrt"
rem ////////释放编译 cl /GX ws2_32.lib atl.lib kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib Comdlg32.lib %1
rem ///////调试编译
cl.exe /MD /LD /EHsc acISMobj16.lib acge16.lib acdb16.lib acedapi.lib rxapi.lib acad.lib kernel32.lib gdi32.lib uuid.lib Comdlg32.lib %1 /link /def:del.def /out:del.arx
- [FONT=courier new]
- #define WINVER 0x500
- ///#include "sizecbar.h"
- ///#include "scbarg.h"
- #define _WTL_USE_CSTRING
- #define _ATL_USE_CSTRING_FLOAT
- #include <atlbase.h>
- CComModule _Module;
- #include <atlapp.h>
- #include <atlmisc.h>
- #include <adscodes.h>
- #include <string.h>
- #include <aced.h>
- #include <dbents.h>
- #include <dbsymtb.h>
- #include <dbgroup.h>
- #include <dbapserv.h>
- #include <acdocman.h>
- #include <imgdef.h> ////AcDbRasterImage;
- #include <imgent.h>
- #include <rxregsvc.h>
- static AcDbDatabase* GetDB(){
- return acdbHostApplicationServices()->workingDatabase();
- }
- static AcDbBlockTableRecord* GetModelSpaceRecord(AcDbDatabase* pDB, AcDb::OpenMode mode){
- Acad::ErrorStatus err;
- AcDbBlockTable *pTable;
- AcDbBlockTableRecord * pRecord = NULL;
-
- err = pDB->getSymbolTable(pTable, AcDb::kForRead);
- if(err == Acad::eOk){
- err = pTable->getAt(ACDB_MODEL_SPACE, pRecord, mode);
- if(err != Acad::eOk){
- pRecord = NULL;
- }
- pTable->close();
- }
- return pRecord;
- }
- static Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEntity){
- Acad::ErrorStatus err = Acad::eNullHandle;
- AcDbBlockTableRecord* pRecord = GetModelSpaceRecord(GetDB(), AcDb::kForWrite);
- if(pRecord){
- err = pRecord->appendAcDbEntity(pEntity);
- if(err == Acad::eOk){
- pEntity->close();
- }
- pRecord->close();
- }
- return err;
- }
- //////////Image Process start =================
- static BOOL RImg_CreateImgDef_(AcDbObjectId& defID, const char* pImgPath, const char* pImgName){
- BOOL isOK = FALSE;
- Acad::ErrorStatus err;
- // Create new image def object
- AcDbRasterImageDef* pImgDef = new AcDbRasterImageDef();
- if(pImgDef){
- err = pImgDef->setSourceFileName(pImgPath);
- if(err == Acad::eOk){
- err = pImgDef->load();
- ////dict process;
- if(err == Acad::eOk){
- AcDbObjectId dictID = AcDbRasterImageDef::imageDictionary(GetDB());
- if(dictID.asOldId() == 0){
- AcDbRasterImageDef::createImageDictionary(GetDB(), dictID);
- }
- if(dictID.asOldId() != 0){
- AcDbDictionary* pDict;
- err = acdbOpenObject((AcDbObject*&)pDict, dictID, AcDb::kForWrite);
- if(err == Acad::eOk){
- if(!pDict->has(pImgName)){
- err = pDict->setAt(pImgName, pImgDef, defID);
- if(err == Acad::eOk){
- pImgDef->close();
- isOK = TRUE;
- }
- }
- pDict->close();
- }
- }
- }
- }
- if(!isOK){
- delete pImgDef;
- }
- }
-
- return isOK;
- }
- static BOOL RImg_CreateImg_(AcDbObjectId& entID, AcDbObjectId defID){
- BOOL isOK = FALSE;
- Acad::ErrorStatus err;
- AcDbRasterImage* pImg = new AcDbRasterImage();
-
- if(pImg){
- err = pImg->setImageDefId(defID);
- if(err == Acad::eOk){
- err = AddToModelSpace(pImg);
- if(err == Acad::eOk){
- entID = pImg->objectId();
- pImg->close();
- isOK = TRUE;
- }
- }
- if(!isOK){
- delete pImg;
- }
- }
- return isOK;
- }
- static BOOL RImg_GetImgWH_(const char* pFileName, float& w, float& h){
- BOOL isOK = FALSE;
- Acad::ErrorStatus err;
- AcDbRasterImageDef* pImgDef = new AcDbRasterImageDef();
- if(pImgDef){
- err = pImgDef->setSourceFileName(pFileName);
- if(err == Acad::eOk){
- err = pImgDef->load();
- if(err == Acad::eOk){
- AcGeVector2d wh = pImgDef->size();
- if(wh.x>0 && wh.y>0){
- w = wh.x;
- h = wh.y;
- isOK = TRUE;
- }
- pImgDef->unload();
- }
- }
- pImgDef->close();
- delete pImgDef;
- }
-
- return isOK;
- }
- static BOOL RImg_InsertImg_Gen_(const char* pFilePath, const char* pImgName, AcDbObjectId& imgID){
- BOOL isOK = FALSE;
- Acad::ErrorStatus err;
- float w; float h;
- float x = 0, y = 0;
- if(!RImg_GetImgWH_(pFilePath, w, h))return FALSE;
-
- AcDbObjectId defID;
- if(RImg_CreateImgDef_(defID, pFilePath, pImgName)){
- if(RImg_CreateImg_(imgID, defID)){
- AcDbRasterImage* pImg;
- err = acdbOpenObject((AcDbObject*&)pImg, imgID, AcDb::kForWrite);
- if(err == Acad::eOk){
-
- AcGeVector3d u,v;
- u.set(w, 0,0);
- v.set(0, h, 0);
- AcGePoint3d o(x, y, 0);
- pImg->setOrientation(o, u, v);
- ////pImg->setColorIndex(color);
- pImg->close();
- isOK = TRUE;
- }
- }
- }
-
- return isOK;
- }
- //////////Image Process end ===================
- static BOOL GetCADSelectRect(CRect& r){
- BOOL isOK = FALSE;
- ///set doc focus;
-
- //从cad获得选择范围
- ads_point p1,p2;
- if(acedGetPoint(NULL, NULL, p1) == RTNORM){
- if(acedGetCorner(p1, NULL, p2) == RTNORM){
- long minX = __min(p1[0], p2[0]);
- long minY = __min(p1[1], p2[1]);
- long maxX = __max(p1[0], p2[0]);
- long maxY = __max(p1[1], p2[1]);
- ////acutPrintf("x1:%f y1:%f x2:%f y2:%f \r\n", p1[0],p1[1], p2[0],p2[1]);
- ads_point t1, t2, t3, t4;
- t1[0] = minX; t1[1] = minY; t1[2] = 0;
- t2[0] = maxX; t2[1] = minY; t2[2] = 0;
- t3[0] = maxX; t3[1] = maxY; t3[2] = 0;
- t4[0] = minX; t4[1] = maxY; t4[2] = 0;
- acedGrDraw(t1, t2, 1, 0);
- acedGrDraw(t2, t3, 1, 0);
- acedGrDraw(t3, t4, 1, 0);
- acedGrDraw(t4, t1, 1, 0);
- r = CRect(minX, minY, maxX, maxY);
- isOK = TRUE;
- }
- }
- return isOK;
- }
- static void OnlyLockDoc(){
- acDocManager->lockDocument(acDocManager->curDocument());
- }
- static void OnlyUnlockDoc(){
- acDocManager->unlockDocument(acDocManager->curDocument());
- }
- static AcDbBlockTableRecord* test1(AcDbDatabase* pDB){
- Acad::ErrorStatus err;
- AcDbBlockTable *pTable;
- AcDbBlockTableRecord * pRecord = NULL;
-
- err = pDB->getSymbolTable(pTable, AcDb::kForRead);
- if(err == Acad::eOk){
- err = pTable->getAt(ACDB_MODEL_SPACE, pRecord, AcDb::kForWrite);
- if(err == Acad::eOk){
- AcGePoint3d p1(0,0,0);
- AcGePoint3d p2(100,100,0);
- AcDbLine* pLine = new AcDbLine(p1, p2);
- err = pRecord->appendAcDbEntity(pLine);
- acutPrintf("err:%i, ok:%i\r\n", err, Acad::eOk);
- pLine->close();
-
- }
- pTable->close();
- }
- return pRecord;
- }
- void initApp(){
- acrxLoadModule("acismui.arx", 1);
- acutPrintf("gggggggggg\r\n");
- OnlyLockDoc();
- AcDbBlockTableRecord* pRecord = test1(GetDB());
- if(pRecord){
- acutPrintf("pRecord:%i\r\n", pRecord);
- pRecord->close();
- }
- AcDbObjectId id;
- RImg_InsertImg_Gen_("d:\\3.jpg", "ssss", id);
- OnlyUnlockDoc();
- acutPrintf("ssssssssssssss\r\n");
- CRect r;
- GetCADSelectRect(r);
- acutPrintf("%i, %i, %i, %i\r\n", r.left, r.top, r.right, r.bottom);
- }
- void unloadApp(){
- }
- AcRx::AppRetCode
- acrxEntryPoint(AcRx::AppMsgCode msg, void* appId){
- switch (msg) {
- case AcRx::kInitAppMsg:
- acrxDynamicLinker->unlockApplication(appId);
- acrxDynamicLinker->registerAppMDIAware(appId);
- initApp();
- break;
- case AcRx::kUnloadAppMsg:
- unloadApp();
- }
- return AcRx::kRetOK;
- }
- [/FONT]
复制代码 |
|