LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

windows messaging

hi,
 
I have interfaced Labview with a software using Windows messaging. Moreover, the same interface was made in C++.
 
The C++ program send message and cath all the ones send by the software. But my Labview application sometime doesn't cath the messages. I don't know why. it's really strange because I build my labview application copying on the C++ code.
 
Could you explain me how windows treats the messages queue? for instance, when is a message deleted after it was posted?
 
I join my application.
 
Thank you
 
L'asticot.
 
 
Download All
0 Kudos
Message 1 of 10
(4,600 Views)
I have to say you've made some pretty good progress since you first started dealing with this. I would suggest reading the MSDN article on Messages and Message Queues.

Note: Since this is a byproduct of the original post, it helps to reference it so others can get a better idea of the context of the question.
Message 2 of 10
(4,582 Views)

 

I can't live an other day without you. You are looking after me, shame on me!

I have already read this article but i don't have lot of knowledges about Windows.... and my English is so bad that it's difficult to understand!

But i'm going to read it again!

In fact, my question was: is a message can be deleted if it is read by an other application?

Thank you.

0 Kudos
Message 3 of 10
(4,558 Views)
A properly written application would not remove messages that are not meant for it. By looking at the code you posted my guess is that you need to put some execution order dependency. You should add error in/error out clusters on your "Receive Message" VI so that you can force that VI to run after you post the message. Wire the error out from the call library function that posts the message to the error in of the "Receive Message" to ensure that the "Receive Message" runs after the message has been posted. Try this to see if there's an improvement in the reliability of your application.
Message 4 of 10
(4,538 Views)

But there is no error in/out an a "call library fonction"?!?

i have tried to put the post message and the receive message in a sequence structure. It seems to be a little bit better...

Don't you think it can be a probleme with Getmessage()? i have try with peekmessage() but i had the same results...

Or Maybe Labview is so slow. Because when i quickly move the mouse (then i create lot of events) during i order to mshape, my application never find the messages send back by mshape.

Thank you again.

0 Kudos
Message 5 of 10
(4,519 Views)
Indeed, the LabVIEW 7.1 version of the Call Library function doesn't have error I/O clusters. You can always wrap the call in a VI.

Unfortunately, I can't help you any further on this, as it's hit my limit of knowledge. Based on what I saw by running a test program is that the problem isn't that LabVIEW is too slow. Rather, it seems that the LabVIEW UI is being locked up once you execute the PostMessage or GetMessage a couple of times. If I have just the "Receive a Message" open and I run that I can send a test message from another application and it receives it just fine. Running within your framework, however, it stops responding. Maybe those calls are running in the LabVIEW UI so that's basically causing the whole thing to lock up. Perhaps if George Zou is listening he can offer some tips. I know he's done a fair bit of LabVIEW<->Windows programming. Otherwise, perhaps if any NI rep is listening perhaps they can shed some light?
0 Kudos
Message 6 of 10
(4,506 Views)
The problem is that you can't use GetMessage.  GetMessage is designed to be used in window procedure, not an external program.
 
If you want to get window messages mean for another window, you should use the hook technique.  That's advanced window programming technique.  It might hard for a beginner.
 
You should get a window programming book, such as Charles Petzold's Programming Windows.  It's a popular book.  You might be able to find one in your language.
 
There is an example in NI's website: window message queue (http://zone.ni.com/devzone/cda/epd/p/id/4394).  It might need some work.
 
What window do you try to get message from?  Is it a LabVIEW window?
 
George Zou
 
George Zou
0 Kudos
Message 7 of 10
(4,499 Views)

Dear Zou,

I am trying to dialogue with a interferometry software called mShape. this was sold with an external module which allows to control mShape by an other application via window messaging-.

At this time, my application is not so bad, it often works but sometimes it doesn't manage to receive the mShape messaging.

The external modul's constructor give me an example in C++ to show me how mShape works. If you have an idea to translate this code in a Labview application... 

Thank you very much

L'asticot   

Download All
0 Kudos
Message 8 of 10
(4,469 Views)
It seems you get the send messag part working, although the structure design has a lot room to improve.
 
The get meesage part is not right.  You shouldn't use GetWindowMessage.
You just created a race condition.  There is no guarantee you will get the message.
 
As I mentioned in my previous post, you should use the hook technique to get the message.
 
You don't have to do this in C/C++, but you have to do this in LabVIEW.  Because in C/C++, you create
message loop, window procedure, etc., but LabVIEW is taking care of the message loop and window procedure,
and only pass a few messages (no including user registered message) to LabVIEW programmer.
 
The message queue example does what you need: catch the messge.  You should spend some time to understand it,
and combine it with your send message part program.  That's basicly what the C++ does.
 
Your project is not for an entry level window programmer.
 
Good luck.
 
George Zou
 

Message Edited by zou on 05-24-2007 01:22 PM

George Zou
0 Kudos
Message 9 of 10
(4,462 Views)
In this kind of situation I would also suggest that perhaps creating a wrapper DLL that handles the messaging outside of LabVIEW will probably yield more reliable results. I had suggested this when you first brought this up in the other thread that I referenced. Based on George's comments I think you may want to revisit this idea.
0 Kudos
Message 10 of 10
(4,452 Views)