- UID
- 281509
- 积分
- 1054
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-6-21
- 最后登录
- 1970-1-1
|
发表于 2006-7-12 17:19:50
|
显示全部楼层
你是要判断鼠标是否在绘图区域而非菜单工具等上呢?
给你个程序参考:
//是否在有效的编辑区域
BOOL CGenericFun::IsInEditWindows(int WantToNo,int& ResultNo)
{
BOOL mRet;
struct resbuf rb;
CPoint CurPt;
double douWidth,douHeight;
AcGePoint3d mousPt;
AcGePoint3d cenPt;
AcGePoint3d winPt1,winPt2;
acedGetVar("VIEWCTR",&rb);
rb.restype=RTPOINT;
cenPt.x=rb.resval.rpoint[0];
cenPt.y=rb.resval.rpoint[1];
acedGetVar("VIEWSIZE",&rb);
rb.restype=RTREAL;
douHeight=rb.resval.rreal/2;
acedGetVar("SCREENSIZE",&rb);
rb.restype=RTPOINT;
douWidth=douHeight*rb.resval.rpoint[0]/rb.resval.rpoint[1];
winPt1.x=cenPt.x-douWidth;
winPt1.y=cenPt.y-douHeight;
winPt2.x=cenPt.x+douWidth;
winPt2.y=cenPt.y+douHeight;
GetCursorPos(&CurPt);
ScreenToClient(acedGetAcadDwgView()->m_hWnd,&CurPt);
mousPt.x=cenPt.x-douWidth;
mousPt.y=cenPt.y+douHeight;
mousPt.x=mousPt.x+MyGeFun->SdToCd(CurPt.x);//客户量向屏幕量转化的函数,你搜索一下,我在论坛上发表过的
mousPt.y=mousPt.y-MyGeFun->SdToCd(CurPt.y);
if(mousPt.x>winPt1.x && mousPt.x<winPt2.x &&
mousPt.y>winPt1.y && mousPt.y<winPt2.y)
mRet=true;
else
mRet=false;
ResultNo=0;
switch(WantToNo)
{
case 0://分析是否在绘图区域
break;
case 1://分析用户是否有关闭的企图
if(!mRet && mousPt.y>winPt2.y && mousPt.x>winPt2.x-douWidth/2) ResultNo=1;
break;
case 2://分析是否在工具条上
break;
default:
break;
}
return mRet;
} |
|