LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i pass a control(Button,…) reference from Labview to C#(VisualStudio)

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

 

Download All
0 Kudos
Message 1 of 8
(2,828 Views)

Hi neco,

 

why don't you use property nodes in LabVIEW to determine the coordinates of that button?

 

What exactly is your goal - and why do you need external code in C# to reach that goal?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(2,798 Views)

@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...

0 Kudos
Message 3 of 8
(2,790 Views)

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

0 Kudos
Message 4 of 8
(2,788 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(2,783 Views)

@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 LabVIEWSmiley Wink.

0 Kudos
Message 6 of 8
(2,777 Views)

@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?

0 Kudos
Message 7 of 8
(2,775 Views)

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 8
(2,709 Views)