Graphics32:通过鼠标拖动进行平移,通过鼠标滚轮缩放到鼠标光标
我需要在单击并拖动鼠标时实现平移,并朝向/远离使用鼠标滚轮的鼠标光标进行缩放/取消缩放。 (在 Delphi 2010 中,图像固定在窗体的左、右、上、下。)
我刚刚安装了 Graphics32,并了解了它的内置滚动条和 .Scale 如何实现其中的一些功能。至少能走到这一步是非常容易的。
问题:
Graphics32 是处理此类事情的好工具吗?我还可以研究其他(也许更简单吗?)工具吗?
有谁有关于如何实现上述内容的任何指示或示例代码?
谢谢。
I need to implement a pan as I click and drag the mouse, and zoom/unzoom towards/away from the mouse cursor that uses the mouse wheel. (In Delphi 2010, with the image anchored to left,right,top,bottom the form.)
I've just installed Graphics32 and seen how its built-in scroll bars and .Scale allow some of this. It's tantalizingly easy to at least get that far.
Questions:
Is Graphics32 a good tool for this kind of thing? Are there other (perhaps more simple?) tools that I might look into?
Does anyone have any pointers or sample code on how to implement the above?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Graphics32提供了一个名为TImgView32的组件,可以通过设置Scale属性来缩放。执行此操作的适当方法是使用 OnMouseWheelUp 和 -Down 事件。将 TabStop 设置为 True 以触发这些事件,并将 Centered 设置为 False。但这种方式的缩放并不符合您将缩放操作集中在鼠标光标处的愿望。因此,围绕该点重新定位和调整大小是一个更好的解决方案。此外,据我了解,图像始终与组件的左上角对齐,因此还必须通过重新定位组件来完成平移。
编辑:使用 TImage 而不是 TImgView32 的替代方案:
Graphics32 provides a component named TImgView32 which can zoom by setting the Scale property. The appropriate way to do so is by using the OnMouseWheelUp and -Down events. Set TabStop to True for triggering these events and set Centered to False. But scaling in this manner does not comply with your wish to center the zooming operation at the mouse cursor. So repositioning and resizing around that point is a nicer solution. Further, as I understand, the image is always aligned in the top-left corner of the component, so panning must also be accomplished by repositioning the component.
Edit: Alternative with TImage instead of TImgView32: