|
-
Apr 25th, 2001, 03:55 PM
#1
Thread Starter
New Member
webbrowser control's history
anyone know how you can detect whether there are any pages in the webbrowser control's history so that i can enable/disable the back/forward buttons?
-
Apr 25th, 2001, 05:18 PM
#2
Try this:
Code:
Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
On Error Resume Next
Select Case Command
Case CSC_NAVIGATEFORWARD
If Enable = True Then
'Forward dispo
ForwardEnable = True
RaiseEvent ForwardUpdate(True)
Else
'Forward non dispo
ForwardEnable = False
RaiseEvent ForwardUpdate(False)
End If
'Pas de forward
Case CSC_NAVIGATEBACK
If Enable = True Then
BackEnable = True
RaiseEvent BackUpdate(True)
'Back dispo
Else
BackEnable = False
RaiseEvent BackUpdate(False)
'Back non dispo
End If
End Select
If Command = -1 Then Exit Sub
'End If
End Sub
-
Apr 25th, 2001, 05:22 PM
#3
or this....SHorter...faster...better...Stronger!....(oh wait...that's the Bionic Man )
Code:
Private Sub WB_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
On Error Resume Next
DoEvents
If Enable = True And Command = CSC_NAVIGATEBACK Then
cmdBack.Enabled = True
Elseif Enable = False And Command = CSC_NAVIGATEBACK Then
cmdBack.Enabled = False
End If
If Enable = True And Command = CSC_NAVIGATEFORWARD Then
cmdFwd.Enabled = True
Elseif Enable = False And Command = CSC_NAVIGATEFORWARD Then
cmdFwd.Enabled = False
End If
End Sub
VBBrowser v2.2.1
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 25th, 2001, 10:47 PM
#4
Frenzied Member
Shorter Yet
Code:
Private Sub WebBrowser_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
Select Case Command
Case CSC_NAVIGATEBACK
Back.Enabled = Enable
Case CSC_NAVIGATEFORWARD
Forward.Enabled = Enable
End Select
End Sub
Last edited by Bloodeye; Apr 25th, 2001 at 10:51 PM.
-
Apr 26th, 2001, 07:20 AM
#5
Thread Starter
New Member
ah ha! thanks guys
-
Apr 26th, 2001, 09:28 AM
#6
Bloodeye...Then your buttons will never be disabled?
The frwd button in particular...
sometimes it should be.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 26th, 2001, 10:02 AM
#7
Frenzied Member
geoff -
I forgot to tell you that you need to start with the "Back" and "Forward" buttons disabled.
I got the my above example from Microsoft. The VB code is at the bottom of the example...difficult to see because the format is all garbled up. I noticed they don't mention anything about haveing the buttons disabled...I must have picked that up somewhere else.
Here's the code that I use. Pretty much the same as the MS example.
Code:
Private Sub brwWb_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
If Command = 2 Then
cmdNav(0).Enabled = Enable
End If
If Command = 1 Then
cmdNav(1).Enabled = Enable
End If
End Sub
-
Apr 26th, 2001, 10:11 AM
#8
i was just wondering how it would reacte when:
u use the back button...then the frwd btn is enabled...
if you then click forward...the frwd button should then be disabled again.
?? will that happen?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 26th, 2001, 11:25 AM
#9
Frenzied Member
Everything works fine for me.
Keep in mind that you need to start with both buttons disabled. Then the CommandStateChange event indicates when either button should be enabled or disabled from the (ByVal Enable as Boolean) operator. "Enable" can be either True of False.
-
Apr 26th, 2001, 11:45 AM
#10
<HOMER> DOH! </HOMER>
Omg...ok..that must be one of the most obvious things I have overlooked. 
thanks for the wake up slap Bloodeye...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|