- UID
- 1
- 积分
- 15891
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
发表于 2002-3-8 03:38:56
|
显示全部楼层
Re: [求助]:请教xd:关于ToolTip?
最初由 梦宁 发布
[B]上次从论坛上下载的是关于控件上的ToopTip,但是怎样当鼠标在绘图区移动时鼠标有ToolTip,就象在绘制一条直线时,当拖动直线的一点时会有ToolTip显示相关属性,我需要鼠标移动时就有这种效果,我想在您的代码上改,?.. [/B]
下面资料是选中实体后,弹出TAG,标出实体的属性,可以定制自己的别ACAD LIST命令更方面的功能了。
梦宁你参照下,ARX的SAMPLE目录下,也有这类方面的代码。
How to display a tooltip for an Acad entity (AcDbEntity)?
ID 17816
Applies to: AutoCAD 2000I
AutoCAD 2002
AutoCAD 2000
This document is part of ObjectARX MFC User Interface
Question
Most of the MFC toolbar buttons have associated tooltips that indicate what the
buttons are. Can I have tooltips for AutoCAD entities?
Answer
Yes. You can display the tooltip by using either using the CToolTipCtrl class provided by
MFC or the more simple *newer* method is to use the AcEdInputPointMonitor class.
CToolTipCtrl Method:
For displaying the entity type of an AutoCAD entity, for example, the same
class can be used in almost the same fashion.
The first task is to get the current mouse cursor position and translate that
into the AutoCAD WCS. This is handled by installing a mouse message hook,
acedRegisterFilterWinMsg() and using acedCoordFromPixelToWorld().
The second task is to select an entity under this translated mouse cursor
position and extract the entity information via its data structure. Because only
ads_nentselp() and ads_ssget() are suitable for the case, the task is handled by
traversing through the struct resbuf (a singly linked list).
The third task is to keep the content of the tooltip updated while the user
moves the mouse cursor from one entity to the other. There is also a timer that
needs to be set at 300 ms to display the tooltip within an appropriate period of
time.
The last task is to exclude the conflict between the tooltip display and the
AutoCAD command activities. Do this by planting an AcEdReactor so that there is
no tooltip displayed while a specific command activity is in action.
See the attached workspace and the project AutoTag.
AcEdInputPointMonitor
Using the ObjectARX Wizard Visual Studio plugin, create a new ObjectARX application.
Using the ObjectARX Wizard Visual Studio plugin toolbar, pick the Input Point
API Support button and create a new Input point monitor.
In the InitApplication() function, create a new instance of your newly created
Input Monitor.
Now edit the newly created Input Point Monitor class and add this code in the
monitorInput () - that's it!!
- // get the number of entities we've got
- int length = apertureEntities.length();
- // Check mouse aperture over some entity
- if (length)
- {
- // open the entity for read
- AcDbObjectPointer<AcDbEntity>ent (apertureEntities[0], AcDb::kForRead);
- // if opened ok
- if (ent.openStatus () == Acad::eOk)
- {
- // create a static string to return our string in
- static char toolTip[133];
- // now create our tooltip display value
- strcpy (toolTip, ent->isA ()->name ());
- // now tell autocad we have a tooltip for him
- appendToTooltipStr = true;
- // now set the tool tip string pointer
- additionalTooltipString = toolTip;
- }
- }
- return Acad::eOk;
复制代码 |
|