Results 1 to 5 of 5

Thread: POP up Blocked Help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Posts
    150

    Angry POP up Blocked Help

    hi Vb
    For Some Reason My Pop Up Blocker wont work
    but if i debug the application it will work for some reason please help me

    error code below:

    Code:
    ************** Exception Text **************
    System.InvalidCastException: Unable to cast object of type 'System.Windows.Forms.MouseEventArgs' to type 'System.ComponentModel.CancelEventArgs'.
       at WarezEditionBrowser.PopUpDialog._Lambda$__1(Object a0, EventArgs a1)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    And Here is my code For Pop Blocker

    Code:
    Imports System.Windows.Forms
    
    Public Class PopUpDialog
    
        Private Sub Yes_Button_Click(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Yes_Button.Click
            On Error Resume Next
            Me.DialogResult = System.Windows.Forms.DialogResult.Yes
            If System.Windows.Forms.DialogResult.Yes Then
    
                e.Cancel = True
    
            End If
    
    
        End Sub
    
        Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles No_Button.Click
            Me.DialogResult = System.Windows.Forms.DialogResult.No
            If System.Windows.Forms.DialogResult.No Then
                PopUpBlocked.Show()
    
            End If
            Me.Close()
        End Sub
     
    End Class
    Please Help Me It Works In debug Mode But Not When i release it get the error at the top
    thanks

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: POP up Blocked Help

    Get rid of that On Error Resume Next line - all that will do is hide errors from you and make it harder to troubleshoot problems like this... you should never use that in a .NET program.

    Anyway, the reason you get the error is because your Yes_Button_Click event handler has the wrong signature... you must have edited it or copied and pasted it from somewhere because VS will put the correct signature in for you automatically when you just double click the button that you want to edit the Click event handler for.
    Basically, you can get rid of the error you are getting by changing it to this:
    Code:
    Private Sub Yes_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Yes_Button.Click
            Me.DialogResult = System.Windows.Forms.DialogResult.Yes
    End Sub
    and then you need to check the DialogResult value returned from the place where you show this form, not from the form itself.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Posts
    150

    Re: POP up Blocked Help

    yes but the e.cancel true doesnt work then !! And I have copyed and pasted my coding cause my program broke lol

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: POP up Blocked Help

    Yes I know e.Cancel wont work then but it wont work in that button click event anyway, no matter what you do. What are you actually trying to achieve with that line?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Posts
    150

    Re: POP up Blocked Help

    Its cause ive made dialog box to ask the users would they want to allow pop ups if the dialog result is yes then e.cancel =false and if it was no then e.cancel = true but the dialog.vbs is on seperate form to the browser like any ideas or anything to help me resolve this matter

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