Private Sub Form_Load()
WebBrowser1.Navigate "http://community.csdn.net/Expert/TopicView1.asp?id=5081713"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If Not (pDisp Is WebBrowser1.Object) Then Exit Sub
WebBrowser1.Height = WebBrowser1.Document.body.scrollHeight * Screen.TwipsPerPixelY
WebBrowser1.Width = WebBrowser1.Document.body.scrollWidth * Screen.TwipsPerPixelX
WebBrowser1.Document.body.Scroll = "no"
End Sub
You'll probably want to make this more useful by obtaining the window information, such as the height and width, so that you can modify your view accordingly. A simple approach to this is to handle the BeforeNavigate2 event that is fired after the new window is created. Add the following code to your application to resize the view to the size of the new window. Note that this is an overridden method that allows access to the WebBrowser object, and that an additional Boolean member, m_bResizeWindow, is required. Set this to false in the constructor and true in the NewWindow2 event handler to ensure this code is only called for new windows.