简体   繁体   English

屏幕坐标与水平滚动条

[英]screen coordinates with a horizontal scroll bar

I need to place icons on a map image. 我需要在地图图像上放置图标。 Since the map image is bigger than my screen resolution 1280 x 1024, a horizontal scroll bar is shown. 由于地图图像大于我的屏幕分辨率1280 x 1024,因此将显示水平滚动条。

I use Location x and y to place icons, but the problem is: placing an icon at location (0, 0) when the horizontal scroll bar is at left-most position is different from when the horizontal scroll bar is at right-most position... 我使用位置x和y放置图标,但是问题是:当水平滚动条位于最左侧位置时,将图标放置在位置(0,0)不同于水平滚动条位于最右侧位置时...

If I move scroll bar to x-axis(right) 10 then placing an icon at (0, 0), should be (0, 0) but it is placed at (10, 0). 如果将滚动条移动到x轴(右)10,则将图标放置在(0,0),应该是(0,0),但它放置在(10,0)。

in this case, is there any different approach? 在这种情况下,有什么不同的方法吗? or should I consider how much scroll bar has moved? 还是应该考虑滚动了多少滚动条? if so, how do I do it? 如果是这样,我该怎么办?

hope my explanation makes sense. 希望我的解释有意义。

Thanks, 谢谢,

Yes, it's sort of annoying. 是的,这很烦人。 If your container Control supports scrolling, then you have to account for its current position whenever you set the Location on a child Control. 如果您的容器控件支持滚动,则每当您在子控件上设置“位置”时,都必须考虑其当前位置。 Suppose you are using autoscroll and you want to put a child at x, y. 假设您正在使用自动滚动,并且想在x,y处放置一个孩子。 Then your container Control could use code like this: 然后,您的容器控件可以使用如下代码:

Point p = new Point(x, y);
p.Offset(AutoScrollPosition);
child.Location = p;

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

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