开发者

screen coordinates with a horizontal scroll bar

开发者 https://www.devze.com 2023-01-07 15:45 出处:网络
I need to place i开发者_如何转开发cons on a map image. Since the map image is bigger than my screen resolution 1280 x 1024, a horizontal scroll bar is shown.

I need to place i开发者_如何转开发cons on a map image. Since the map image is bigger than my screen resolution 1280 x 1024, a horizontal scroll bar is shown.

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...

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).

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. Then your container Control could use code like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号