[原创]用TAB键移动视图的程序
<p>自己用SDK中pretranslate的例子写了一个移动视图的程序,挺简单的</p><p>附上工程中唯一的CPP文件,用它来替代SDK下pretranslate中的CPP文件再编译即可</p><p>//////////////////////////////////////////////////////////////<br/>//<br/>// Includes<br/>//<br/>//////////////////////////////////////////////////////////////<br/>#define _AFX_NOFORCE_LIBS // we do not want to link to MFC DLLs or libs<br/>#ifdef _DEBUG<br/>#define WAS_DEBUG<br/>#undef _DEBUG<br/>#endif</p><p>#include "afxwin.h" // need this because rxmfcapi.h needs windows header. </p><p>#ifdef WAS_DEBUG<br/>#undef WAS_DEBUG<br/>#define _DEBUG<br/>#endif</p><p>#include "aced.h"<br/>#include "adslib.h"<br/>#include "rxmfcapi.h"<br/>#include <windef.h><br/>#include<accmd.h> //acedCommand<br/>#include<acedads.h> //acedSetVar<br/>#include<adscodes.h><br/>#include<adsdef.h> //resbuf<br/>#include <rxmfcapi.h><br/>#include<dbsymtb.h> //AcDbViewTableRecord<br/>#include<gepnt3d.h> //AcGePoint3d<br/>#include<dbapserv.h> //acdbHostApplicationServices<br/>#include<gepnt2d.h> //AcGePoint2d</p><p><br/>//////////////////////////////////////////////////////////////<br/>//<br/>// Standard C Test function<br/>//<br/>//////////////////////////////////////////////////////////////</p><p>void snapTAB(); // ARX callbacks <br/>//void zoomExtents();<br/>//void zoomExtents();<br/>void moveview();<br/>BOOL filterTAB(MSG *pMsg); // hook function for capsing.</p><p><br/>// preventing from inserting the same hook twice.<br/>static BOOL TABDone = FALSE;<br/>static long px=0;<br/>static long py=0;</p><p>/*static struct resbuf wcs, ucs;*/ // 转换坐标时使用的坐标系统标记<br/>//////////////////////////////////////////////////////////////<br/>//<br/>// Rx interface<br/>//<br/>//////////////////////////////////////////////////////////////</p><p><br/>void initApp()<br/>{<br/>////snapTAB();<br/> acedRegCmds->addCommand( "MKEvents", // Group name <br/> "caps", // Global function name<br/> "caps", // Local function name<br/> ACRX_CMD_MODAL, // Type<br/> &snapTAB ); // Function pointer<br/> <br/> //acutPrintf( ".OK!\n" );</p><p>}</p><p>void unloadApp()<br/>{<br/> <br/> if (TABDone == TRUE)<br/> acedRemoveFilterWinMsg(filterTAB); </p><p><br/>}</p><p><br/>//////////////////////////////////////////////////////////////<br/>//<br/>// Entry point<br/>//<br/>//////////////////////////////////////////////////////////////</p><p>extern "C" AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void* pkt)<br/>{<br/> switch( msg ) <br/> {<br/> case AcRx::kInitAppMsg: <br/> //initApp();<br/> snapTAB();<br/> acrxUnlockApplication(pkt);<br/> acrxDynamicLinker->registerAppMDIAware(pkt);<br/> acutPrintf( ".OK!\n" );<br/> break;<br/> case AcRx::kUnloadAppMsg: <br/> unloadApp(); <br/> break;<br/> default:<br/> break;<br/> }<br/> return AcRx::kRetOK; <br/>}</p><p></p><p>//////////////////////////////////////////////////////////////</p><p>BOOL filterTAB(MSG *pMsg)<br/>{ <br/> // Change All lowercase to caps!!<br/> if (pMsg->message == WM_CHAR && pMsg->wParam == 9)//TAB键<br/> { </p><p> moveview();</p><p> }else if (pMsg->message == WM_MOUSEMOVE || pMsg->message == WM_LBUTTONDOWN<br/> || pMsg->message == WM_LBUTTONUP){<br/> px=LOWORD(pMsg->lParam);<br/> py=HIWORD(pMsg->lParam);<br/> }<br/> return FALSE; // continue<br/>}</p><p></p><p><br/>void snapTAB()<br/>{<br/> if (TABDone == TRUE) // already has the hook??<br/> return;<br/> acutPrintf( "Capsing...\n" );<br/> if (acedRegisterFilterWinMsg(filterTAB) == FALSE)<br/> acutPrintf("Can't register Windows Msg hook - Lower->upper\n");<br/> else<br/> TABDone = TRUE;<br/>}</p><p>void moveview()<br/>{<br/>//acutPrintf("移动视口!\n");<br/>//本函数用来移动视口<br/> struct resbuf wcs, ucs; // 转换坐标时使用的坐标系统标记<br/> wcs.restype = RTSHORT; wcs.resval.rint = 0; <br/> ucs.restype = RTSHORT; ucs.resval.rint = 1; <br/> double screenx,screeny,vscal;// 1/2 屏幕 宽高 比例:像素/图形单位<br/> struct resbuf viewctr1 ;<br/> double vhight,vwidth;<br/> ads_point ptCurrent;</p><p> AcGePoint2d center_2d,ocenter_2d;//前一个为待移动的中心点 后一个为当前中心点<br/> acedGetVar("screensize",&viewctr1);//二维点 以像素为单位存储当前视口的大小<br/> screenx=viewctr1.resval.rpoint/2;// 1/2 屏幕 宽<br/> screeny=viewctr1.resval.rpoint/2;// 1/2 屏幕 高<br/> <br/> acedGetVar("viewsize",&viewctr1);//类型:实数 按图形单位存储当前视口的高度。<br/> vhight=viewctr1.resval.rreal;//当前视口的高度 类型:实数<br/> vscal=screeny/vhight*2;//比例:像素/图形单位<br/> vwidth= screenx/vscal ;//当前视口的宽度 类型:实数</p><p> //*********************************************************************<br/> acedGetVar("viewctr",&viewctr1);<br/> //类型:三维点 存储当前视口中视图的中心点。该值用 UCS 坐标表示。<br/> ocenter_2d=viewctr1.resval.rpoint;<br/> ocenter_2d=viewctr1.resval.rpoint;<br/> //*************************************************************<br/> ptCurrent=(px-screenx)/vscal+ocenter_2d;<br/> ptCurrent=(screeny-py)/vscal+ocenter_2d;<br/> acedTrans(ptCurrent, &ucs, &wcs, 0, ptCurrent);<br/> center_2d=ptCurrent;<br/> center_2d=ptCurrent;</p><p> AcDbViewTableRecord view ;// view2;<br/> view.setCenterPoint (center_2d);</p><p> view.setHeight(vhight);//设定图形单位高<br/> view.setWidth(vwidth);//设定图形单位宽<br/> <br/> //acutPrintf("调用!x:%lf Y:%lf\n" ,vwidth,vhight);<br/> acedSetCurrentView (&view, NULL);//NULL</p><p> acdbHostApplicationServices()->workingDatabase()->updateExt(TRUE);//TRUE<br/>}</p> <p>我这里出现很多错误</p><p>--------------------Configuration: pretranslate - Win32 Debug--------------------<br/>Linking...<br/> Creating library .\Debug/pretranslate.lib and object .\Debug/pretranslate.exp<br/>LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library<br/>rxtemplt.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall AcDbViewTableRecord::~AcDbViewTableRecord(void)" (<a href="mailto:??1AcDbViewTableRecord@@UAE@XZ">??1AcDbViewTableRecord@@UAE@XZ</a>)<br/>rxtemplt.obj : error LNK2001: unresolved external symbol "public: enum Acad::ErrorStatus __thiscall AcDbDatabase::updateExt(bool)" (<a href="mailto:?updateExt@AcDbDatabase@@QAE?AW4ErrorStatus@Acad@@_N@Z">?updateExt@AcDbDatabase@@QAE?AW4ErrorStatus@Acad@@_N@Z</a>)<br/>rxtemplt.obj : error LNK2001: unresolved external symbol "public: void __thiscall AcDbAbstractViewTableRecord::setWidth(double)" (<a href="mailto:?setWidth@AcDbAbstractViewTableRecord@@QAEXN@Z">?setWidth@AcDbAbstractViewTableRecord@@QAEXN@Z</a>)<br/>rxtemplt.obj : error LNK2001: unresolved external symbol "public: void __thiscall AcDbAbstractViewTableRecord::setHeight(double)" (<a href="mailto:?setHeight@AcDbAbstractViewTableRecord@@QAEXN@Z">?setHeight@AcDbAbstractViewTableRecord@@QAEXN@Z</a>)<br/>rxtemplt.obj : error LNK2001: unresolved external symbol "public: void __thiscall AcDbAbstractViewTableRecord::setCenterPoint(class AcGePoint2d const &)" (<a href="mailto:?setCenterPoint@AcDbAbstractViewTableRecord@@QAEXABVAcGePoint2d@@@Z">?setCenterPoint@AcDbAbstractViewTableRecord@@QAEXABVAcGePoint2d@@@Z</a>)<br/>rxtemplt.obj : error LNK2001: unresolved external symbol "public: __thiscall AcDbViewTableRecord::AcDbViewTableRecord(void)" (<a href="mailto:??0AcDbViewTableRecord@@QAE@XZ">??0AcDbViewTableRecord@@QAE@XZ</a>)<br/>.\pretranslate.arx : fatal error LNK1120: 6 unresolved externals<br/>Error executing link.exe.</p><p>pretranslate.arx - 7 error(s), 1 warning(s)</p> <p></p><p>这是工程文件</p> <p><font style="BACKGROUND-COLOR: #eeee11;"><strong>看到下面的文字吗?</strong></font></p><p><font style="BACKGROUND-COLOR: #eeee11;"><strong>附上工程中唯一的CPP文件,用它来替代SDK下pretranslate中的CPP文件再编译即可</strong></font></p> <p>问题出在引入的库文件上面,可能是有些库文件没引用,我用的的SDK2006,没法调试,我看了一下,你的调试版本和发布版本引入的库不一样。</p><p>你用下面的试试 </p><p><table cellspacing="0" cellpadding="0" width="72" border="0" style="WIDTH: 54pt; BORDER-COLLAPSE: collapse;"><colgroup><col width="72" style="WIDTH: 54pt;"></col></colgroup><tbody><tr height="19" style="HEIGHT: 14.25pt;"><td width="72" height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 54pt; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;">acad.lib</td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;">rxapi.lib</td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;">acedapi.lib</td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;">acrx15.lib</td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;">acutil15.lib<br/><font color="#ff0000">acdb15.lib</font></td></tr></tbody></table></p> <p>还是有很多错误:</p><p>--------------------Configuration: pretranslate - Win32 Debug--------------------<br/>Linking...<br/> Creating library .\Debug/pretranslate.lib and object .\Debug/pretranslate.exp<br/>rxtemplt.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: double & __thiscall AcGePoint2d::operator[](unsigned int)" (<a href="mailto:__imp_??AAcGePoint2d@@QAEAANI@Z">__imp_??AAcGePoint2d@@QAEAANI@Z</a>)<br/>rxtemplt.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall AcGePoint2d::AcGePoint2d(void)" (<a href="mailto:__imp_??0AcGePoint2d@@QAE@XZ">__imp_??0AcGePoint2d@@QAE@XZ</a>)<br/>.\pretranslate.arx : fatal error LNK1120: 2 unresolved externals<br/>Error executing link.exe.</p> <p><font color="#ff0000">acge15.lib</font><br/>这个呢?</p>
页:
[1]