Tutorial :How can I make my C++ ActiveX control print nicely in Excel?



Question:

I am trying to get my ActiveX control to print out nicely in Excel.

The control is written in C++. Originally I generated the control using the Visual Studio 2005 wizard. I have tested this with a simple wizard generated control to experiment with the OnDraw function and I discovered that even a control straight out of the wizard doesn't print well either. It appears to clip out a large portion of the control - which by default renders a black outline and some text in the centre.

The function IDataObject_GetData is called on my ActiveX control which in turn creates a metafile and renders to it.

Does anyone know how to get an ActiveX control to print out nicely? Alternatively links to useful information will be appreciated.


Solution:1

After much head scratching I figured out the solution to my problem.

The OnDraw function generated by the Visual Studio 2005 wizard sets up a clipping region by calling the function SelectClipRgn. It was this clipping setup that was causing ActiveX control to appear clipped when printed. Commenting out the code makes the ActiveX control print out perfectly. Commenting out the code doesn't appear to cause any other problems either - at least not in my case.

I can only assume that whatever coordinate system is used for clipping is not compatible with the coordinate system used when drawing to a metafile DC.

Here are some links to useful info that I found about printing ActiveX controls:

http://www.codeproject.com/KB/COM/officeatlprint.aspx

http://www.codeproject.com/KB/COM/WirgerPrintArticle.aspx

http://support.microsoft.com/kb/81497

http://support.microsoft.com/kb/84984


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »