LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting screen coordinates to LabVIEW pane coordinates

Solved!
Go to solution

Hello all.

 

I have a .NET callback that is returning screen percentages which I would like to convert into LabVIEW panel coordinates.  The goal is to have an indicator move to the proper coordinates in the LV panel when the .NET event fires.  All of the event handling is taken care of, but I'm having trouble with the math converting the screen percentage into an exact position on a LV pane.

 

The first thing I've done is to multiply the percentage by the resolution of the screen, but I'm stuck on how to take that screen pixel data and figure out where that is relative to LV's pane.

 

I'm sorry if this hasn't been the clearest post, I'll try and clarify any questions if I can.  Thank you so much for your support.

0 Kudos
Message 1 of 16
(5,604 Views)

You can convert screen coordinates to panel coordinates (that's a VI method), these panel coordinates can be converted into pane coordinates (that's a Pane method).

 

No extra math needed.

 

i don't have LabVIEW running right now, but maybe someone can post a snippet of what I meant.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 16
(5,600 Views)

Here's a little VI, where a control followes your mouse pointer:

21313iE76865457BBE560B

 

Where I get screen coordinate from the Mouse VI, and posisinot a control just below the mouse pointer.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 16
(5,588 Views)

Ton,

 

Thanks for your reply.  I feel that's on the right track, but I'm getting an error message I don't know how to debug when I run this code.  Here's what I'm running:

 

 

And the error is included there.  How do I go about running this method in execution mode?  Or am I completely missing the point?  Thanks!

0 Kudos
Message 4 of 16
(5,568 Views)

You should connect the error ins and outs wherever they are available to determine at which node the error is occuring.  Just put a probe on each error wire to look for the error condition.  I've run the same code and I don't have any errors.  Perhaps your error is occuring elsewhere.  The only way to tell where the error is occuring is to connect the error wires and use probes on them.

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 16
(5,557 Views)

The error occurs at the Convert Screen to Panel Coordinates invoke, as the error source shows:

 

Invoke Node in Untitled 1<APPEND>
Method Name: <b>Convert Screen To Panel Coordinates</b>

 

The explained error is very similar to the popup I linked in my previous post.

 

Error 1073 occurred at Invoke Node in Untitled 1
Possible reason(s):
LabVIEW:  This property is writable only when the VI is in edit mode, or this method is available only when the VI is in edit mode.
Method Name: Convert Screen To Panel Coordinates

 

I'm still unsure what it means or how to fix it.  Would this have anything to do with me running LV 8.0?  I'm at a loss for what to do next.  Thanks so much for all your help!

0 Kudos
Message 6 of 16
(5,552 Views)

DOH!!!  I'm so stupid.  I didn't even bother to read the whole error box.  I don't know what to say.  I used TCPlomps code and it works for me.

 

Did you drag his snippet into your code or did you create yours from scratch?  I dragged his snippet and it works fine.

- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 16
(5,538 Views)

I get the same error in LV8.2, no error in LV8.6,LV9 and LV10.

Message 8 of 16
(5,535 Views)

I'm using LV9.  That explains why I didn't get the error.

- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 16
(5,532 Views)

I created my own from scratch.  How exactly does one drag a picture and make LV code out of it?  I'm not really sure how to use TCPlomp's code.

 

EDIT: Ah, I see.  I'll see if I can't get access to some of the newer versions we have around here in the office.  Any thoughts on an 8.0 alternative?

0 Kudos
Message 10 of 16
(5,531 Views)