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. Mouse Coordinates of a bitmap form in the main window

Mouse Coordinates of a bitmap form in the main window

Scheduled Pinned Locked Moved C#
graphics
6 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.
  • S Offline
    S Offline
    sebogawa
    wrote on last edited by
    #1

    I have the mouse event handler function that takes the mouse x and y coordinates and converts that integer to a string and is sent to two text boxes, one for each axis. I am trying the get the x and y coordinates of the mouse when it is on any part of a live video stream bitmap. It is for a color tracking app, ill eventually get the color ARGB values of the pixel the mouse is over and save it to the color filter value chart. I digress, all i need to know is where do i have to place my function: protected override void OnMouseMove(MouseEventArgs mouseEv) { txtMouseX.Text = mouseEv.X.ToString(); txtMouseY.Text = mouseEv.Y.ToString(); } so that i get the coordinates of the bitmap, not the application window.

    modified on Friday, April 17, 2009 10:06 AM

    H 1 Reply Last reply
    0
    • S sebogawa

      I have the mouse event handler function that takes the mouse x and y coordinates and converts that integer to a string and is sent to two text boxes, one for each axis. I am trying the get the x and y coordinates of the mouse when it is on any part of a live video stream bitmap. It is for a color tracking app, ill eventually get the color ARGB values of the pixel the mouse is over and save it to the color filter value chart. I digress, all i need to know is where do i have to place my function: protected override void OnMouseMove(MouseEventArgs mouseEv) { txtMouseX.Text = mouseEv.X.ToString(); txtMouseY.Text = mouseEv.Y.ToString(); } so that i get the coordinates of the bitmap, not the application window.

      modified on Friday, April 17, 2009 10:06 AM

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      If you put the Bitmap on the window, you should know its coordinates. Keep your code where it is but put a test before your existing code to see if the mouse is in the rectangle for the image. If not in the rectangle, return. Then just add offsets to your two lines for the X and Y coordinates of the image.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      S 1 Reply Last reply
      0
      • H Henry Minute

        If you put the Bitmap on the window, you should know its coordinates. Keep your code where it is but put a test before your existing code to see if the mouse is in the rectangle for the image. If not in the rectangle, return. Then just add offsets to your two lines for the X and Y coordinates of the image.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        S Offline
        S Offline
        sebogawa
        wrote on last edited by
        #3

        The issue is that I stop receiving coordinates when the mouse enters the bitmap rectangle due to the fact that it is part of a form group. How do i get rid of the border that separates the bitmap and text boxes from the rest of the application window.

        H 1 Reply Last reply
        0
        • S sebogawa

          The issue is that I stop receiving coordinates when the mouse enters the bitmap rectangle due to the fact that it is part of a form group. How do i get rid of the border that separates the bitmap and text boxes from the rest of the application window.

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          sebogawa wrote:

          due to the fact that it is part of a form group

          I do not understand. What, exactly, is a form group? Do you mean that the image is on one form, and the TextBoxes are on another? If not, then please clarify.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          S 1 Reply Last reply
          0
          • H Henry Minute

            sebogawa wrote:

            due to the fact that it is part of a form group

            I do not understand. What, exactly, is a form group? Do you mean that the image is on one form, and the TextBoxes are on another? If not, then please clarify.

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            S Offline
            S Offline
            sebogawa
            wrote on last edited by
            #5

            Ill try my best to explain. So imagine a simple form window. It has a black rectangle, thats the video feed bitmap thing, then it has two text boxes. The bitmap rectangle and the text boxes are surrounded by a border that groups then under a specific title. I got the color filtering code from the "Lego Pan and Tilt with color tracking" app posted on this site. The mouse coordinates only change value in the textboxes when the mouse is outside the group border, but still inside the main window. If u look up the Lego app u will see what i am talking about in the images posted with that article. Everthing in the picture is the same except for two text oxes under the bitmap rectangle. Thanks for healping : )

            H 1 Reply Last reply
            0
            • S sebogawa

              Ill try my best to explain. So imagine a simple form window. It has a black rectangle, thats the video feed bitmap thing, then it has two text boxes. The bitmap rectangle and the text boxes are surrounded by a border that groups then under a specific title. I got the color filtering code from the "Lego Pan and Tilt with color tracking" app posted on this site. The mouse coordinates only change value in the textboxes when the mouse is outside the group border, but still inside the main window. If u look up the Lego app u will see what i am talking about in the images posted with that article. Everthing in the picture is the same except for two text oxes under the bitmap rectangle. Thanks for healping : )

              H Offline
              H Offline
              Henry Minute
              wrote on last edited by
              #6

              sebogawa wrote:

              thats the video feed bitmap thing

              And is the 'bitmap thing' actually a control? If it is, then in the designer, select it, in the Properties Window, switch to Events page and double click on the MouseMove event. Put your code in the handler stub created in the code view for the form, should work OK, no need for offsets etc..

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              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