From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

windows messaging in Labview

Hello all,

Here is my situation:

I have a program that was written in C (by someone else) to operate a
piece of lab hardware. The program has a windows interface and I have
access to the source code. The program was compiled and runs well.

I would like to integrate this executable with my labview experiment.
From what I have read, the way to do this is to send messages to my
Windows application using a "call library function" in labview. I am
assuming I can use the SendMessageA() function from the User32.dll in
NT. Essentially, I need to be able to execute two of the commands in
the windows application. The rough outline of the C source that uses
these commands looks like:

switch(msg){
case WM_COMMAND:

switch(LOWORD(wparam)){
case IDM_CAP:
/*do something associated with CAP command*/

case IDM_GAB:
/*do something associated with GAB command*/
}
break;

Basically, I need to know how to configure the call to library
function to execute either of the above commands. As you probably
already know, I am new to Windows programming, but proficient in DOS C
and labVIEW, so if you can help, don't be afraid to elaborate on
details. Also, if my strategy is all wrong, please let me know.
Thanks in advance for any help you may provide.

Chris
0 Kudos
Message 1 of 4
(3,379 Views)
Hey Chris,

I think you might find it easier to just make a CIN or a DLL that contains the switch statement and all your code. You would pass in a LV Boolean that toggles either/or and it will pass back whatever data you like in Labview.

If you drag/drop a CIN object into a labview window, you will notice that you can right-click on the object, and it will give you the option to "create a .c file.." - Before you do so, wire your intended inputs to the CIN and outputs. The data type will be created for you in the .c file when you generate the code. All that's left to do it cut/past your switch code and compile.

Let me know if you get stuck, I'll help you out.

Kindest,
Warren
0 Kudos
Message 2 of 4
(3,378 Views)
Warren,

Thanks for the input. Your suggestion was my first approach, however
the instrument that I am using is somewhat dated and requires that its
custom commands be compiled by a 16 bit compiler. I am assuming that
this would make it difficult to interface with labview, as the CIN source
would need to be compiled with a 32 bit compiler. Am I mistaken?

Since my posting, I have found a solution in using the g toolbox messaging
functions to send messages to my 16 bit windows application. I used the
spy program in Visual C++ to determine the proper message parameters. This
seems to do the trick. Thanks for the input,

Chris









wxfield wrote in message news:<5065000000050000002E3A0000-993342863000@exchange.ni.com>...
> Hey Chris,
>
> I thi
nk you might find it easier to just make a CIN or a DLL that
> contains the switch statement and all your code. You would pass in a
> LV Boolean that toggles either/or and it will pass back whatever data
> you like in Labview.
>
> If you drag/drop a CIN object into a labview window, you will notice
> that you can right-click on the object, and it will give you the
> option to "create a .c file.." - Before you do so, wire your intended
> inputs to the CIN and outputs. The data type will be created for you
> in the .c file when you generate the code. All that's left to do it
> cut/past your switch code and compile.
>
> Let me know if you get stuck, I'll help you out.
>
> Kindest,
> Warren
0 Kudos
Message 4 of 4
(3,378 Views)
Hi Chris,
sometimes it's easier with windows messages.

For this, you need 2 or 3 API calls (normal LV dll calls - user32.dll) :

1. findwindow to obtain a reference to your c application running - you will need to know the title of your C application (the one that apears on title bar)
2. sendmessage or postmessage for sending that message to your application (the difference between them is that the first one waits till your application process the message)

you can find full documentation in MSDN or just take a look on these Visual Basic declares
"
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Declare Function PostMessage Lib "user32" Alias "PostMessageA
" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
"

Good Luck
0 Kudos
Message 3 of 4
(3,378 Views)