delphi中如何用鼠标移动圆圈?
delphi中如何用鼠标移动圆圈?
circle:Shape;
How to move circle with mouse in delphi?
circle:Shape;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
delphi中如何用鼠标移动圆圈?
circle:Shape;
How to move circle with mouse in delphi?
circle:Shape;
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
请务必使用
ClientToScreen
和ScreenToClient
将从 Control 上的 MouseMove 获取的鼠标 X、Y 客户端坐标转换为父级客户端。以下过程将 Control 的中心移动到其客户端坐标中的点 (X,Y):
现在,要在单击 TShape 时移动 TShape,您必须提供以下 MouseMove 事件处理程序:
要测试它,请放置一个使用以下代码在表单中添加按钮:
现在,这是一个极简示例,但它应该可以帮助您入门。
为了好玩,只需使用此 MouseMove 事件处理程序挂钩其他控件...:-)
Be sure to convert the Mouse X,Y client coordinates that you get from MouseMove on your Control to the Parent's client using
ClientToScreen
andScreenToClient
.The following procedure moves the center of a Control to the point (X,Y) in it's client coordinates:
Now to move your TShape when when it is clicked, you have to provide the following MouseMove event handler:
And to test it, drop a button in your Form with this code:
Now, that's a minimalist example, but it should get you started.
For fun, just hook other controls with this MouseMove event handler... :-)
如果您访问我的网页,您可以找到一些示例(全部包含代码),它们可以帮助您解决这个问题。
“带有图形和平面图的视觉作品示例”;使用两个组件来直观地管理、移动、调整大小和保存元素;一种用于选择、移动、调整大小……(TSeleccOnRuntime),另一种(TSaveComps)用于保存状态(位置、大小……)。
替代文本 http://neftali-mirror.site11.com/images/imagen_ej_restaurante.png
直观地选择形状;用于解释选择视觉形状和图像的两种模式的示例。
在运行时(如 IDE)上创建、移动和响应控件; TSeleccOnRuntime 组件的另一个示例。模拟和IDE。
替代文本 http://neftali-mirror.site11.com/images/image_ej_form_designer.png
最后是另一个在运行时创建/销毁组件并用鼠标移动示例;该样品是在没有任何组件的情况下制作的。示例中的所有代码。
替代文字 http://neftali-mirror.site11.com/images/imagen_ej_mover_mouse.png
我希望对你有用。
问候
PD:请原谅我的英语不好。
If you go to my webpage, you can Find some samples (all with code included) thah can help you about this question.
"Sample for visual work with figures and plans"; Use two components for manage, move, resize and save elements visually; One for selection, movement, resize,... (TSeleccOnRuntime) and other (TSaveComps) for save the state (position, size,...).
alt text http://neftali-mirror.site11.com/images/imagen_ej_restaurante.png
Select Shapes Visually; Sample for explain two modes for select visually shapes and images.
Create, move and resive controls on Runtime (like IDE); Another sample of TSeleccOnRuntime component. Simulate and IDE.
alt text http://neftali-mirror.site11.com/images/image_ej_form_designer.png
And finally another sample for Create/destroy components in runtime and move with mouse; This sample is made without components. All code at the sample.
alt text http://neftali-mirror.site11.com/images/imagen_ej_mover_mouse.png
I hope that is usefull for you.
Regards
P.D: Excuse for my bad english.
好吧,我没有太多可说的,但是让某些东西移动来跟随鼠标通常是这样工作的:
在某处有一个“IsFollowingMouse”标志。当您应该跟随鼠标时将其打开。
在窗体的 MouseMove 事件上,执行如下操作:
偏移量是您使用的变量,用于给出鼠标指针位置与 TShape 左上角位置之间的差异。
Well, I don't have too much to go on, but having something move to follow the mouse generally works like this:
Have a "IsFollowingMouse" flag somewhere. Turn it on when you should be following the mouse.
On the form's MouseMove event, do something like this:
The offsets are variables you use that gives the difference between the location of the mouse pointer and the top-left corner of the TShape.