Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Scrolling - Co-ordinates problem

Scrolling - Co-ordinates problem

Scheduled Pinned Locked Moved C#
testingbeta-testinghelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Griffin
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • P 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

      P Offline
      P Offline
      Philip Fitzsimons
      wrote on last edited by
      #2

      my first thought is rememeber that Rects are structs... so bob.rect = new Rectangle(1,2,3,4); is fine, but bob.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."

      P 1 Reply Last reply
      0
      • P Philip Fitzsimons

        my first thought is rememeber that Rects are structs... so bob.rect = new Rectangle(1,2,3,4); is fine, but bob.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."

        P Offline
        P Offline
        Paul Griffin
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • P 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

          P Offline
          P Offline
          Philip Fitzsimons
          wrote on last edited by
          #4

          Events are: ValueChanged Scroll


          "When the only tool you have is a hammer, a sore thumb you will have."

          P 1 Reply Last reply
          0
          • P Philip Fitzsimons

            Events are: ValueChanged Scroll


            "When the only tool you have is a hammer, a sore thumb you will have."

            P Offline
            P Offline
            Paul Griffin
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups