Results 1 to 10 of 10

Thread: webbrowser control's history

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    7

    Wink 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?

  2. #2
    Matthew Gates
    Guest
    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

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    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"

  4. #4
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    7
    ah ha! thanks guys

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    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"

  7. #7
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    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

  8. #8
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    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"

  9. #9
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    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.

  10. #10
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    <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
  •  



Click Here to Expand Forum to Full Width