locked
Make regions clickable in a picturebox RRS feed

  • Question

  • Hi,

    How can I make regions clickable in a picturebox?... I've tried it already with a transparent button, but the result didn't look very well,... is there another way to do this ?...

    Greets, Gert-Jan

    Tuesday, February 15, 2011 1:47 PM

Answers

  • A Region contains an IsVisible method that checks for a point being contained within the region, like this.. (Remember! The region has to be initialized) This example uses a WinForm.Region as a very basic example. The Rectangle class also provides like methods.

      private void Form1_MouseDown(object sender, MouseEventArgs e)
      {
       if (this.Region.IsVisible(e.Location))
        MessageBox.Show("CLICK");
      }
    
    • Proposed as answer by Rudedog2Moderator Wednesday, February 16, 2011 12:13 AM
    • Marked as answer by Mio_Miao Monday, February 21, 2011 3:34 AM
    Tuesday, February 15, 2011 6:42 PM

All replies

  • You'd have to handle mouse down, get the mouse position and manually figure out if it's within a specific region.
    http://blog.voidnish.com
    Tuesday, February 15, 2011 2:08 PM
    Moderator
  • A Region contains an IsVisible method that checks for a point being contained within the region, like this.. (Remember! The region has to be initialized) This example uses a WinForm.Region as a very basic example. The Rectangle class also provides like methods.

      private void Form1_MouseDown(object sender, MouseEventArgs e)
      {
       if (this.Region.IsVisible(e.Location))
        MessageBox.Show("CLICK");
      }
    
    • Proposed as answer by Rudedog2Moderator Wednesday, February 16, 2011 12:13 AM
    • Marked as answer by Mio_Miao Monday, February 21, 2011 3:34 AM
    Tuesday, February 15, 2011 6:42 PM