Processing the mouse PDF Print E-mail

Mouse events can be processed simply by overriding the OnMouseDown method of the Control class.

  1.  
  2. using System;
  3. using System.Windows.Forms;
  4. class MouseSample : Form {
  5. public static void Main() {
  6. Application.Run( new MouseSample() );
  7. }
  8. protected override void OnMouseDown( MouseEventArgs e ) {
  9. MessageBox.Show( "X:" + e.X.ToString() + " Y:" + e.Y.ToString() );
  10. }
  11. }
 

The method OnMouseDown of the Control class expects a MouseEventArgs as argument. An object of the type MouseEventArgs has two properties X and Y for the corresponding coordinates. We use these to display the location of a mouse click.




Bookmark it...
Digg!Reddit!Del.icio.us!Google!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!
 
< Prev   Next >
Joomla Template by Joomlashack
Joomla Templates by JoomlaShack Joomla Templates by Compass Design