locked
Getting cursor position in WM 6.x. RRS feed

  • Question

  • Hello! I want to use stylus as pen in my app, but i don't understand how to get cursor position. I used code from library, but it doesn't works

            private void MoveCursor()
            {
                // If the form's cursor is not the Default cursor,
                // set the Current cursor, move the cursor's Position,
                // and set its clipping rectangle to the form.
                if (!this.Cursor.Equals(Cursors.Default))
                {
                    this.Cursor = new Cursor(Cursor.Current.Handle);
                    Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);
                    Cursor.Clip = new Rectangle(this.Location, this.Size);
                }

    Help plese. Also, give me some ideas how to make drawing with stylus like in default notes app in WM. :)

    Wednesday, April 13, 2011 10:22 PM

Answers

  • Hi,

    You can try this code:

    public partial class Form1 : Form
      {
        public Form1()
        {
          InitializeComponent();
        }
    
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
         label1.Text = e.X.ToString() + "; " + e.Y.ToString();
        }
    
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
          label1.Text = e.X.ToString() + "; " + e.Y.ToString();
        }
    
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
          label1.Text = e.X.ToString() + "; " + e.Y.ToString();
        }
      }

     

    Also have a look on this sample:

    http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=7261

     

    Regards,

    Malleswar

    • Marked as answer by Jesse Jiang Thursday, April 21, 2011 9:34 AM
    Thursday, April 14, 2011 4:07 AM