LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My LabVIEW-WinAPI Fails

Hi,
I created this message to ask and verify if I'm the only LabVIEW developer which fails every time when tries to use Windows API on his own (not using ready to use DLL wrappers, developed by some LabVIEW-Windows genius)? I mean, every time when I realise that there is some nice Win function, which is not natively supported by LV, and I tried to use it in LV, I'm failing translating WinAPI from MSDN to LV code...


How about You LV Community?

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 1 of 25
(4,894 Views)

Can you give an example of what you mean?  By chance is there a specific thing you really want to do?

 

In my experience some things are relatively easy and some things are not.  The things that are not tend to be those that have inputs that don't have an easy way (or any way) to create using LabVIEW.

 

As an example, one of the things that took me far longer to create than it should was a List object of another object.  Code that would be rather simple in C# like this:

 

List<CustomObject> oList = new List<CustomObject>();

CustomObject CustObj = new CustomObject();

CustObj.SomeProperty = SomeValue;

oList.Add(CustObj);

SomeOtherFunctionThatTakesListsOfCustomObjectsAsInput(oList);

 

However doing this in LabVIEW was an incredible pain in the butt because the generic List object has no easy way to instantiate in LabVIEW.  This was the way to do it:

List.png

I had to copy out that long typeName string by hand as I couldn't find anywhere I could copy-paste it from, plus I had to update it manually whenever the version number changed.

 

So generally unless there's someone else's code that I need to interface with using Windows APIs I generally stay as far away from it as I can.

0 Kudos
Message 2 of 25
(4,833 Views)

Show us the "Code that Fails" (and tell us what you want to do).  Maybe one of us can "fix it" for you.  Wouldn't it be nicer to have a specific solution to a problem you are having than a trivial example of no interest to you?  Post the actual VI, please, as we'll want to modify/run/probe/test it ourselves (and we can't do that with a JPEG image).

 

Bob Schor

0 Kudos
Message 3 of 25
(4,814 Views)

Ok so this time I tried to create semi transparent window with opaque controls in it. Something similar to this. I tried code from this thread. But from the articles from mattb-5906 I know that I need to use UpdateLayeredWindow method instead of SetLayeredWindowAttributes. And here the trouble begins... I tried to understand how to implement this but I failed...

I asked for help on MS forum, but no one responded...

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 4 of 25
(4,802 Views)

@bienieck wrote:

Ok so this time I tried to create semi transparent window with opaque controls in it. Something similar to this. I tried code from this thread. But from the articles from mattb-5906 I know that I need to use UpdateLayeredWindow method instead of SetLayeredWindowAttributes. And here the trouble begins... I tried to understand how to implement this but I failed...

I asked for help on MS forum, but no one responded...


You rant about not being able to implement Windows API in LabVIEW, but yet you don't even have working non-LabVIEW code.

 

The key is to be able to do what you want in Windows code first.  Are you absolutely certain it can be done in Windows?

 

 

 

 

0 Kudos
Message 5 of 25
(4,787 Views)

Yes, I'm certain it is doable. Here are examples, even from LV:

http://www.codeproject.com/Articles/34158/Cool-Semi-transparent-and-Shaped-Dialogs-with-Stan

http://www.oocities.org/gzou999/features.htm

http://www.oocities.org/gzou999/grf/semitransparent.gif

 

and from mattb-5906:

"I spent ages looking at doing something similar to your idea... In the end I gave up .

 

Layered windows: http://msdn.microsoft.com/en-us/library/ms997507.aspx

Below are some links to reources I have collected over the years which may be of interest:

http://support.microsoft.com/kb/249341

http://www.codeproject.com/Articles/1036/Per-Pixel-Alpha-Blend

http://www.codeproject.com/Articles/34158/Cool-Semi-transparent-and-Shaped-Dialo gs-with-Stan

http://melander.dk/articles/alphasplash/

http://msdn.microsoft.com/en-us/library/ms633540%28VS.85%29.aspx"

 

And example how to do something similar:

https://decibel.ni.com/content/blogs/labview-news-english/2014/02/17/making-your-splash-screen-groov...

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 6 of 25
(4,750 Views)

@bienieck wrote:

Yes, I'm certain it is doable. Here are examples, even from LV:

http://www.codeproject.com/Articles/34158/Cool-Semi-transparent-and-Shaped-Dialogs-with-Stan

http://www.oocities.org/gzou999/features.htm

http://www.oocities.org/gzou999/grf/semitransparent.gif

 

and from mattb-5906:

"I spent ages looking at doing something similar to your idea... In the end I gave up .

 

Layered windows: http://msdn.microsoft.com/en-us/library/ms997507.aspx

Below are some links to reources I have collected over the years which may be of interest:

http://support.microsoft.com/kb/249341

http://www.codeproject.com/Articles/1036/Per-Pixel-Alpha-Blend

http://www.codeproject.com/Articles/34158/Cool-Semi-transparent-and-Shaped-Dialo gs-with-Stan

http://melander.dk/articles/alphasplash/

http://msdn.microsoft.com/en-us/library/ms633540%28VS.85%29.aspx"

 

And example how to do something similar:

https://decibel.ni.com/content/blogs/labview-news-english/2014/02/17/making-your-splash-screen-groov...


 

mattb-5906 gave up so I hardly consider that a ringing endorsement of doable.

 

Have you actually taken the non-LV code and have it run in Windows 7 yet?

 

 

If you have something similar in LabVIEW, why aren't you able to convert it ?

 

 

 

0 Kudos
Message 7 of 25
(4,736 Views)

It IS doable, I gave you real examples....

 

No.

 

Because similar solution uses different approach. SetLayeredWindowAttributes makes either whole window semi transparent or particular background color transparent. I need something between this options and for this purpose in need to use UpdateLayeredWindow which is not that easy.

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 8 of 25
(4,711 Views)

What question are you asking here? If your question is, are there LabVIEW developers who call functions in DLLs (from the Windows API and elsewhere) successfully in their code, the answer is yes. Does it require some knowledge of C (because that's the standard for function prototypes and data types)? Absolutely.

 

If you want help with specific WinAPI function, it would be best to ask a question about that specific function instead. Include links to the MSDN functions you want to call, your attempt at calling it from LabVIEW (showing how you configured the Call Library Function Node), and the specific error that you're getting. DON'T just complain that your attempts "fail."

 

As for the functions you mention: I've never tried this and I've only skimmed the MSDN documentation. Looks like you'll need to use SetWindowLongPtr to set the WS_EX_LAYERED flag. Once you do that, you should be able to call UpdateLayeredWindow on the window, and you'll need to determine the appropriate parameters. I have no idea if this will get your desired effect, though, since many of the LabVIEW controls are not standard Windows controls.

 

 

0 Kudos
Message 9 of 25
(4,703 Views)

@bienieck wrote:

It IS doable, I gave you real examples....

 

No.

 

Because similar solution uses different approach. SetLayeredWindowAttributes makes either whole window semi transparent or particular background color transparent. I need something between this options and for this purpose in need to use UpdateLayeredWindow which is not that easy.


How is it doable when you were asking at the MSDN forums for pseudo code?

 

You don't have real examples. You have code that someone else wrote in C++ and .NET which may or may not be exactly what you want to achieve.

 

You have not actually run the non-LabVIEW code. You "think" it works, but you really don't know. You are going by pictures.

 

You need actual working code that you understand, and you need to then convert it.

 

 

 

 

0 Kudos
Message 10 of 25
(4,691 Views)