08-12-2010 04:12 PM
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.
Solved! Go to Solution.
08-12-2010 04:39 PM
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
08-12-2010 04:54 PM
Here's a little VI, where a control followes your mouse pointer:
Where I get screen coordinate from the Mouse VI, and posisinot a control just below the mouse pointer.
Ton
08-13-2010 11:32 AM
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!
08-13-2010 12:02 PM
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.
08-13-2010 12:07 PM
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!
08-13-2010 12:15 PM
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.
08-13-2010 12:20 PM
I get the same error in LV8.2, no error in LV8.6,LV9 and LV10.
08-13-2010 12:21 PM
I'm using LV9. That explains why I didn't get the error.
08-13-2010 12:21 PM - edited 08-13-2010 12:22 PM
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?