Using the WebBrowser control

Started by J P Eskdale, October 30, 2013, 09:35:19 AM

Previous topic - Next topic

J P Eskdale

I managed OK to put a webbrowser control into the project using a fixed web address but I need the application to dynamically change the url that is used.  I need to change the url depending upon the event that is selected.  Is this possible?  I spent about an hour looking but couldn't find a way - so thought I would ask if anyone could point me in the right direction before looking further.

Thanks

Jon

Paul Squires

Here is code that I stole from Jose's forum (from his MDI WebBrowser example):

   Local  pIWebBrowser2 As IWebBrowser2       ' // Instance of the WebBrowser control
   Local  vUrl          As Variant            ' // URL
   Local  wszUrl        As wStringZ * %L_MAX_URL_LENGTH

   wszUrl = "http://www.planetsquires.com"
   
   ' // Get a reference to the WebBrowser control
   pIWebBrowser2 = OC_GetDispatch(HWND_FORM1_WEBBROWSER1)
   If IsObject(pIWebBrowser2) Then
      ' // Nevigate to the URL
      vUrl = wszUrl
      pIWebBrowser2.Navigate2 vUrl
      ' // Release the object reference
      pIWebBrowser2 = Nothing
   End If

Paul Squires
PlanetSquires Software

J P Eskdale

Brilliant - Thanks both Paul and Jose

That works nicely - love the way you can preset the zoom factor of the browser control as well and CTL Mousewheel zooms as well.

Thanks
Jon