المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Check Mistake [modified]



C# Programming
05-22-2009, 11:00 AM
Hi,

i am trying to get cursor position clicking anywhere except my application. I used keydown event on my form for checking, it works. But when i click anywhere it does'nt workhttp://www.barakasoft.com/script/Forums/Images/smiley_frown.gif
please check my code and tell me where am I doing mistak?

Thank you in Advance
(Riaz)



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

namespace MM1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Click += new System.EventHandler(Raised_Click);
}

private void Raised_Click(object sender, EventArgs e)
{
label1.Text = Cursor.Position.X.ToString() + " ; " + Cursor.Position.Y.ToString();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
label1.Text = Cursor.Position.X.ToString() + " ; " + Cursor.Position.Y.ToString();
}
}
}
}




modified on Friday, May 22, 2009 2:27 AM