LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Registering and broadcasting a custom Windows message


I currently have two programs running on the same computer, both programmed in C++ by me, a programming idiot. One is recording data and the other is providing a stimulus. The recording program broadcasts a custom Windows message to sync the stimulus or to move to the next stimulus.

The recording program is being replaced by a LV program, but we want to use the same stimulus program. So I need to make the LV program register and broadcast custom Windows messages. How is that done?


Here's some more details...
The two applications run on the same computer and they both register these Windows messages:

static UINT WM_SYNC = RegisterWindowMessage("SYNCMESSAGE");        // used to sync with stim
static UINT WM_NEXTSTIM = RegisterWindowMessage("NEXTSTIMMESSAGE");    // used to call next stim

The stimulus program receives these messages and responds to them.

The recording program, which is being replaced by a LABVIEW application, post these messages
with this code:

::SendMessage(HWND_BROADCAST,WM_SYNC,NULL,NULL);    // reset the stim

or

::SendMessage(HWND_BROADCAST,WM_NEXTSTIM,NULL,NULL);     // switch to the next stim

How can I get my LV program to register a custom Windows message and broadcast it?

Or are there built-in custom Windows messages that LABVIEW can broadcast? If so, what are the strings associated with them so I can change my stimulus program?

Thanks in advance!
sls
0 Kudos
Message 1 of 7
(3,929 Views)
How about using the System Exec.vi to execute the net send console command?
 
 
There are lots of examples that can be found by searching the forum. To save a bit of time I have attached a VI that I had found previously on the NI site to execute DOS commands to get you started.
 
David
0 Kudos
Message 2 of 7
(3,911 Views)

Thanks for the suggestion, David, but that's a different kind of message. I'm not trying to send notes arounds. I want to post a message to the Windows operating system message queue. These are messages (like mouse movements, key presses, and the like) generated by the Windows system and then delivered to programs. This is much faster and more basic to the operating system then net send. I just need to know how to get LV to register and post custom Windows messages.

0 Kudos
Message 3 of 7
(3,908 Views)
Since you are good at C++, why not create a dll that Calls the RegisterWindowMessage, and SendMessage, and call the dll in LabVIEW?
 
George Zou
George Zou
Message 4 of 7
(3,891 Views)
George- I might try that, if there isn't a better option. How do you call a DLL in LV? What's the timing like for that? BTW, I'm not good at C++, I'm a programming idiot as I mentioned in my original post. I've never written a DLL before. -s
0 Kudos
Message 5 of 7
(3,880 Views)
Message 6 of 7
(3,860 Views)
Thanks for the link, George. It sounds like that's the way to do it. -s
0 Kudos
Message 7 of 7
(3,851 Views)