Hello,
I created a docker for X7 with two buttons.
It works fine. (Thanks to bonus630. Great project).
Please could you explain or point me to other previous topic about :
1. How to check from other application if the docker is installed?
2. How to start or close the docker from other application?
3. How to press one of the buttons from other application?
Thank you in advance
When you say 'other application' can it be any type of application?
For instance, in the next VBS code, you can see how to solve the first two issues. Of course, you must know the docker guide.... In the following example I use my docker guide.
If the guide does not belong to any installed docker the code does not return any error... You can find the guide in AppUI.xslt: (in bonus630 47 line): check="*Docker('f3f09ab3-a8b6-4400-9152-62ffbe93ecb5')"
dim drawApp, Found Set drawApp = CreateObject("CorelDraw.Application") drawApp.Framework.ShowDocker "f3f09ab3-a8b6-4400-9152-62ffbe93ecb5" if drawApp.FrameWork.IsDockerVisible("f3f09ab3-a8b6-4400-9152-62ffbe93ecb5") = true then msgbox "Docker installed" Found = true else msgbox "Docker not installed" end if if Found then drawApp.FrameWork.HideDocker "f3f09ab3-a8b6-4400-9152-62ffbe93ecb5" set drawApp = nothing
Pressing the buttons is a little more difficult...
1. Application.Quit works very well but from the moment of running the code in about 6-7 seconds Corel Grafic Interface is closed and corel works like background process for other 20 - 35 seconds according to your number of gms files. After doing whatever is necessary to start well next time the process is really closed. You cand catch this closing in the MacroStorage QueryQuit event and do there whatever you need... I do not know what GC from the next lines means... GC.Collect(); GC.WaitForPendingFinalizers();
2. Why starting of many sessions of CorelDraw would be a chalange?
3. Do you mean that Corel multiple sessions are hidden, working in background in order to allow to 'other logged user to work simultaneously'?
4. Why is that so useful? You are able to know when corel is loaded from its own events. Am I wrong?
5. Even like virtual question the problem could easily be solved between two connected client-server dockers. If communication between dockers is not so important why do you need client, respectively, server dockers? I have a problem now with my Visual Studioa 2013 installation and I'm trying to repair it. Repair operation is stacked in the same point... I will figure it up. Even if I will reinstall it, but like final solution because it takes a lot of time... I would like to look at your project if available. If you decide to send it please use my public email on my profile... Have a nice time! P.S. Are you from Bulgaria? I dared to guess looking to your login name... I'm asking that in order to know if a Good night is appropriate. I am from Romania...
1. Your code should definitely work. You only must take in consideration the necessary time for Corel to properly close. Working with many instances could also be a RAM loading behavior. Maybe you would take in consideration to clear memory later... Do you need stopping them all at once?
2. You may be right putting the problem in this way, but speaking about client-server application maybe it is just enough to run CorelDraw.exe and each docker could send back the instance handler on its Loaded event or even at constructor initialization (hWnd = app.AppWindow.Handle;)...
3. Not working in background processes, how could "user2" work there? I mean working in Corel... With all the other windows loosing focus? What resources do that computers have? In terms of RAM and CPU.
4. Events are easily understandable. For instance you are able to subscribe a QueryQuit event similar with the one from VBA:
//inside constructor: app.QueryQuit += doWhateverYouNeed; private void doWhateverYouNeed(ref bool Cancel) { //do whatever //if you wont to make corel wait until doing something you make //Cancel = true, do the job an after that cancel... MessageBox.Show("BY!"); }
All events of VBA are available in app (for documentNew, documentOpen, PageChange, etc...)
5. Use it in order to send information from inside Corel in order to simplify helper job...
Have a nice day Watson!
1. I still believe that the most 'controlled manner' is the native Quit of the application. On my taste, it is just a matter of being patient. But, de gustibus not discutando...
2. As you wont...
I think Windows allows creation of more than one instance... It depends on how the application has been built. If my application firstly check if another instance is already running and do something according to this check keeps from the application 'habit', I think. For instance, the next two VBScripts are basically written on the same idea, but works different because of Excel Application against Corel Application:
dim drawApp, drApp Set drawApp = CreateObject("CorelDraw.Application"): drawApp.Visible = true set drApp = CreateObject("CorelDraw.Application"): drApp.Visible = true msgbox drApp.appWindow.Handle msgbox drawApp.appWindow.Handle set drawApp = nothing: set drApp = nothing
You will receive the same Handle...
dim E, E1, E2 set E = CreateObject("Excel.Application"): E.Visible = true set E1 = CreateObject("Excel.Application"): E1.Visible = true set E2 = CreateObject("Excel.Application"): E1.Visible = true msgbox E.Hwnd msgbox E1.Hwnd msgbox E2.Hwnd
Here you will receive three apWindow Handles... Excel will really open three sessions! In order to find the open existing session (first time) you must use:
Set E = GetObject(, "Excel.Application")
This is what I firstly tried for Corel (on my first post) but it did not work. I am rather skilled in VBA Excel. I started playing with Corel VBA much more after Excel...
I am used to look for the simplest way of accessing. Now I still do not have VS and can play only with that toys... I am almost sure that this approach works the same in C#, too. Maybe for Corel nobody built a simple tool for simple task. The prove that Windows accept multiple instances is the fact that you manually can open such multiple instances running the exe file. We just must find the most convenient way to do that. For me the most convenient way looks to be just running the exe file, receiving back the corel Window handle and based on that controlling each docker. But it may be not the best solution since I do not know which is the use of that....
3. OK. Understood...