OLE: Returning from server application?

I'm using a TOleContainer in my program to add embedded objects to a database. When the user creates a new embedded object, the InsertObjectDialog box appears and opens up the appropriate server application (eg. Word). What I want to do is to save the embedded object to the database when the user returns from the application. How can I tell when the user closes down the application and returns?

I know in Visual Basic that it's OLE container has an Updated event, but Delphi does not. All Delphi has is a modified property. How do I know when to check this modified property to see if the object has changed. I want to check it after the user returns from the server application. But how?

When opening an OLE's server application your program does not stop and wait until the server has closed, it continues to run. That's why putting code to save the object to the database straight after the call to the server application does not work.
rocknrollAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rocknrollAuthor Commented:
Edited text of question
0
ZifNabCommented:
Why don't you use the modified property?

property Modified: Boolean;

Run-time only. Indicates that the OLE object has been modified (including being deleted or replaced by another OLE object). You can set Modified to False and later check it to see if the OLE object has been modified. If there is no OLE object loaded into the container, Modified returns False.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rocknrollAuthor Commented:
I think my question was misunderstood. Checking the Modified property would work, but when? The following code example will not work.

if OleContainer1.InsertObjectDialog then
begin
   OleContainer1.Modified := False;
   OleContainer1.DoVerb(ovShow);   {execute server application}
   If OleContainer1.Modified = True then
   begin
      {code to save object to database}
   end;
end;

In the above code, when the server application is executed, the IF statement following will be immediately execute, and of course it will not be true.

Is there any possible way of knowing when the user finishes modifying the object in the server application and closes it down and returns to my application. If there isn't, then the only time I can see to check the Modified property would be before my application is closed down, or when the user moves to the next record in the database. Using the Timer to check the Modified property at certain intervals would just be ridiculous.

0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

ZifNabCommented:
Use it when the ondeactivate method occurs :

property OnDeactivate: TNotifyEvent;

Why isn't it good to check after the user changed to another record?

0
rocknrollAuthor Commented:
I tried the OnDeactivate Event but that didn't work. Closing down the server application doesn't seem to generate any Event in the OleContainer.


0
ZifNabCommented:
OnDeActivate doesn't work, strange. Well, then I really don't know how to solve this problem. Sorry. I'll go to look at it, but not at this moment I'm afraid. Don't have much time at the moment. Still, my question, why isn't it good to check after the user changed to another record?
0
rocknrollAuthor Commented:
When the user changes to another record (check Modified property) may be the only solution I can see at the moment. Thanks for your help anyway ZifNab.
0
TetarddCommented:
I had the same problem and I found that using the OnResize and OnObjectMove events does the job.
Whenever your object is updated/modified/inserted, these events are fired so you know when to test for Modified = True.

David.
0
TetarddCommented:
I had the same problem and I found that using the OnResize and OnObjectMove events does the job.
Whenever your object is updated/modified/inserted, these events are fired so you know when to test for Modified = True.

David.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.