Uncategorized

Windows Control Library does not resize correctly if you change IE window size

 


Hosting a Windows Control Library control in an ASP.NET 2.0 page, the WCL does not resize correctly, if you change the size of the IE Window. The problem does not occur using .NET Framework 1.1

The problem is a regression in Visual Studio 2005 which prevents the .Net ActiveX implementation from asserting managed code privilege when calling IOleClientSite::OnPosRectChange. Since that call requires managed code execution privileges, it fails and the control cannot resize itself.

The workaround is to set the size of the control from the HTML rather than resizing it internally. For example, the onresize in the body tag in the following script does this:

<html>
<body onresize=”obj1.Width=document.body.clientWidth;”>
<div style=”width:100%;height:100%;background-color:blue”>
<OBJECT id=”obj1″ height=”90%” width=”90%”
classid=”MyResizeControl.dll#MyResizeControl.UserControl1″ VIEWASTEXT />
</div>
<br>
This is a long string for me to test the other space
</body>
</html>

Capitalization of the properties is important: capital “W” (Width) will correctly change the Width property of the internal .Net control; lowercase “w” (width) will change the property of the HTML object rather than the .Net object, and this will not work if the .Net object is 1.1.

 


Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.