Mouse Handler : Mouse Event « Event « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Event » Mouse EventScreenshots 
Mouse Handler
Mouse Handler

/*
GDI+ Programming in C# and VB .NET
by Nick Symmonds

Publisher: Apress
ISBN: 159059035X
*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace MouseHandler_c
{
    /// <summary>
    /// Summary description for Finally_c.
    /// </summary>
    public class MouseHandler_c : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button Off;
        private System.Windows.Forms.Button On;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public MouseHandler_c()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            this.MouseMove += new 
                     System.Windows.Forms.MouseEventHandler(this.MyMouseHandler);

        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing ) {
            ifdisposing )
            {
                if (components != null
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
              this.label1 = new System.Windows.Forms.Label();
              this.Off = new System.Windows.Forms.Button();
              this.On = new System.Windows.Forms.Button();
              this.SuspendLayout();
              // 
              // label1
              // 
              this.label1.Location = new System.Drawing.Point(4056);
              this.label1.Name = "label1";
              this.label1.Size = new System.Drawing.Size(17616);
              this.label1.TabIndex = 0;
              this.label1.Text = "label1";
              // 
              // Off
              // 
              this.Off.Location = new System.Drawing.Point(40216);
              this.Off.Name = "Off";
              this.Off.Size = new System.Drawing.Size(7224);
              this.Off.TabIndex = 1;
              this.Off.Text = "Off";
              this.Off.Click += new System.EventHandler(this.Off_Click);
              // 
              // On
              // 
              this.On.Location = new System.Drawing.Point(152216);
              this.On.Name = "On";
              this.On.Size = new System.Drawing.Size(7224);
              this.On.TabIndex = 2;
              this.On.Text = "On";
              this.On.Click += new System.EventHandler(this.On_Click);
              // 
              // MouseHandler_c
              // 
              this.AutoScaleBaseSize = new System.Drawing.Size(513);
              this.ClientSize = new System.Drawing.Size(292273);
              this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.On,
                                                                          this.Off,
                                                                          this.label1});
              this.Name = "MouseHandler_c";
              this.Text = "MouseHandler_c";
              this.Load += new System.EventHandler(this.MouseHandler_c_Load);
              this.ResumeLayout(false);

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new MouseHandler_c());
        }

        private void MouseHandler_c_Load(object sender, System.EventArgs e)
        {
        }
        private void MyMouseHandler(object sender, 
                                    System.Windows.Forms.MouseEventArgs e)
        {
          label1.Text = "X= " + e.X.ToString() ", Y= " + e.Y.ToString();
        }
    
        protected override void OnMouseMoveMouseEventArgs e )
        {
          base.OnMouseMove(e);
        }
    
        private void Off_Click(object sender, System.EventArgs e)
        {
          this.MouseMove -= new 
            System.Windows.Forms.MouseEventHandler(this.MyMouseHandler);
        }
    
        private void On_Click(object sender, System.EventArgs e)
        {
          this.MouseMove += new 
            System.Windows.Forms.MouseEventHandler(this.MyMouseHandler);
        }

    }
}


           
       
Related examples in the same category
1.Which mouse button was clicked?
2.Mouse left click, right click, middle click, hoverMouse left click, right click, middle click, hover
3.Register Form Mouse Move, down and up actionRegister Form Mouse Move, down and up action
4.Block Mouse
5.Mouse Enter actionMouse Enter action
6.Mouse Exit actionMouse Exit action
7.Mouse click actionMouse click action
8.Mouse Hover actionMouse Hover action
9.Mouse Down actionMouse Down action
10.Mouse up actionMouse up action
11.Mouse Double Click eventMouse Double Click event
12.Handle Mouse click event on an ImageHandle Mouse click event on an Image
13.Catch Mouse Click event inside a strange shapeCatch Mouse Click event inside a strange shape
14.Mouse MovementMouse Movement
15.Mouse Buttons ClickMouse Buttons Click
16.Mouse moveMouse move
17.Full screen and KeyEvent and MouseEvent
18.Hit TestingHit Testing
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.