![]() |
#1
|
|||
|
|||
![]()
Hello,
I'm pretty new in Corel programming so I hope I don't ask too ridiculous things ![]() I'm referencing Corel X4 with CSharp 2005 and wonder, what's the right way to compare Document Objects in like this situation: Code:
List<CorelDRAW.Document> docs = new List<CorelDRAW.Document>(); CorelDRAW.Document doc = app.createDocument(); docs.add(doc); Code:
app.QueryDocumentSave += new CorelDRAW.DIDrawApplicationEvents_QueryDocumentSaveEventHandler(onQueryDocumentSave); Code:
void onQueryDocumentSave(CorelDRAW.Document Doc, ref bool Cancel) { // Doc is the document where the event happend. But what is the corresponding document in my list? foreach(CorelDRAW.Document d in docs) { if(d == Doc) // do sth if(d.Equals(Doc)) // do sth } } Any ideas on this? Best, -Jeff |
#2
|
||||
|
||||
![]()
Hey Jeff welcome to the forum. I don't have C# on this machine, so I did a quick test in VBA, and the equals does work in VBA.
Code:
Private Sub GlobalMacroStorage_QueryDocumentSave(ByVal Doc As Document, Cancel As Boolean) Dim d As Document For Each d In Documents If d = Doc Then MsgBox "match" Else MsgBox "no match" End If Next d End Sub |
#3
|
|||
|
|||
![]()
Hello Shelby,
thanks for looking into this! I narrowed it down further, even without the List, kind of like so: Code:
// global scope: CorelDRAW.Document my_doc = null; // --- then in a func: CorelDRAW.Application app = new CorelDRAW.Application(); app.Visible = true; app.QueryDocumentSave += new CorelDRAW.DIDrawApplicationEvents_QueryDocumentSaveEventHandler(onQueryDocumentSave); my_doc = app.CreateDocument(); doc1.Name = "My Doc"; Code:
void onQueryDocumentSave(CorelDRAW.Document Doc, ref bool Cancel) { if(my_doc == Doc) MessageBox.Show(Doc.Name); } So I'm definitely missing something, there sure must be a way to compare documents but I don't understand why Corel gives me a copy of the source Document where the event happend. Best, -Jeff Last edited by Jeff; 18-05-2011 at 04:12. |
#4
|
|||
|
|||
![]()
UPDATE: at last I found the Property
Code:
CorelDRAW.Document.MetaData.DocID Code:
if(doc1.Metadata.DocID == Doc.Metadata.DocID) // do sth... |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Rotate All Objects in current document | derasje | Macros/Add-ons | 2 | 15-11-2008 05:07 |
Is it possible to make an invisible document in coreldraw ? | enpassant | CorelDRAW/Corel DESIGNER VBA | 2 | 12-07-2006 10:16 |
Objects in Document | akayani | Code Critique | 9 | 06-02-2006 07:15 |
How to get objects from another opened corel document | ama | CorelDRAW/Corel DESIGNER VBA | 12 | 24-02-2004 07:11 |
Copying objects to clipboard then closing document. | CORNMEN | CorelDRAW/Corel DESIGNER VBA | 4 | 31-03-2003 09:52 |