Solved

OLE: Returning from server application?

Posted on 1997-10-03
9
260 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
  • 4
  • 3
  • 2
9 Comments
 

Author Comment

by:rocknroll
Comment Utility
Edited text of question
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
Comment Utility
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
Comment Utility
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
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:rocknroll
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now