Results 1 to 5 of 5

Thread: WebBrowser1_NewWindow2 ??? Cancel = True

Hybrid View

  1. #1

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Arrow WebBrowser1_NewWindow2 ??? Cancel = True

    Hy, i have this part of code:
    VB Code:
    1. Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    2. Cancel = True
    3. End Sub

    How do i change this option from a button? The NewWindow2 to be enabled. Thenx
    Last edited by RoYeti; May 7th, 2006 at 01:58 PM.

  2. #2
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: WebBrowser1_NewWindow2 ??? Cancel = True

    If you mean controlling the appearing of a new window I guess this would work:
    VB Code:
    1. Private Sub cmd1_Click()
    2.  
    3.     '0 = Not Blocking
    4.     '1 = Blocking
    5.     If cmd1.Tag = "0" Or cmd1.Tag = "" Then
    6.         cmd1.Caption = "Disable Blocking"
    7.         cmd1.Tag = "1"
    8.     Else
    9.         cmd1.Caption = "Enable Blocking"
    10.         cmd1.Tag = "0"
    11.     End If
    12.  
    13. End Sub
    14.  
    15. Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    16.  
    17.     If cmd1.Tag = "0" Or cmd1.Tag = "" Then
    18.         Exit Function
    19.     Else
    20.         Cancel = True
    21.     End If
    22.  
    23. End Sub

  3. #3

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Arrow Re: WebBrowser1_NewWindow2 ??? Cancel = True

    hmm... I want to do like this :
    VB Code:
    1. Private Sub Form_Load()
    2. timer1.interval=5000
    3. timer1.enabled=true
    4. End Sub
    5.  
    6. Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    7. Cancel = True
    8. End Sub
    9.  
    10. Private Sub Timer1_Timer()
    11. ' here i want to enable the NewWindow2
    12. timer1.enabled=false
    13. End Sub

    ideeas how to to that ?

  4. #4
    Addicted Member
    Join Date
    Apr 2006
    Posts
    155

    Re: WebBrowser1_NewWindow2 ??? Cancel = True

    Put this API Function in your General Declarations:

    VB Code:
    1. Private Declare Function GetTickCount Lib "kernel32" () As Long

    Put this on your form:

    VB Code:
    1. Function Wait(seconds As Long) As Boolean
    2.     Dim tick As Long, tick2 As Long, Num As Long
    3.         Num& = seconds& * 1000
    4.             tick& = GetTickCount()
    5.             tick2& = GetTickCount()
    6.     Do Until tick2& - tick& >= Num&
    7.             tick2& = GetTickCount()
    8.         DoEvents
    9.     Loop
    10. End Function

    Ex:
    VB Code:
    1. Wait 5 'This will wait 5 seconds before loading new window

    VB Code:
    1. Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    2.  Wait 5
    3.     Debug.Print "Done, now loading New Window..."
    4. End Sub

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: WebBrowser1_NewWindow2 ??? Cancel = True

    Do you want something like this ?
    VB Code:
    1. Option Explicit
    2. Private bNoNewWindow As Boolean
    3. '---------------------------------------------------------
    4. Private Sub Command1_Click()
    5.  
    6. bNoNewWindow = Not bNoNewWindow
    7.  
    8. If bNoNewWindow Then
    9.     Command1.Caption = "Allow New Window"
    10. Else
    11.     Command1.Caption = "Disable New Window"
    12. End If
    13.  
    14. End Sub
    15. '---------------------------------------------------------
    16. Private Sub Form_Load()
    17.  
    18.     Command1.Caption = "Disable New Window"
    19.  
    20. End Sub
    21. '---------------------------------------------------------
    22. Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    23.    
    24.     Cancel = bNoNewWindow
    25.    
    26. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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