LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bringing MS Word application to the front and detecting when it is closed

Well, look at it this way. At least you now have another Microsoft story... Smiley Very Happy
Message 11 of 19
(1,729 Views)

LOL!!  I have too many ms stories..

Ever use Borland C, then Borland C++ ver 4.0, then 4.5? then 5.0? 

 

BAck to topic..

 

Getting much closer..  The callback example is where I'm at..  Works well... opens word.  closes it..  calls the callback VI which pops up the message.  It's almost there.

How do you genenrate a trigger from the Strictly Typed VI created by the Reg Event Callback?

It's hard to describe what I'm trying to do.  So with reference to attached image, pretend that the event "create report" is one of the state in the Event Structure and "VI Activation" is another event in the same structure.  So the attached image would represent two pages from the same structre (easier to show this way).  How do I get the bottom Event Structure to trigger only from the desired User Event (Word closing) which is generated from the one pictured above it?  The reference in the top one is for the VI at the bottom.  I realize VI Activation VI is probably not the event to choose..  (it triggered by clicking on the block diagram.. 😉 )
 
Since the VI being referenced by the Strict Type does not allow to change the connector pane (ie add terminals), which could be used to set a change of value to an known indicator; how do I trigger a LV event within the Event Structure??.. 
 
This would be easier to explain with a mind-meld.. 😉 
 
Many Thanks
 
RayR


Message Edited by JoeLabView on 01-23-2008 03:11 PM
0 Kudos
Message 12 of 19
(1,721 Views)
I only used Borland a long time ago. Can't remember what version it was, though.

As to your question, one simple way to do it is to use the User Parameter item for the Register Callback. You can pass it a control reference and in the callback you can write to the "Value (Signaling)" property to trigger an event. This requires an extra indicator on your front panel (which can be hidden), so some may see it as crude, but it works, and it's simple. See attached updated VIs for sample.

I may have to start adding version numbers to these VIs. Smiley Very Happy
Download All
0 Kudos
Message 13 of 19
(1,715 Views)

Great topic,

The only other thing to watch out for is that all callback VI's are inherently reentrant and they run in their own application instance of LV. I found this out during my current project using teststand. Drove me crazy trying to figure out why somethings would work and others would not. Just something to keep in mind.

 

 




Joe.
"NOTHING IS EVER EASY"
Message 14 of 19
(1,693 Views)

Thank you Joe..

I'm close to the solution (although I've been working on other parts of the project).  You may have explained a "mysterious" behavior that I did not get a chance to investigate.

What I described earlier is a simplified version of what I'm trying to do.  Many thanks also to smercurio for leading me into the right direction.   🙂

 

0 Kudos
Message 15 of 19
(1,675 Views)

It is somewhat working..  Many thanks guys..

I did find out what causes the "somewhat"..  It is a race condition.

Word is busy doing it's thing :  adding text to the document & adding pretty pictures, etc.

I need to detect when it is done doing "those" things.  I know there is a way of doing this, I did it before, can't remember how, etc...  Detecting when it is done will also prevent the application for leaving the foreground.

I include a very tiny code tid-bit..  It's simple, place text in the range and format the text... nothing special.  I just want to know when it is done. 

I could place a wait.... but that's just not right.. 😠

🙂



Message Edited by JoeLabView on 01-29-2008 04:50 PM
0 Kudos
Message 16 of 19
(1,647 Views)

Everything is good.

It turned out not to be a race condition.   I changed a couple of things...  related to how the report comes to the front and resetting the boolean for the Quit event.

That was it..  Strangely simple..  😮

😄 

0 Kudos
Message 17 of 19
(1,637 Views)
All things are strange in the world of Microsoft. Smiley Happy



Joe.
"NOTHING IS EVER EASY"
Message 18 of 19
(1,621 Views)
Let's just say that I gained a lot of respect for those who "have to" program any msuff products.. 😉
0 Kudos
Message 19 of 19
(1,608 Views)