I've read bunch of Q&As but none helped me.
I'm using VB.net; added awesomium browser control on the form. I need to be able to change its proxy server on the fly (example: User clicks a button to change proxy IP & port). Would it be possible? If not maybe I could create a dynamic awesomium browser control and than add it to the form (also on button click). But still don't know how to initialize control with the proxy.
If I cannot change it while running that is fine. Can I read proxy from some file and than initialize control with that proxy?
Nevermind - below worked for me:
Dim prefs As WebPreferences = New WebPreferences()
prefs.ProxyConfig = txtProxy.Text
Dim session As WebSession = WebCore.CreateWebSession(prefs)
Dim webcontrol As WebControl = New WebControl()
webcontrol.WebSession = session
Me.panWeb.Controls.Add(webcontrol)
webcontrol.Dock = DockStyle.Fill
webcontrol.Source = New Uri(txtURL.Text)
webcontrol.Visible = True
Related
I am using in a WinForm an object of type:
CefSharp.WinForms.ChromiumWebBrowser
Everything is working fine but I am having an issue when I try to change the ZoomLevel with SetZoomLevel method:
If oBrowser.IsBrowserInitialized Then
oBrowser.SetZoomLevel(-2.0)
Dim frame As CefSharp.IFrame = oBrowser.GetMainFrame
Dim request As CefSharp.IRequest = frame.CreateRequest()
request.Url = url
request.Method = "POST"
request.InitializePostData()
Dim element = request.PostData.CreatePostDataElement()
element.Bytes = postDataBytes
request.PostData.AddElement(element)
request.Headers = headers
frame.LoadRequest(request)
End If
The first time I open the WinForm the Zoom level doesn't change, while it works correctly from the 2nd refresh.
Am I missing some initialization and/or method call... Or do I have to call this method in another position?
Note: the CEFSharp DLL version is 63.0.3.0.
The .NET Framework is 4.5.2
EDITED 01.06.2018: I've found a solution (see below) but now there's another problem: the zoom change is made when the browser is already visible, so it's not nice for the final user to see the page size changing during the form load.
Has anyone a suggestion to freeze the layout during zoom change? Please note that .SuspendLayout() and .ResumeLayout() are not working.
I've found a way to answer my own question. I post it here as it could be useful to other users.
You must add a LoadingStateChanged handler to the ChromiumWebBrowser object:
AddHandler oBrowser.LoadingStateChanged, AddressOf WebBrowserOnLoadingStateChanged
The method would be then something like:
Private Sub WebBrowserOnLoadingStateChanged(ByVal sender As Object, ByVal loadingStateChangedEventArgs As LoadingStateChangedEventArgs)
Dim oBrowser As WinForms.ChromiumWebBrowser = CType(sender, WinForms.ChromiumWebBrowser)
If Not oBrowser.IsLoading Then
oBrowser.SetZoomLevel(-2.0)
End If
End Sub
This solution works good in my environment but now there's another problem: the zoom change is made when the browser is already visible, so it's not nice for the final user to see the Zoom Level changing during the form load.
I have a situation in which I have a aspx page ,that hit on schedule ,all my logic is written in this page.I want that while this page is hit on schedule time,no console window or page that was hit,will not show up.what I have done to hide console window ,
1.just change it to window application output in application setting.
2.and to start aspx page
Dim url As String = ""
url = ConfigurationManager.AppSettings("www.youtube.com")
Process.Start(url)
But Problem is when that page is hit using this code ,that page open up in browser?
if you any logic written in web page code behind that you need to execute from many places, ideally you should move that to a common library project accessible to all other projects.
I am not much clear why we need to execute a web page from console, still you can use WebRequest and WebResponse classes to get the output of the web page without opening in browser.
Dim _request As WebRequest = WebRequest.Create("www.youtube.com")
_request.GetResponse()
Old Answer
using _response As WebResponse = _request.GetResponse()
Using _reader As New StreamReader(_response.GetResponseStream())
Dim _html As String = _reader.ReadToEnd()
End Using
End Using
here is a simple code to run a page without open it in browser.
Dim url As String = ""
url = ConfigurationManager.AppSettings("url")
Dim client As New WebClient
client.DownloadString(url)
client.Dispose()
I am using a class supplied with VFP that uses the IE7 control _webview to open up a web browser and it does not have a function to add a new tab withen the browser , if I am clicking on link in a current page it will open it in IE , is there a way that the new page should open up on the foxpro browser ,
and How can I add a new tab in the browser for a new search
also is there a class that will open up a web browser in foxpro based on a more updated internet broweser
There is no tab in the control. you need to create new tabs in response of the NewWindow2 event from the webbrowser control, put a new webbrowser control on the tab, then tell the event that the new webbrowser control should be used to display the new window. Your event handler looks like this:
LPARAMETERS ppdisp, cancel
*creating new tab
newTab.ADDOBJECT("Olecontrol1", "OLEControl", "shell.explorer.2")
With newTab
.olecontrol1.Top = 0
.olecontrol1.Width = .Width
.olecontrol1.Left = 0
.olecontrol1.Height = .Height
.olecontrol1.visible = .T.
.olecontrol1.RegisterAsBrowser = .T.
.Visible = .T.
Endwith
ppDisp = newTab.olecontrol1.Object
By default the webbrowser control operates in IE7 mode. To opt-in to a new version, add a FEATURE_BROWSER_EMULATION registry key in your program's installer.
I use CDHtmlDialog to work with DOM of some HTML content from given URLs. I need to disable all possible popup messages (e.g Security alerts) that can appear as in case of InternetExplorer Browser. In JScript I can set property Silent to true
var oIE = WScript.CreateObject("InternetExplorer.Application","EventIE_");
oIE.Silent = true;
and that's work! How to get same behaviour in CDHtmlDialog?
Thanks
I found the solution!
m_pBrowserApp->put_Silent(VARIANT_TRUE);
I've got a VB.NET class that is invoked with a context menu extension in Internet Explorer.
The code has access to the object model of the page, and reading data is not a problem. This is the code of a test function...it changes the status bar text (OK), prints the page HTML (OK), changes the HTML by adding a text and prints again the page HTML (OK, in the second pop-up my added text is in the HTML)
But the Internet Explorer window doesn't show it. Where am I doing wrong?
Public Sub CallingTest(ByRef Source As Object)
Dim D As mshtml.HTMLDocument = Source.document
Source.status = "Working..."
Dim H As String = D.documentElement.innerHTML()
MsgBox(H)
D.documentElement.insertAdjacentText("beforeEnd", "ThisIsATest")
H = D.documentElement.outerHTML()
MsgBox(H)
Source.status = ""
End Sub
The function is called like this from JavaScript:
<script>
var EB = new ActiveXObject("MyObject.MyClass");
EB.CallingTest(external.menuArguments);
</script>
To the best of my understanding, in order to use insertAdjacentText or any of the other editing methods, the document object should be in the design mode.
In design mode you can edit the document freely, and so can the user.
Check this site for more details
I do not think that Alex is right, something else is the matter.
When I tried to do something like that, insertBefore would not work for me, but appendChild worked just fine, so adding an element is possible.
I worked in Javascript, but I don't expect that makes a difference.