Hi, I'm trying to run the fallowing code:
Type pia_type = Type.GetTypeFromProgID("CorelDRAW.Application.18");Corel.Interop.VGCore.Application corelApp = Activator.CreateInstance(pia_type) as Corel.Interop.VGCore.Application;corelApp.Visible = false;
// Thread.Sleep(5000);
Corel.Interop.VGCore.Document doc = corelApp.OpenDocument(copiedFilePath);
......
The OpenDocument line fails, because the Corel is not yet fully started to perform next actions. And it works if I uncomment Thread.Sleep line, because it has more time to load. Clearly Thread.Sleep is not a good solution, because some computers might load faster, some slower and I can't guess the milis needed. I tried different Events (WindowActivate, OnApplicationEvent), but with "corelApp.Visible = false;" I was not lucky to catch a "nowItsLoaded" event.
Any ideas?
gstoilov said:Hi, I'm using waiting loop for a specific window to appear . http://community.coreldraw.com/sdk/f/40/p/54477/261110#261110 for example menu bar :Menubar = FindChildWindow(hwnd, "Menubar-f3016f3c-2847-4557-b61a-a2d05319cf18");
And can you obtain Corel.Application (COM object) from MenuBar Child window?
I found ways to obtain Exel COM object using AccessibleObjectFromWindow API, but in order to work, besides the window handler you have to know IDispatch interface... For Excel (workbook window - class "EXCEL7", IDispatch = "{00020400-0000-0000-C000-000000000046}".
Can you obtain Corel.Application only from MenuBar handle? If Yes, can you share your solution (code)?
Thanks in advance!
Deleted...
deleted
Sorry trsh, I will delete the posts.