Solved

OLE: Returning from server application?

Posted on 1997-10-03
9
262 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
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 90
Delphi cmd execution 6 60
Delphi - replicating a form 8 74
CheckListBox usage 3 58
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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