LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

APWIN interface

I have some APwin procedure but I would like to call some labview VI from this APwin procedure.
0 Kudos
Message 1 of 5
(5,173 Views)
I would guess you're trying to use a Win32 API that uses a callback. I do not believe LabVIEW can give you a pointer to a VI that would work as a callback procedure. The thing to do is to write a DLL (probably in C++) that calls the Win32 API function and supplies it with a pointer to one of it's procedures. Then it can do the calculations and return the results to LabVIEW.
An example of an API function where you'd need this is EnumWindows (User32.dll).
EnumWindows cycles through the windows 'windows list', returning a window handle on each iteration. It takes 2 parameters, lpEnumFunc which is a pointer to a function (you must create the function) and lParam which is a parameter that EnumWindows sends to lpEnumFunc. When EnumWindows is called, it grabs the fi
rst window handle and passes it to the procedure at lpEnumFunc. If the procedure returns a 0, EnumWindows ends, otherwise, it passes the procedure the next window handle.
My workaround for my problem was to call GetDeskTopWindow (which contains all top level windows as child windows), call GetWindow with the GW_CHILD constant to get the first top level window handle, then iterate with GetWindows using the GW_NEXTWIND constant, retrieving the window handles until I get a window handle that's not a window handle (test it with IsWindow).
That's what you have to do without the ability to specify callbacks. You can't do Hooks (to snag events) or subclassing (to react to ,modify or remove events for a window) either. Dammit.
I'm working on this problem in a desultory fashion, and when I get it right, I'll post it to info-labview, the example programs here at NI, and on my web site.
Until then, life sucks for you (and me.)
John Wilson
Sanders Engineering & Analytical Services, In
c.
Mobile, AL
251-633-4120
johnwilson@pctechnician.net
Message 2 of 5
(5,173 Views)

Perfect layout John:

I did exactly as you had layed out and attached is a copy of a working vi I made in 8.2. If anyone else wanted to get all running windows and their handles take a look at my vi.

0 Kudos
Message 3 of 5
(4,352 Views)

I was using similar routine to EnumWindows and use first and last hwnds to complete search and only enum windows with names.

Do not forget to close handles after you done using them...

EnumWindows.png

Message 4 of 5
(4,201 Views)

While we're on the subject of HWNDs and LabVIEW.  I figured I would share a nice little reuse VI that gives the HWND of a LabVIEW front panel window.

 

I realize people have been doing this for a while but they generally do it using the front panel window title, and then use that to get the HWND.  A more robust way is to use the Private Method Native Window.

 

This VI does have a private method (and an optional depracated method) so causion should be used, and use this at your own risk, understanding functionality of this property may change without notice on other LabVIEW versions.

0 Kudos
Message 5 of 5
(4,178 Views)