This project is read-only.

Mouse functionality sharpGL

May 2, 2012 at 11:09 PM

I am working with Example 5 in the Sharp GL package.

I like being able to move the image around with the mouse. But I would like to have the sceneControl1 form detect a mouse click event and do something...display a message box would be fine

Below is an example of the code I could see demonstrating this functionality.

         private void OnMouseClick(MouseEventArgs e)

         void my_mouseclick(MouseEventArgs e)
             int x = SceneControl.MousePosition.X;
             int y = SceneControl.MousePosition.Y;             

            MessageBox.Show("Mouse Click Event:" + y.ToString() + " " + x.ToString());


This code works well on the form that the sceneControl1 is embedded on but it does not work on the control itself. 

Any help is appreciated.



May 3, 2012 at 4:19 PM

I figured this one out. This site has some good info for beginning mouse event-ers like myself:


And then rather than doing this:

this.MouseDown += new System.WinForms.MouseEventHandler(this.Form_MouseDown);

I did this:

            this.sceneControl1.MouseClick += new System.Windows.Forms.MouseEventHandler(sceneControl1_MouseClick);


Which then added all of the auto-generated code necessary to handle the event.