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. Visual Basic
  4. mouse over graphical objects event?

mouse over graphical objects event?

Scheduled Pinned Locked Moved Visual Basic
question
3 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.
  • B Offline
    B Offline
    Boniolopez
    wrote on last edited by
    #1

    Hi all, I draw a rectangle. Now I want, that rectangle changes the color, when mouse over it. I want to have an event when mouse is over rectangle, and NOT track all mouse moves. Is it possible? I just can't find a good way to do it? Thanks a lot, Boni

    N 1 Reply Last reply
    0
    • B Boniolopez

      Hi all, I draw a rectangle. Now I want, that rectangle changes the color, when mouse over it. I want to have an event when mouse is over rectangle, and NOT track all mouse moves. Is it possible? I just can't find a good way to do it? Thanks a lot, Boni

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Sure, but you will have to track the mouse movement, if you think about it, if you didn't track the mouse movement it wouldn't be very effective. Assuming your class has a Rectangle object (i.e., rect in the example), within your MouseMove eventhandler you could say:

      If rect.Contains(Cursor.Position) Then
      'change your color here, you are inside the rectangle
      End If

      - Nick Parker
      My Blog | My Articles

      B 1 Reply Last reply
      0
      • N Nick Parker

        Sure, but you will have to track the mouse movement, if you think about it, if you didn't track the mouse movement it wouldn't be very effective. Assuming your class has a Rectangle object (i.e., rect in the example), within your MouseMove eventhandler you could say:

        If rect.Contains(Cursor.Position) Then
        'change your color here, you are inside the rectangle
        End If

        - Nick Parker
        My Blog | My Articles

        B Offline
        B Offline
        Boniolopez
        wrote on last edited by
        #3

        Hi Nick, thank you so much for the answer. But can't windows notify me with an event, when the mouse is over my rectangle? (I could imagine to register the rectangles "contain"-method somewhere(?)) I fear, that if track mouse for all of my 1000 objects (not only rectangles but even more complicated figures) for each move this will slow down the PC very much. Thanks for your time, boni

        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