简体   繁体   中英

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.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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