Click here to Skip to main content
15,126,209 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I want to make GUI screen in and then find out the co-ordinates of any point on the GUI screen.

Can any one please help me?
Updated 15-Mar-11 23:41pm
OriginalGriff 15-Mar-11 11:52am
What exactly does this have to do with your subject line?
Vikrant3 15-Mar-11 12:01pm
I have to find out co-ordinates and then I have to send the co-Ordinates to microcontroller using RS232 serial communication
OriginalGriff 15-Mar-11 12:29pm
There! That wasn't so hard, was it? :laugh:
When you ask a question, ask the whole question - it helps us to answer.
Dalek Dave 16-Mar-11 4:42am
Edited for Grammar and Readability.

A way can be using Mouse.Move Event, you can find it in the events belongings to your main form,
it appears like this :

Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
    e.X = the x coordinate of mouse
    e.Y = the y coordinate of mouse
End Sub

for serial comm , take a look a this :

RS 232 serial programming using fluke and PC.[^]
Sergey Alexandrovich Kryukov 15-Mar-11 19:56pm
Needs a word about serial port, at least cite Griff's Answer to make a good Answer.
Vikrant3 17-Mar-11 10:50am
I don't know about fluke. I want to send the data (co-ordinates) to microcontroller port using serial communication. How to do it in
Piccadilly Yum Yum 17-Mar-11 10:58am
Sorry, youre right... use an ActiveX serial comm control, there's a lot, also free... then you use it like any other control, you place it in the form from controls window.. the you manage it by code, is quite simple..
Sergey Alexandrovich Kryukov 17-Mar-11 13:28pm
For the port operation, see Griff's answer, very first link. This is all you need.
Dalek Dave 16-Mar-11 4:42am
Good Call
Look at athe SerialPort[^] class - it will handle the communications, though you will have to work out how the uProcessor wants the data and format it appropriately.

To get the GUI position, try handling the MouseMove[^] event- the MouseEventArgs parameter will give you the mouse location.

However, I can't remember if MouseMove fires for a form when the mouse is over a control - it may fire at teh control instead. If so, then you will have to handle the control MouseMove event as well and may have to translate the coordinates from local to form based. Not difficult, but it may be necessary.
Vikrant3 15-Mar-11 14:15pm
thank you very much. I will try it and if any help required will post again.
OriginalGriff 16-Mar-11 4:12am
You are welcome- good luck!
Sergey Alexandrovich Kryukov 15-Mar-11 19:59pm
Good answer, my 5. To come "under" controls you can override one of the low-level Windows message processing methods (now I don't remember, easy to find out), good only for System.Windows.Forms.
Dalek Dave 16-Mar-11 4:42am
That earns a 5 for comprehensive answering.
Apart that the other answers are 100% correct (IMHO) I would add that if you are making yourself the touch interface then both answers are pointing you to the right direction.

But in the other hand, if you are trying to use a bought touch screen, usually those elements come with a driver and then the touch of the screen generates a normal mouse click message. then your job would be really easier so you would not have to think in the hardware part and then your app would work perfectly with a touch screen and with a mouse (who knows if you'll need that some day).

HTH! :jig:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900