如何在Excel中很好地打印我的C ++ ActiveX控件?

时间:2022-09-01 14:31:43

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

我试图让我的ActiveX控件在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.

该控件是用C ++编写的。最初我使用Visual Studio 2005向导生成控件。我用一个简单的向导生成的控件测试了这个,以试验OnDraw函数,我发现即使是向导的控件也不能打印得很好。它似乎会剪掉控件的很大一部分 - 默认情况下会在中心呈现黑色轮廓和一些文本。

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

在我的ActiveX控件上调用函数IDataObject_GetData,然后创建一个元文件并呈现给它。

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

有谁知道如何让ActiveX控件很好地打印出来?或者,我们将赞赏有用信息的链接。

1 个解决方案

#1


2  

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.

Visual Studio 2005向导生成的OnDraw函数通过调用SelectClipRgn函数来设置剪切区域。正是这种裁剪设置导致ActiveX控件在打印时出现剪裁。注释掉代码会使ActiveX控件完美打印出来。注释掉代码似乎也没有引起任何其他问题 - 至少在我的情况下不是这样。

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.

我只能假设用于裁剪的任何坐标系与绘制到图元文件DC时使用的坐标系不兼容。

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

以下是我发现的有关打印ActiveX控件的有用信息的链接:

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

#1


2  

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.

Visual Studio 2005向导生成的OnDraw函数通过调用SelectClipRgn函数来设置剪切区域。正是这种裁剪设置导致ActiveX控件在打印时出现剪裁。注释掉代码会使ActiveX控件完美打印出来。注释掉代码似乎也没有引起任何其他问题 - 至少在我的情况下不是这样。

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.

我只能假设用于裁剪的任何坐标系与绘制到图元文件DC时使用的坐标系不兼容。

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

以下是我发现的有关打印ActiveX控件的有用信息的链接:

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