07-19-2019 06:46 AM - edited 07-19-2019 06:48 AM
i have a button on my FrontPanel in LabView. I created a DLL in VisualStudio that i would like to use in Labview to get the coordinates of that button.
My GetCoords method uses a "Control" input parameter which is my button in LabView. When i link my button reference from Labview to the method from C# using the DLL i get an error that my reference from my control in labview is not a .NET reference. And yes, its not a .NET control, but what do i use in C# instead of "Control" parameter so i can input my labview control?
So is there any other way to send my Labview button reference to the C# DLL ?
Thanks
07-19-2019 07:08 AM - edited 07-19-2019 07:09 AM
07-19-2019 07:14 AM - edited 07-19-2019 07:15 AM
@neco93 wrote:So is there any other way to send my Labview button reference to the C# DLL ?
What you are trying to do is very complicated.
The control reference means nothing in C# (or C, Python, or anything else but LabVIEW).
You could theoretically use the reference in the dll by opening a LabVIEW application instance (ActiveX, IIRC), and invoke methods on that control reference.
Even if you get the button coordinates, they will be relative to the panel\pane and it's origin. So you'd need more LabVIEW magic to convert the coordinates to screen coordinates.
Why not simply pass the coordinates to the dll?
Another long shot is to make a .NET Button, and pass the .NET control reference. This isn't as simple as it sound either; the LabVIEW reference probably isn't the C# reference. But how knows, maybe it is...
07-19-2019 07:16 AM
Hi Gerd,
i know how to get the coordinates from propery nodes, but sadly LabView has a bug with the position of the controls. In my case i have i big application and sometimes the position of the control is way off. I even tried method "convert pnl to screen coordinates" but that also sometimes works and sometimes doesnt. I have also concacted LABview developers that say that they are still fixing the bug. SO now i am trying with C# if it will work.
BR
07-19-2019 07:19 AM
Hi neco,
In my case i have i big application and sometimes the position of the control is way off.
The panel origin is always in the upper left corner of the front panel?
Never had this problem so far: Can you provide an example VI showing this problem?
07-19-2019 07:23 AM
@neco93 wrote:
I even tried method "convert pnl to screen coordinates" but that also sometimes works and sometimes doesnt. I have also concacted LABview developers that say that they are still fixing the bug. SO now i am trying with C# if it will work.
BR
I've used this a lot, and also never noticed bugs...
You do need to do some math, and it's a hassle when using SubPanels, but no bugs AFAIK.
C# is not a solution for sure.
@neco93 wrote:
I have also concacted LABview developers
A for effort, but it's LabVIEW.
07-19-2019 07:25 AM
@GerdW wrote:
What exactly is your goal - and why do you need external code in C# to reach that goal?
Don't forget about this one...
Why do you need the coordinates in the first place?
07-19-2019 04:39 PM
wiebe@CARYA wrote:
@GerdW wrote:
What exactly is your goal - and why do you need external code in C# to reach that goal?
Don't forget about this one...
Why do you need the coordinates in the first place?
I agree. Whatever you might need the coordinates for, there's probably an easier way to achieve it.