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. Middle mouse click and scroll

Middle mouse click and scroll

Scheduled Pinned Locked Moved C#
5 Posts 3 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.
  • G Offline
    G Offline
    gwithey
    wrote on last edited by
    #1

    I am experiencing difficulty trying to make a trackbar scroll when the middle mouse button/ball is clicked and scrolled. I need the mouse scroll wheel to scroll up and down when it is clicked and reset the value to the middle when realised. Does anyone know how this can be done. Thanx George

    G 1 Reply Last reply
    0
    • G gwithey

      I am experiencing difficulty trying to make a trackbar scroll when the middle mouse button/ball is clicked and scrolled. I need the mouse scroll wheel to scroll up and down when it is clicked and reset the value to the middle when realised. Does anyone know how this can be done. Thanx George

      G Offline
      G Offline
      gwithey
      wrote on last edited by
      #2

      I have tried this: private void trackBar1_Scroll_1(object sender, MouseEventArgs m) { if (m.Button == MouseButtons.Middle) { label1.Text = trackBar1.Value.ToString(); } } but dont know if it will work as havent got it to compile because its complaining about the delegate this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll_1); I dont know how to change it, it works with eventArgs but i put in mouseEventArgs which i need and it does not like it.

      L 1 Reply Last reply
      0
      • G gwithey

        I have tried this: private void trackBar1_Scroll_1(object sender, MouseEventArgs m) { if (m.Button == MouseButtons.Middle) { label1.Text = trackBar1.Value.ToString(); } } but dont know if it will work as havent got it to compile because its complaining about the delegate this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll_1); I dont know how to change it, it works with eventArgs but i put in mouseEventArgs which i need and it does not like it.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, you can't just change the partameter types; Scroll gives an EventArgs, not a MouseEventArgs. you are aware of the Control.MouseWheel event? That one offers a MouseEventArgs. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        B G 2 Replies Last reply
        0
        • L Luc Pattyn

          Hi, you can't just change the partameter types; Scroll gives an EventArgs, not a MouseEventArgs. you are aware of the Control.MouseWheel event? That one offers a MouseEventArgs. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


          B Offline
          B Offline
          Baeltazor
          wrote on last edited by
          #4

          Thanks for that. You just answered my question too! lol :laugh: :thumbsup: 2 answers in 1!

          Regards, Jason Pezzimenti.


          1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, you can't just change the partameter types; Scroll gives an EventArgs, not a MouseEventArgs. you are aware of the Control.MouseWheel event? That one offers a MouseEventArgs. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            G Offline
            G Offline
            gwithey
            wrote on last edited by
            #5

            Thank you that was a silly thing to do. This is the first time i have worked with events so will probably make a few mistakes along the way.

            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