I'm making a webbrowser and need to make buttons for the scroll functions. (up, down, left, right).
I can not figure out how to make them.
Can someone please help.
Lars
Printable View
I'm making a webbrowser and need to make buttons for the scroll functions. (up, down, left, right).
I can not figure out how to make them.
Can someone please help.
Lars
I am not sure why you need to put scroll buttons on yourself. If you navigate to a page like in the example below the scroll bars will appear automatically on the webbrowser control.
Code:WebBrowser1.Navigate ("http://www.microsoft.com")
Oh.
It's because I'm making a touch screen application, and I need separat buttons for this.
Lars
You can use SendKeys.
Code:Private Sub Command1_Click()
Webbrowser1.SetFocus
SendKeys "{UP}"
End Sub
Private Sub Command2_Click()
Webbrowser1.SetFocus
SendKeys "{DOWN}"
End Sub
Private Sub Command3_Click()
Webbrowser1.SetFocus
SendKeys "{LEFT}"
End Sub
Private Sub Command4_Click()
Webbrowser1.SetFocus
SendKeys "{RIGHT}"
End Sub
Thank you Matthew!
Yes this looks good, and is similar to what I figured out, but I still have two problems.
1.
On som html-pages Mr. Setfocus doesn't his job. I often have to put the cursor in the web myself before I can scroll.
2.
I'd like to have the scroll on the mousedown so that it scrolls as long as I hold the button in, and stops on mouseup. I have tried a getTickcount method, but I'm not to familiar with it.
Anyone have any ideas?
Lars
What you want to do is purdy simple :rolleyes:.
Code:Dim MouseUp As Boolean
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MouseUp = False Then
Webbrowser1.SetFocus
Do
DoEvents
SendKeys "{UP}", True
Loop Until MouseUp = True
End If
If MouseUp = True Then MouseUp = False
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseUp = True
End Sub
Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MouseUp = False Then
Webbrowser1.SetFocus
Do
DoEvents
SendKeys "{DOWN}", True
Loop Until MouseUp = True
End If
If MouseUp = True Then MouseUp = False
End Sub
Private Sub Command2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseUp = True
End Sub
Private Sub Command3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MouseUp = False Then
Webbrowser1.SetFocus
Do
DoEvents
SendKeys "{LEFT}", True
Loop Until MouseUp = True
End If
If MouseUp = True Then MouseUp = False
End Sub
Private Sub Command3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseUp = True
End Sub
Private Sub Command4_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MouseUp = False Then
Webbrowser1.SetFocus
Do
DoEvents
SendKeys "{RIGHT}", True
Loop Until MouseUp = True
End If
If MouseUp = True Then MouseUp = False
End Sub
Private Sub Command4_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseUp = True
End Sub
Thanxs Matthew!
The code looks great, but we need to set MouseUp to false somewhere so that the browser scrolls, don't we?
Lars
MouseUp is set to false.
Code:'Private Sub Command_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'If MouseUp = False Then
'Webbrowser1.SetFocus
'Do
'DoEvents
'SendKeys "{....}", True
'Loop Until MouseUp = True
'End If
If MouseUp = True Then MouseUp = False
'End Sub
All of the code I gave works. I tested it before I posted :rolleyes:.