Solved

OLE: Returning from server application?

Posted on 1997-10-03
9
264 Views
Last Modified: 2010-04-04
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.
0
Comment
Question by:rocknroll
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 

Author Comment

by:rocknroll
ID: 1346766
Edited text of question
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1346767
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
 

Author Comment

by:rocknroll
ID: 1346768
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1346769
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
 

Author Comment

by:rocknroll
ID: 1346770
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
 
LVL 8

Expert Comment

by:ZifNab
ID: 1346771
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
 

Author Comment

by:rocknroll
ID: 1346772
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
 

Expert Comment

by:Tetardd
ID: 3926693
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
 

Expert Comment

by:Tetardd
ID: 3926753
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question