Page 1 of 1
Position of the cursor
Posted: Wed Mar 27, 2013 9:52 am
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
Re: Position of the cursor
Posted: Wed Mar 27, 2013 12:09 pm
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
Re: Position of the cursor
Posted: Thu Mar 28, 2013 12:30 pm
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
Re: Position of the cursor
Posted: Thu Mar 28, 2013 12:42 pm
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.
Re: Position of the cursor
Posted: Thu Mar 28, 2013 1:31 pm
by Edmund
Sorry Jwphilippi, I didn´t mean try to fool you
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
Re: Position of the cursor
Posted: Thu Mar 28, 2013 2:16 pm
by Jwphilippi
Thank you Mark and Thank you Edmund. I am astounded by ya'lls awesomeness when it comes to programming these HMIs.