Scrolling - Co-ordinates problem
-
Hey all i've got a small app that creates several Rectangle objects as part of its constructor code. These are then used later as bounding rectangles for hit testing of lines. This works very well for my needs ... the problem is when i scroll vertically the rectangles no londer bound the correct area!! i've tried creating a seperate function(which i called in my paint handler) which re-initialises the Rects to the original co-ords plus AutoScrollPosition.X and Y. .... this doesn't seem to have any effect though!!! i guess i'm calling the function from the wrong place but is there an event that's triggered by scrolling as in OnScroll for ex. If anyone has any ideas i'd love to hear them thanks Paul Paul Griffin
-
Hey all i've got a small app that creates several Rectangle objects as part of its constructor code. These are then used later as bounding rectangles for hit testing of lines. This works very well for my needs ... the problem is when i scroll vertically the rectangles no londer bound the correct area!! i've tried creating a seperate function(which i called in my paint handler) which re-initialises the Rects to the original co-ords plus AutoScrollPosition.X and Y. .... this doesn't seem to have any effect though!!! i guess i'm calling the function from the wrong place but is there an event that's triggered by scrolling as in OnScroll for ex. If anyone has any ideas i'd love to hear them thanks Paul Paul Griffin
my first thought is rememeber that Rects are structs... so
bob.rect = new Rectangle(1,2,3,4);
is fine, butbob.rect.x = 1;
will not work... as Rectangles are stuctures they are copy by value.
"When the only tool you have is a hammer, a sore thumb you will have."
-
my first thought is rememeber that Rects are structs... so
bob.rect = new Rectangle(1,2,3,4);
is fine, butbob.rect.x = 1;
will not work... as Rectangles are stuctures they are copy by value.
"When the only tool you have is a hammer, a sore thumb you will have."
Ya your right but i don't actually attempt anything like that luckily what i try to do is add the scroll position offsets to the Rect dimensions by creating entirely new rects but of the same name. the trouble is when to do this ... that's why i was hoping there might be some event triggered by the scrolling Paul Griffin
-
Ya your right but i don't actually attempt anything like that luckily what i try to do is add the scroll position offsets to the Rect dimensions by creating entirely new rects but of the same name. the trouble is when to do this ... that's why i was hoping there might be some event triggered by the scrolling Paul Griffin
Events are:
ValueChanged Scroll
"When the only tool you have is a hammer, a sore thumb you will have."
-
Events are:
ValueChanged Scroll
"When the only tool you have is a hammer, a sore thumb you will have."
Thanks Philip believe or not though i've just managed to get around it by trying something a little different.... instead of trying to re create the Rects after the scroll i just modified the mouse click point by subtracting the scroll offset .. that way i don't have to touch the Rects... but thanks for that info .. i'm sure i'll need it further down the road at some stage Cheers Paul Paul Griffin