PDF-XChange / Multithreaded COM
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Andrew - Tracker Support, Tracker - Clarion Support, John - Tracker Supp, Support Staff, moderators
-
- User
- Posts: 29
- Joined: Fri Feb 18, 2005 2:23 pm
- Location: Trondheim, Norway
- Contact:
PDF-XChange / Multithreaded COM
Several of our applications use PDF-XChange. We have implemented the communication with PDF-XChange in a DLL and tried using both message-based communication and the CPXCControl, and it all has been working well.
However, one our applications now need to use multithreaded COM, and then the communication with PDF-XChange doesn't work as it should anymore.
We have written a small test application that use automation to open a Word document and print it to PDF-XChange. When we use "CoInitialize()" to initialize COM it works well, but when we call "CoInitializeEx(nil, COINIT_MULTITHREADED) it fails.
Debugging shows that with multithreaded COM, the OnPrintingStarted event of the CPXCControl is never called, and if we use message-based communication the application never gets the pdfxcMsg_StartDoc message.
Hope you can help us with this problem.
Regards,
Arnstein
However, one our applications now need to use multithreaded COM, and then the communication with PDF-XChange doesn't work as it should anymore.
We have written a small test application that use automation to open a Word document and print it to PDF-XChange. When we use "CoInitialize()" to initialize COM it works well, but when we call "CoInitializeEx(nil, COINIT_MULTITHREADED) it fails.
Debugging shows that with multithreaded COM, the OnPrintingStarted event of the CPXCControl is never called, and if we use message-based communication the application never gets the pdfxcMsg_StartDoc message.
Hope you can help us with this problem.
Regards,
Arnstein
-
- Site Admin
- Posts: 8203
- Joined: Tue Jun 29, 2004 10:34 am
- Location: Vancouver Island - Canada
- Contact:
Hi,
Could you please provide us with the sample application you have created and any supporting additional files/instructions we may require to run and test here - please provide both compiled exe's' & dll's etc and source code for the project to allow us to modify if required.
Please zip any files uploaded - or emailed directly to us (usrfiles@tracker-software.com) also if posting here - please ensure your license codes are not included for general viewing.
Also please briefly outline the environment/system this is to be run on and Windows OS's in use.
thanks.
Could you please provide us with the sample application you have created and any supporting additional files/instructions we may require to run and test here - please provide both compiled exe's' & dll's etc and source code for the project to allow us to modify if required.
Please zip any files uploaded - or emailed directly to us (usrfiles@tracker-software.com) also if posting here - please ensure your license codes are not included for general viewing.
Also please briefly outline the environment/system this is to be run on and Windows OS's in use.
thanks.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 29
- Joined: Fri Feb 18, 2005 2:23 pm
- Location: Trondheim, Norway
- Contact:
PDF-XChange / Multithreaded COM
Please find attached a Delphi test project.
The program opens a document in Microsoft Word and prints it to PDF. It uses a DLL to do the actual communication with PDF-XChange. Please let me know if you need the source code for the DLL too.
Thanks,
Arnstein
The program opens a document in Microsoft Word and prints it to PDF. It uses a DLL to do the actual communication with PDF-XChange. Please let me know if you need the source code for the DLL too.
Thanks,
Arnstein
- Attachments
-
- DIPrintTest.zip
- Delphi test project + DIPDF.DLL
- (281.74 KiB) Downloaded 130 times
-
- Site Admin
- Posts: 8203
- Joined: Tue Jun 29, 2004 10:34 am
- Location: Vancouver Island - Canada
- Contact:
Hi,
Please do provide the source code for the DLL too - in the meantime I will ask our in-house Delphi Project dev to take a look at the project provided to date.
thanks.
Please do provide the source code for the DLL too - in the meantime I will ask our in-house Delphi Project dev to take a look at the project provided to date.
thanks.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 29
- Joined: Fri Feb 18, 2005 2:23 pm
- Location: Trondheim, Norway
- Contact:
Will do, but since this is part of our commercial products I would prefer to send it directly to you rather than posting it in this forum. Is that possible?Tracker Support wrote:Hi,
Please do provide the source code for the DLL too - in the meantime I will ask our in-house Delphi Project dev to take a look at the project provided to date.
thanks.
Thanks,
Arnstein
-
- Site Admin
- Posts: 8203
- Joined: Tue Jun 29, 2004 10:34 am
- Location: Vancouver Island - Canada
- Contact:
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- Site Admin
- Posts: 8203
- Joined: Tue Jun 29, 2004 10:34 am
- Location: Vancouver Island - Canada
- Contact:
Hi Arnstein,
Our project manager has now looked at this and advises that when using the ActiveX you should not use
CoInitializeEx(nil, COINIT_MULTITHREADED)
but should use
CoInitializeEx(nil, COINIT_APARTMENTTHREADED)
Unfortunately we could not rebuild and test your DLL as we are missing some project files - the first of which is ConfirmPasswordDialog.pas and most likely others ?
I hope the above helps.
Our project manager has now looked at this and advises that when using the ActiveX you should not use
CoInitializeEx(nil, COINIT_MULTITHREADED)
but should use
CoInitializeEx(nil, COINIT_APARTMENTTHREADED)
Unfortunately we could not rebuild and test your DLL as we are missing some project files - the first of which is ConfirmPasswordDialog.pas and most likely others ?
I hope the above helps.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 29
- Joined: Fri Feb 18, 2005 2:23 pm
- Location: Trondheim, Norway
- Contact:
I'm sending the missing files (ConfirmPasswordDialog) to you by email.
We have tried using apartment threading, and the communication with PDF-XChanage works well under this threading model. Unfortunately, the rest of our application doesn't, it demands multithreading.
What can we do to fix this? I suppose we could make a separate .exe to handle printing, but this means a lot of work for us as our application prints both using Microsoft Word and QuickReport (which gets data from various data sources).
Thanks,
Arnstein
We have tried using apartment threading, and the communication with PDF-XChanage works well under this threading model. Unfortunately, the rest of our application doesn't, it demands multithreading.
What can we do to fix this? I suppose we could make a separate .exe to handle printing, but this means a lot of work for us as our application prints both using Microsoft Word and QuickReport (which gets data from various data sources).
Thanks,
Arnstein
-
- Site Admin
- Posts: 8203
- Joined: Tue Jun 29, 2004 10:34 am
- Location: Vancouver Island - Canada
- Contact:
Thanks Arnstein,
Unfortunately the received zip file when saved to disk here was corrupt - could you please re-send and as soon as received, will ask our Project Dev for Delphi to look into and advise.
Unfortunately the received zip file when saved to disk here was corrupt - could you please re-send and as soon as received, will ask our Project Dev for Delphi to look into and advise.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 29
- Joined: Fri Feb 18, 2005 2:23 pm
- Location: Trondheim, Norway
- Contact:
I have now made a simpler Delphi test project. It contains one form, and on this form I place a TCPXCControl (the PDF-XChange ActiveX control).
In the initialization code I initialize COM multithreaded:
"CoInitializeEx(nil, COINIT_MULTITHREADED);"
During startup, when the program tries to create the main form (the form with the ActiveX-control) the program fails with the following exception:
"EOleError: Could not obtain OLE control window handle". This occurs in the TOleControl.HookControlWndProc method in unit OleCtrls, which is part of Delphi VCL, and the program terminates.
The statement that fails is this: "FOleInPlaceObject.GetWindow(WndHandle)". It returns WndHandle=0, and this triggers an exception in the next statement.
In other words: The program fails before any of our printing code is executed, the only code that I have written in this test project is the call to CoInitialize.
If I change COM initialization to singlethreaded the program works fine, but as I said earlier we have to run our program multithreaded for other reasons so this is not an option.
At the moment, I'm not able to see what we can do to avoid this. Any help would be greatly appreciated.
My development machine runs Windows XP SP2 and I use Delphi 7.
Thanks,
Arnstein
In the initialization code I initialize COM multithreaded:
"CoInitializeEx(nil, COINIT_MULTITHREADED);"
During startup, when the program tries to create the main form (the form with the ActiveX-control) the program fails with the following exception:
"EOleError: Could not obtain OLE control window handle". This occurs in the TOleControl.HookControlWndProc method in unit OleCtrls, which is part of Delphi VCL, and the program terminates.
The statement that fails is this: "FOleInPlaceObject.GetWindow(WndHandle)". It returns WndHandle=0, and this triggers an exception in the next statement.
In other words: The program fails before any of our printing code is executed, the only code that I have written in this test project is the call to CoInitialize.
If I change COM initialization to singlethreaded the program works fine, but as I said earlier we have to run our program multithreaded for other reasons so this is not an option.
At the moment, I'm not able to see what we can do to avoid this. Any help would be greatly appreciated.
My development machine runs Windows XP SP2 and I use Delphi 7.
Thanks,
Arnstein
-
- Site Admin
- Posts: 8203
- Joined: Tue Jun 29, 2004 10:34 am
- Location: Vancouver Island - Canada
- Contact:
Hi Arnstein,
Later this month we will change the ActiveX from being a DLL to an Exe and we believe this will resolve this issue - we do not think there is any other way to satisfy your need without causing other issues.
Thanks for your patience.
Later this month we will change the ActiveX from being a DLL to an Exe and we believe this will resolve this issue - we do not think there is any other way to satisfy your need without causing other issues.
Thanks for your patience.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 29
- Joined: Fri Feb 18, 2005 2:23 pm
- Location: Trondheim, Norway
- Contact:
-
- Site Admin
- Posts: 8203
- Joined: Tue Jun 29, 2004 10:34 am
- Location: Vancouver Island - Canada
- Contact:
Hi,
I am afraid it is not yet available as we are altering the JPEG2000 decoding encoding to resolve some important Viewing issues - until this is complete the ActiveX will not be released.
Thanks for your patience.
I am afraid it is not yet available as we are altering the JPEG2000 decoding encoding to resolve some important Viewing issues - until this is complete the ActiveX will not be released.
Thanks for your patience.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com