VB.net Gecko WebBrowser DocumentCompleted not compatible? - vb.net

I'm using GeckoBrowser, as I find it displays and loads pages faster than the native WebBrowser(IE). The only issue I'm having is when to tell the page has finished loading so I can then run more code.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
GeckoWebBrowser1.Navigate("http://www.google.com")
End Sub
Private Sub GeckoWebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles GeckoWebBrowser1.DocumentCompleted
Label1.Text = "YES"
End Sub
End Class
The error I get is "Method 'GeckoWebBrowser1_DocumentCompleted' cannot handle event 'DocumentCompleted' because they do not have a compatible signature.
I've tried changing 'WebBrowserDocumentEventArgs' to 'GeckoDocumentCompletedEventArgs' but that says 'Type - is not defined'.
Any suggestions would be greatly appreciated.

#jmcilhinney's solution worked, just used drop downs at the top.
All I really needed was to add Imports Gecko.Events at the top

Related

Cannot navigate to facebook.com from WebBrowser Tool in VB.NET

I tried to navigate to www.google.com and it worked, I even tried to navigate to www.yahoo.com and it still worked!
But when I tried to navigate to www.facebook.com it doesn't show anything.
Here's the code:
Public Class Simple
Private Sub Simple_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("https:\\www.facebook.com")
End Sub
End Class
The above code worked well but when I changed the parameter with "https:\www.facebook.com" it didn't work.
I don't know what is causing this?
Maybe it can't load javascript or something (just a guess)
Output when WebBrowser1.Navigate("https:\www.google.com")
Output when WebBrowser1.Navigate("https:\www.google.com")
WebBrowser is outdated which can cause issue with javascript and other newer libraries. I have just started to used GeckoFx which uses Firefox and not dependent on IE. Use Nuget Console "Install-Package Geckofx45 -Version 45.0.34"
Here's an example how to browse Facebook via GeckoFX
Private geckoWebBrowser As Gecko.GeckoWebBrowser
Private Sub WebView_Load(sender As Object, e As EventArgs) Handles MyBase.Load
InitializeBrowser()
End Sub
Private Sub InitializeBrowser()
Gecko.Xpcom.Initialize("Firefox")
geckoWebBrowser = New Gecko.GeckoWebBrowser()
geckoWebBrowser.Dock = DockStyle.Fill
Me.Controls.Add(geckoWebBrowser)
geckoWebBrowser.Navigate("https://www.facebook.com")
End Sub

Improve UI responsiveness on windows form application

I am currently working on a project and decided to create a user interface for it using visual studio with a windows forms application(Visual Basic).
The problem I'm facing is that the user interface doesn't respond as quickly and smoothly as I'd like it to.
Mainly, I am using pictures as buttons to make the user form look more modern.
However, when I hover my mouse over a "button" it takes a while until the "highlighted button" appears.
P1 is the picture of the "normal button" and P2 is the picture of the "highlighted button".
Here is the short code I have for now:
Public Class Main
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub PictureBox1_MouseHover(sender As Object, e As EventArgs) Handles P1.MouseHover
P1.Visible = False
P2.Visible = True
End Sub
Private Sub P2_MouseClick(sender As Object, e As MouseEventArgs) Handles P2.MouseClick
'Call cmdInit()
'Call cmdConnectRobot()
'Call cmdUnlock()
End Sub
Private Sub Main_MouseHover(sender As Object, e As EventArgs) Handles Me.MouseHover
If P2.Visible = True Then
P2.Visible = False
P1.Visible = True
End If
End Sub
Private Sub P4_Click(sender As Object, e As EventArgs) Handles P4.Click
End Sub
End Class
Another problem I'm facing is that when I call other subs, the user form becomes unresponsive while the sub is running.
I researched and found that I could implement multi threading or async tasks but I'm a bit lost and would be extremely grateful if someone could guide me or point me in the right direction.
Thanks in advance!!
In this case your UI is responsive, however the MouseHover event is only raised once the mouse cursor has hovered over the control for a certain amount of time (default is 400 ms), which is what is causing the delay.
What you are looking for is the MouseEnter event, which is raised as soon as the cursor enters ("touches") the control:
Private Sub P1_MouseEnter(sender As Object, e As EventArgs) Handles P1.MouseEnter
P1.Visible = False
P2.Visible = True
End Sub
You can then use that together with the MouseLeave event on the second picture box to switch back to the non-highlighted image:
Private Sub P2_MouseLeave(sender As Object, e As EventArgs) Handles P2.MouseLeave
P1.Visible = True
P2.Visible = False
End Sub
However switching picture boxes like this is not optimal. I recommend you to look into how you can use Application Resources, then modify your code to only switch the image that one picture box displays.
Here are the basic steps:
Right-click your project in the Solution Explorer and press Properties.
Select the Resources tab.
To add an image either:
a. Drag and drop the image onto the resource pane.
b. Click the arrow next to the Add Resource... button and press Add Existing File....
Now, in your code add this right below Public Class Form1:
Dim ButtonNormal As Image = My.Resources.<first image name>
Dim ButtonHighlighted As Image = My.Resources.<second image name>
Replace <first image name> and <second image name> with the names of your button images.
Now you only need one picture box for the button:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
P1.Image = ButtonNormal
End Sub
Private Sub P1_MouseEnter(sender As System.Object, e As System.EventArgs) Handles P1.MouseEnter
P1.Image = ButtonHighlighted
End Sub
Private Sub P1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles P1.MouseLeave
P1.Image = ButtonNormal
End Sub
I'll start by saying i'm not a programmer by trade, and i'm sure someone will point out better ways of doing these things, but in regards to the threading question it's fairly simple to implement.
Imports System.Threading
Public Class Form1
Dim WorkerThread As New Thread(AddressOf DoWork)
'WorkerThread' can be any name you like, and 'DoWork' is the name of the sub you want to run in the new thread, and is launched by calling:
WorkerThread.start()
However there is a catch, the new thread is not able to interact directly with the GUI, so you cannot change textbox text etc... I find the easiest way to get changes made to the GUI is to drag a timer onto your form, and have the new thread change variables (pre-defined just below Public Class Form1), then use the Timer1 Tick event to monitor the variables and update the GUI if there are any changes.

there is a loading cursor in visual studio build program, will not stop

I made a small program ( in visual studio 2013) that simply displays a label in Form1 and a message when closing it. However, when I open it, it has the loading cursor that never stops. Can anyone help me please?
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub PictureBox1_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Form_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim response As MsgBoxResult
response = MsgBox("Skype must be restarted.", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Confirm")
If response = MsgBoxResult.Ok Then
Me.Dispose()
End If
End Sub
End Class
Cause of Error?
Look, I can't clearly say what the error is, but I find, the two main things because of which you are getting the error are:
There is a background task in your computer who is generating this, or, your Visual Studio's Environment is taking too long to load it's features.
The second error may be that, your cursor is set to loading.
Steps to Overcome
You need to go to your form's properties and set the cursor property to default or whatever you want. This can do your work, if you are having the second problem.
You can set different cursor property for different controls.
I hope this helps!

Media Player won't do anything

My code looks to be right, but when I press button nothing happens. What am I doing wrong?
Code below:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
AxVLCPlugin21.playlist.add("C:\Users\Adminx\Downloads\The_Hobbit_Full_Length_Trailer_2_HD.mp4")
AxVLCPlugin21.playlist.play()
End Sub
End Class
Also in my toolbox the vlc things are written in Chinese. Is it meant to look like that (look at picture below)
I've figured what I was doing wrong
I needed to change:
AxVLCPlugin21.playlist.add("C:\Users\Adminx\Downloads\The_Hobbit_Full_Length_Trailer_2_HD.mp4")
To this:
AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/The_Hobbit_Full_Length_Trailer_2_HD.mp4")

How is it possible to parse the URL of the desired popup to the popup-form AND show hints/tooltips in the WebKit-Component?

I'm trying to use the WebKit-component (http://www.webkit.org/) in VB with the help of Visual Studio 2008.
This is running without problems, except for two following two issues:
1. Hints/Tooltips are not shown (e.g. as there usually will appear one if you stay with the mouse over the Google-logo)
2. If there's a popup-window, I don't know how to get the new desired URL.
I'm already working a few days on this matter and couldn't find any solution yet :(
Maybe you know a solution to this problem.
Cheers
Markus G.
P.S.: If you need more than the following Source Code to analyze the problem, then let me know ...
Source Code Form1
Imports System.IO
Imports WebKit
Public Class frmMain
Private _url As String
Private _mode As String
Private _popupUrl As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
On Error Resume Next
Dim bLogging As Boolean
setWindowAndBrowserSettings()
_url = "http://www.google.com"
browserComp.Navigate(_url)
End Sub
Private Sub setWindowAndBrowserSettings()
Me.Text = "Test - Browser"
Me.WindowState = FormWindowState.Maximized
browserComp.Dock = DockStyle.Fill
browserComp.Visible = True
End Sub
Private Sub browserComp_NewWindowCreated(ByVal sender As Object, ByVal e As WebKit.NewWindowCreatedEventArgs) Handles browserComp.NewWindowCreated
'frmPopup.WindowState = FormWindowState.Maximized
frmPopup.Text = "ixserv - POPUP"
frmPopup.popup.Navigate(_popupUrl)
frmPopup.Show()
End Sub
Private Sub browserComp_NewWindowRequest(ByVal sender As Object, ByVal e As WebKit.NewWindowRequestEventArgs) Handles browserComp.NewWindowRequest
e.Cancel = False
_popupUrl = browserComp.Url.ToString ' WHERE can I get the clicked URL? This is the old one of the remaining window
End Sub
End Class
Code Form2
Public Class frmPopup
End Class
Following popup/new-Window-Create-function works for me:
Private Sub browserComp_NewWindowCreated(ByVal sender As Object, ByVal e As WebKit.NewWindowCreatedEventArgs) Handles browserComp.NewWindowCreated
frmPopup.Text = "POPUP"
Dim popupBrowser As WebKit.WebKitBrowser
popupBrowser = e.WebKitBrowser
frmPopup.Controls.Add(popupBrowser)
frmPopup.Show()
End Sub
whereas frmPopup is a new form.
Before I tried this I already added the Webkit-component to the new form, which might had been the problem. I assume, the trick is, to create a new WebKitBrower-element that is directly connected to the argument e.WebkitBrowser instead of overloading an existing webkitbrowser-component in the form. Don't ask me for reasons for this now (I really don't know) :P
Oh, I should add that I used the Webkit.NET component. The same trick works also for the OpenWebkitSharp-wrapper
The hint-problem still remains ...