简体   繁体   English

用鼠标在图片框内移动图片

[英]Move around picture inside picturebox with the mouse

I want to be able to drag around a 100% zoomed picture in a picturebox: http://spunit.tk/x/dragpic1.png . 我希望能够在图片框中拖动100%缩放的图片: http ://spunit.tk/x/dragpic1.png。

I want it to work exactly like the Windows Photo Viewer: http://spunit.tk/x/dragpic2.png . 我希望它的工作方式与Windows Photo Viewer完全相同: http : //spunit.tk/x/dragpic2.png

How is this possible? 这怎么可能?

I believe you need to maintain the coordinates of that picturebox, also set its view style to full-image, without any stretching. 我相信您需要保持该图片框的坐标,并将其视图样式设置为全图,而无需任何拉伸。

Then, you will need three mouse events: mouse down, mouse up and mouse move, where you can get the mouse coordinates and capture or release mouse to translate the picture box according to mouse delta translation. 然后,您将需要三个鼠标事件:鼠标向下,鼠标向上和鼠标移动,您可以在其中获取鼠标坐标并捕获或释放鼠标以根据鼠标Delta转换来翻译图片框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM