Load webbrowser content into another webbrowser control - vb.net

I have such situation:
1) One form named 'frm_iexplorer' with webbrowser and loaded document into it.
2) One class named 'PrintHTMLDocument' which creates webbrowser dynamically.
I would like to load a same document into second, dynamically created webbrowser from first webrowser.
My approach in class is like:
Dim ie As New InternetExplorer
ie.Navigate(frm_iexplorer.WebBrowser1.document())
... don't work.
frm_iexplorer is not accessible.
How to do this?

Related

VB.NET - Navigating without loading another form

I'm currently developing a simple enrollment system for our school project. I have multiple modules that when clicked will open a new form with another set of sub modules.
However, I hate how forms load every time I open a new form. Is there like a way that when I clicked say for example "Enrollment" button, instead of loading a new form, it will change all the controls instead. Tried using User Control but it keeps crashing my program down after I created 2 user controls and load them in one form.
Main Form;
Enrollment Sub Form
Please help me guys.
As LarsTech mentioned I would use user controls instead of forms.
Each user control would be setup the same way as your form is, but can be loaded to a panel on the main form, allowing for a single form to show all content.
Dim myControl = New ControlYouCreated
panel1.Controls.Add(myControl)
myControl.bringtofront
This for example, will bring in the contents of the user control you created, into your form1 panel.

How to create simple browser with Mozilla ActiveX Control with VB.NET?

I download and install Mozilla ActiveX Control
and add MozillaBrowser Class to ToolBox
Create a windows form application windows, drag drop MozillaBrowser from ToolBox to Form1
also drag drop a WebBrowser1 to Form1
in Form1_Load write this:
WebBrowser1.ActiveXInstance = AxMozillaBrowser1
but Error Property 'ActiveXInstance' is 'ReadOnly'.
I want display a fix URL in Mozilla browser, Now I must what to do?
As I understand it this control is a direct replacement for the WebBrowser control so you should just add an instance of the control on your form and then something like this should work:
AxMozillaBrowser1.Navigate2("http://www.bbc.co.uk")
have a look at this wrapper which may help you on code project: http://www.codeproject.com/Articles/20312/Browsers-Wrapper-Mozilla-IE

Download file from WebBrowser Control via WebClient

I am using webBrowser control to login and fetching download link from an anchor tag. The link contains a dynamically generated .csv file (even this file is not accessible without login).
My download code looks like
Dim rLink = curElement.GetAttribute("href").ToString()
Dim myWebClient As New WebClient()
myWebClient.Headers.Add(HttpRequestHeader.Cookie, WebBrowser1.Document.Cookie)
myWebClient.DownloadFile(rLink, "report.csv")
Above code fires on DocumentCompleted event

Copy image from webbrowser to clipboard

I need to copy an image from a webbrowser control to my clipboard, because the image changes on every reload, and I tried to get the "src"-attribute and changing my picturebox.imagelocation to that, but the image on the picturebox differed from the picture on the webbrowser control.
I'm trying to automate a web service, and it requires a captcha to be filled out, and it changes every time the page is loaded, that's why I need to get the one that is currently displayed.
Assuming you are using Windows Forms (need to change the way to get document if you use WPF) and the user did not block clipboard access in IE zone settings
Dim doc As IHTMLDocument2 = DirectCast(webBrowser1.Document.DomDocument, IHTMLDocument2)
Dim body As IHTMLElement2 = DirectCast(doc.body, IHTMLElement2)
Dim imgRange As IHTMLControlRange = DirectCast(body.createControlRange(), IHTMLControlRange)
Dim image As IHTMLControlElement = DirectCast(DirectCast(doc, IHTMLDocument3).getElementById(sImgID), IHTMLControlElement)
imgRange.add(image)
imgRange.execCommand("Copy", False, Nothing)
Pseudo code:
For each element by tag 'img'. Get the 'src' attribute. Fire up an instance of HttpWebRequest or use WebClient.DownloadFile for the source.
You will need to do some trickery determining where the source is in relation to the url. For instance the src could be '/img/pony.jpg', in which case you'll need to get the url's root from the WebBrowser control to make it 'http://mylittle.com/img/pony.jpg'.

How can I open an external browser window and refresh it inside a VB.net application?

We have an existing VB.net application. Upon an event, we need to open a browser window. I'm able to open the browser window like this:
System.Diagnostics.Process.Start("http://s3web01/suggestions?item=" + strItem + "&co=" + strOrder)
Upon another event, we need to refresh the browser window with different parameters for strItem and strOrder.
If I call the same code above, it opens a new tab in the browser window. Is there any way to refresh the same browser window that was previously opened?
Add a reference to the following COM libraries: Microsoft Internet Controls (namespace ShDocVw), and Microsoft HTML Object Library (namespace mshtml).
Then you can create a new IE instance:
Dim IE As ShDocVw.InternetExplorer = New ShDocVw.InternetExplorer
and control it like so: IE.Navigate("http://blah.com")
refresh it like so: IE.Refresh
etc