LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to register an event for LV event structure from WinApi "PostMessage"?

Hello experts,

I'm using a standard cardreader (RS232/USB) which I access via the manufacturer's API, this works fine so far. However I don't want to poll the status of the reader all the time. The cardreader sends windows messages using the WIN API "PostMessage" as soon as there is a status change (insert card into reader, reader disconnect etc.)

Now how can I use this fact to get an event for my event structure? Any ideas?

Thank you
Melanie
0 Kudos
Message 1 of 7
(3,230 Views)
hello Melanie,

This may be tricky but you could use the Windows Message Queue Library example to get the messages from the USB drivers;
http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E7AC56A4E034080020E74861&p_node=DZ52071&p_submitted=N&p_rank=&p_answer=&p_source=External

And from then create a custom user event based on the POSTMESSAGES received;
http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E7AC56A4E034080020E74861&p_node=DZ52071&p_submitted=N&p_rank=&p_answer=&p_source=External

Hope this helps,
Cyril Bouton
Active LabVIEW Developper
Message 2 of 7
(3,221 Views)
If you're working with the windows API, you can use the getmessage function from user32.dll to read the message from the queue. Theoretically, The code I'm posting should work, but I haven't tested it. Also, If it does work, I think it will grab all the messages from the window. You can use this as your event (the function should wait until it gets a message) or you can use it to fire a dynamic event.

___________________
Try to take over the world!
0 Kudos
Message 3 of 7
(3,209 Views)
Here's the code.

___________________
Try to take over the world!
Message 4 of 7
(3,207 Views)
Wrong !

You can't use "GetMessage" to steal messages from another window. It's not that simple.

As Cyril Bouton pointed out, the way to intercept messages from another window is demonstrated in the message queue example.

George Zou
http://gtoolbox.yeah.net
George Zou
0 Kudos
Message 5 of 7
(3,187 Views)
Why both of your links point to the sample example ?

I've seen this example long long time ago. It demonstrates how to intercept window messages,
but it doesn't show you how to convert an occurrence to LV event (although it's simple).

George Zou
http://gtoolbox.yeah.net
George Zou
0 Kudos
Message 6 of 7
(3,180 Views)
Sorry.
Like I said, I didn't have time to test the code. This is actually an adaptation of a code that worked perfectly for me on a PocketPC emulator window, which I put together quickly, of the top of my head, without much thought or checking.

___________________
Try to take over the world!
0 Kudos
Message 7 of 7
(3,167 Views)