Sunday, 1 May 2011

Draw Text On Mouse Move In Win Forms:-



Draw Text On Mouse Move In Win Forms:-




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        int i, j;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            Graphics g;
            g = this.CreateGraphics();
            Font f = new Font("Arial", 15);

            Pen p = new Pen(new SolidBrush(Color.Red),1);
           
            if (i % 3 == 0)
            {
                g.DrawString("Rajesh", f, new SolidBrush(Color.Purple), new RectangleF(new Point(e.X, e.Y), new SizeF(100, 110)));
            }
           
            i = i + 1;

            this.Text = "Mouse Position :-" + e.X + "," + e.Y;

            f.Dispose();
            g.Dispose();
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {

        }
    }
}

No comments:

Post a Comment