Position of the cursor

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
Joe
Posts: 27
Joined: Tue Sep 18, 2012 4:53 am

Position of the cursor

Post by Joe »

Hi,
is there any way to determine the current position of the cursor ("sometimes visible") on the screen; coordinates x, y?
-> T15B or RunTime ...

Thanks for reply

Joe

User avatar
Edmund
Posts: 92
Joined: Thu Nov 29, 2012 2:27 pm

Re: Position of the cursor

Post by Edmund »

Sure, it shouldnt be a problem...

I´m home right now so can´t try it on a panel but following should work.

If you want it in "Point" format

var cursorPos = System.Windows.Forms.Cursor.Position;

You can then access X/Y like this

int cursorPosX = cursorPos.X;

Or if you want X/Y as two INT:

var cursorPosX = System.Windows.Forms.Cursor.Position.X
var cursorPosY = System.Windows.Forms.Cursor.Position.Y

Best Regards
Edmund Andersson

AITECH AB

Part of Beijer Integrator Group

Jwphilippi
Posts: 13
Joined: Mon Mar 11, 2013 8:48 am

Re: Position of the cursor

Post by Jwphilippi »

I was trying out a form popup utilizing this cursor position example. Things work dandy through debugging and running the code on Visual Studio with the output CF. But I get the error in the image below when I try and simulate the code in iX Devloper even though the "intelligent code completion" picks up on it. Any thoughts?

Also in just trying to do a pop up form, my end device (QTerm A7) locks up and restarts within a couple of second. Even something as simple as a MessageBox.Show has the same result. Any Ideas?

Thanks in advance.
-Joey
Attachments
Error.jpg
Error.jpg (10.23 KiB) Viewed 11149 times
CodeSnippet.jpg
CodeSnippet.jpg (68.18 KiB) Viewed 11149 times

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Position of the cursor

Post by mark.monroe »

If you switch your target to a PC, I bet your error will go away. If it does, it means that the code complete is using the .NET libraries rather than the Windows CE .NET libraries.

I have found that the code complete often times does than. The .NET Compact framework most likely doesn't have the Position property.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

User avatar
Edmund
Posts: 92
Joined: Thu Nov 29, 2012 2:27 pm

Re: Position of the cursor

Post by Edmund »

Sorry Jwphilippi, I didn´t mean try to fool you :oops:

I was simulating in a T12C project (looks just lika a T15B in the IDE).

Try use this instead and see if it works

Code: Select all

var cursorPos = Control.MousePosition;
Text1.Text = "X = " + cursorPos.X + " / Y = " + cursorPos.Y;

Regards
Edmund Andersson

AITECH AB

Part of Beijer Integrator Group

Jwphilippi
Posts: 13
Joined: Mon Mar 11, 2013 8:48 am

Re: Position of the cursor

Post by Jwphilippi »

Thank you Mark and Thank you Edmund. I am astounded by ya'lls awesomeness when it comes to programming these HMIs.

Post Reply