Link to home
Start Free TrialLog in
Avatar of hrolsons
hrolsonsFlag for United States of America

asked on

webbrowser causing cursor to disappear

On a form, I have a textbox, and a webbrowser control, which has google loaded up.

I click in my textbox and I have a nice flashing cursor.

I click in a black space in the webbrowser, then click in my textbox, and there is no blinking cursor, but I can type into that textbox.

Any ideas?  I've been working on this bug forever now.
Avatar of Carlos Villegas
Carlos Villegas
Flag of United States of America image

Hello, try add this to your form:
    Private Sub Form1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseEnter
        Cursor = Cursors.Default
    End Sub

Open in new window

Oh, is this VB classic?
Avatar of hrolsons

ASKER

Yes, VB6
Ok, can you try this instead?
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Screen.MousePointer = MousePointerConstants.vbDefault
End Sub

Open in new window

Didn't work, yv989c
I'm working on it, I know what the problem is ;) I will let you know when I got something.
Hello buddy!
In a form add a webbrowser control named WebBrowser1, and some textboxes to play, use this code on it:
Private Sub Form_Load()
    WebBrowser1.Navigate2 "www.google.com"
End Sub

Private Sub WebBrowser1_LostFocus()
    Dim ac As Control
    Set ac = Me.ActiveControl
    Me.SetFocus
    If Not ac Is Nothing Then
        If ac.Enabled And ac.Visible Then
            ac.SetFocus
        End If
    End If
End Sub

Open in new window

I hope this work for you.
Looks like it's close.  Still having a problem when WebBrowser1 loses focus to WebBrowser2.
Easy bro, add:
Private Sub WebBrowser2_LostFocus()
    Dim ac As Control
    Set ac = Me.ActiveControl
    Me.SetFocus
    If Not ac Is Nothing Then
        If ac.Enabled And ac.Visible Then
            ac.SetFocus
        End If
    End If
End Sub

Open in new window

No, click on webbrowser1 and then click on webbrowser2 and an error will happen.

"Object doesn't support this property or method"
what code line?
ASKER CERTIFIED SOLUTION
Avatar of Carlos Villegas
Carlos Villegas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I see your "On Error Resume Next"

Would I need "On Error goto 0" at the end of the sub, or does it default back to that for the rest of my code after the sub ends?
I don't remember very well, I don't think so, but to be sure, add a command button and raise an error, like this: Err.Raise
If the error is throw then its fine.
I don't think that you need the On Error goto 0 at the end
It didn't show the error.
If I press the button twice it does come up.  It's almost like the first click you make after a webbrowser, doesn't work.  You fixed my first problem though, so I'll move on.  Thank You.
Thanks buddy, but now I see that it is more simple:
Private Sub WebBrowser1_LostFocus()
    On Error Resume Next
    Me.SetFocus
End Sub

Open in new window

Just make use of this code, it still a little buggy, but this fix your cursor problem.