ActiveX control hosted in a UserControl does not print nor print preview in Internet Explorer

Hello Everybody,

For my first post in the community I would like to share this to your kind attention.

First of all, the problem I'm reporting is not KB835847 - Your Windows Forms user control does not print and does not appear in Print Preview in Internet. I'm running .NET 1.1 SP1. It is something a little bit more subtle.

1. Using VS 2003 and ATL 7.0 I build a very simple ActiveX DLL. Just keep the default options in the wizard. This creates an ActiveX Control that just diplays "ATL 7.0 : DummyAx" for example. This also registers the ActiveX on the system.

2. Using VS 2003 I build a new "Windows Control Library". I add a new "User Control". In the control just put a static text and a text box. Now import the very simple ActiveX created above in the form.

3. Create a html web page the loads the control

<OBJECT CLSID="http:MyControl.dll#MyControl.MyControl"/>

4. Copy the web page along with the the control DLL and wrappers DLLs generated when importing the ActiveX in .NET to the root of the web server.

5. Don't forget to relax the .NET framework security to "full trust" to allow the interaction between .NET and the ActiveX.

6. Load the page in Internet Explorer 6.0 and everything shows OK: the static text, the text box and the ActiveX control are correctly shown.

7. File Menu -> Print Preview and... catastrophe - the static text and the text box are shown but the ActiveX control isn't. At the location of the control I simply see an empty space that might have the background color of the control but I'm not sure of the latest. Anyway the text displayed by the control is not shown.

Any help would be helpful.

Best Regards,

Joel.




Answer this question

ActiveX control hosted in a UserControl does not print nor print preview in Internet Explorer

  • zdrae

    Hi Nobugz,

    You got it. I missed that since when I instanciate the control directly in IE using

    <OBJECT clsid="CLSID:XXXXXX-XXX"/>

    it prints correctly and it is the "OnDraw" method which is called with a "non screen" DC.

    Anyway, Thanks a lot.

    Regards,

    Joel.



  • penninha

    I'm a little fuzzy on the details but believe that you need to respond to the WM_PRINT message. You're handed a device context handle (the printer's) in which you need to render your control image.


  • ActiveX control hosted in a UserControl does not print nor print preview in Internet Explorer