Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. MessageBox.Show not raising HelpRequested event

MessageBox.Show not raising HelpRequested event

Scheduled Pinned Locked Moved Visual Basic
questioncomdebugginghelptutorial
13 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Trevortni
    wrote on last edited by
    #1

    I have a form that is showing a MessageBox using MessageBox.Show, and trying to receive events from the Help button on the MessageBox so I can execute my own code. The Microsoft documentation shows how to do this; however, using what is suggested does not work. Here's a shortened version of my code:

    Private Function MethodName() As Boolean

    AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
    Select Case MessageBox.Show("Text", "Title", MessageButtons.YesNoCancel, _
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)
    Case MsgBoxResult.Yes
    ' Do stuff
    Case MsgBoxResult.No
    ' Do stuff
    Case MsgBoxResult.Cancel
    RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
    Return False
    End Select
    RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested

    End Function
    '
    '
    Private Sub MsgBoxHelpRequested(ByVal sender As Object, _
    ByVal hlpevent As System.Windows.Forms.HelpEventArgs)
    ' Breakpoint that never gets hit
    ' More code
    End Sub

    I posted this question yesterday on stackoverflow[^], where we get into quite a spirited discussion, with a bunch of suggestions that ultimately never seemed to pan out, if you want to see what I've already tried. Currently I'm working on seeing if there's any way to determine if the event was even raised in the first place - either by trying to manually raise the event and see if my code gets called, or seeing if there's any way to break on an event. Does anybody have any suggestions? Oh, and by the way, Chris Maunder: CodeProject is much better designed than StackOverflow. Reading stackoverflow is a pain on the eyes, trying to comment is a pain in the neck - coming back home here is such a relief. While the people over there are just as nice as here, I wish I had thought to check here yesterday.

    D W T 4 Replies Last reply
    0
    • T Trevortni

      I have a form that is showing a MessageBox using MessageBox.Show, and trying to receive events from the Help button on the MessageBox so I can execute my own code. The Microsoft documentation shows how to do this; however, using what is suggested does not work. Here's a shortened version of my code:

      Private Function MethodName() As Boolean

      AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
      Select Case MessageBox.Show("Text", "Title", MessageButtons.YesNoCancel, _
      MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)
      Case MsgBoxResult.Yes
      ' Do stuff
      Case MsgBoxResult.No
      ' Do stuff
      Case MsgBoxResult.Cancel
      RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
      Return False
      End Select
      RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested

      End Function
      '
      '
      Private Sub MsgBoxHelpRequested(ByVal sender As Object, _
      ByVal hlpevent As System.Windows.Forms.HelpEventArgs)
      ' Breakpoint that never gets hit
      ' More code
      End Sub

      I posted this question yesterday on stackoverflow[^], where we get into quite a spirited discussion, with a bunch of suggestions that ultimately never seemed to pan out, if you want to see what I've already tried. Currently I'm working on seeing if there's any way to determine if the event was even raised in the first place - either by trying to manually raise the event and see if my code gets called, or seeing if there's any way to break on an event. Does anybody have any suggestions? Oh, and by the way, Chris Maunder: CodeProject is much better designed than StackOverflow. Reading stackoverflow is a pain on the eyes, trying to comment is a pain in the neck - coming back home here is such a relief. While the people over there are just as nice as here, I wish I had thought to check here yesterday.

      D Offline
      D Offline
      DaveAuld
      wrote on last edited by
      #2

      Yes i have a suggestion; I placed a button on the form, and coded the following;

      Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      
          Dim response As MsgBoxResult = MsgBox("the prompt", MsgBoxStyle.MsgBoxHelp + MsgBoxStyle.Information + MsgBoxStyle.YesNo, "The Title")
      
          MsgBox(response)
      
      End Sub
      
      Private Sub FormMain\_HelpRequested(ByVal sender As Object, ByVal hlpevent As System.Windows.Forms.HelpEventArgs) Handles Me.HelpRequested
          MsgBox("help Requested")
      End Sub
      

      This displays a Yes No Help msgbox, when the help is pressed, another msgbox appears with the help requested. Based on this, what you could do is set a variable before entering the msgbox with some form of identifier, then in the HelpRequested call, check the value of that variable and perform the appropriate help action.

      Dave Don't forget to rate messages!
      Find Me On: Web|Facebook|Twitter|LinkedIn
      Waving? dave.m.auld[at]googlewave.com

      T 1 Reply Last reply
      0
      • D DaveAuld

        Yes i have a suggestion; I placed a button on the form, and coded the following;

        Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
            Dim response As MsgBoxResult = MsgBox("the prompt", MsgBoxStyle.MsgBoxHelp + MsgBoxStyle.Information + MsgBoxStyle.YesNo, "The Title")
        
            MsgBox(response)
        
        End Sub
        
        Private Sub FormMain\_HelpRequested(ByVal sender As Object, ByVal hlpevent As System.Windows.Forms.HelpEventArgs) Handles Me.HelpRequested
            MsgBox("help Requested")
        End Sub
        

        This displays a Yes No Help msgbox, when the help is pressed, another msgbox appears with the help requested. Based on this, what you could do is set a variable before entering the msgbox with some form of identifier, then in the HelpRequested call, check the value of that variable and perform the appropriate help action.

        Dave Don't forget to rate messages!
        Find Me On: Web|Facebook|Twitter|LinkedIn
        Waving? dave.m.auld[at]googlewave.com

        T Offline
        T Offline
        Trevortni
        wrote on last edited by
        #3

        Okay, I'm not sure why you're showing a second MsgBox to display the MsgBoxResult of the first one in the first function, but the second function doesn't help me because it's yet another variation of what I've been trying to do that I have already determined does not work for me.

        D 1 Reply Last reply
        0
        • T Trevortni

          I have a form that is showing a MessageBox using MessageBox.Show, and trying to receive events from the Help button on the MessageBox so I can execute my own code. The Microsoft documentation shows how to do this; however, using what is suggested does not work. Here's a shortened version of my code:

          Private Function MethodName() As Boolean

          AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
          Select Case MessageBox.Show("Text", "Title", MessageButtons.YesNoCancel, _
          MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)
          Case MsgBoxResult.Yes
          ' Do stuff
          Case MsgBoxResult.No
          ' Do stuff
          Case MsgBoxResult.Cancel
          RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
          Return False
          End Select
          RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested

          End Function
          '
          '
          Private Sub MsgBoxHelpRequested(ByVal sender As Object, _
          ByVal hlpevent As System.Windows.Forms.HelpEventArgs)
          ' Breakpoint that never gets hit
          ' More code
          End Sub

          I posted this question yesterday on stackoverflow[^], where we get into quite a spirited discussion, with a bunch of suggestions that ultimately never seemed to pan out, if you want to see what I've already tried. Currently I'm working on seeing if there's any way to determine if the event was even raised in the first place - either by trying to manually raise the event and see if my code gets called, or seeing if there's any way to break on an event. Does anybody have any suggestions? Oh, and by the way, Chris Maunder: CodeProject is much better designed than StackOverflow. Reading stackoverflow is a pain on the eyes, trying to comment is a pain in the neck - coming back home here is such a relief. While the people over there are just as nice as here, I wish I had thought to check here yesterday.

          W Offline
          W Offline
          William Winner
          wrote on last edited by
          #4

          So, I'm not sure what's wrong with your code. I did this:

          Private Sub Button3_Click(...)
          AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested

          Select Case MessageBox.Show("Text","Title", MessageBoxButtons.YesNoCancel, _
          MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)

          End Select
          End Sub

          Private Sub MsgBoxHelpRequested(...)
          MessageBox.Show("got here")
          End Sub

          and I "got here". Am I the only one that this works for?

          T D 2 Replies Last reply
          0
          • T Trevortni

            Okay, I'm not sure why you're showing a second MsgBox to display the MsgBoxResult of the first one in the first function, but the second function doesn't help me because it's yet another variation of what I've been trying to do that I have already determined does not work for me.

            D Offline
            D Offline
            DaveAuld
            wrote on last edited by
            #5

            i was only using msgbox to illustrate a point thats all. What are you trying to do then, what i have shown in the example code is the help button being handled, which is what i thought you couldn't achieve?

            Private helpTopic as integer =0
            

            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

                helpTopic = 1
                Dim response As MsgBoxResult = MsgBox("the prompt", MsgBoxStyle.MsgBoxHelp + MsgBoxStyle.Information + MsgBoxStyle.YesNo, "The Title")
            
                If response = vbYes Then
                    'User Selects Yes
                Else
                    'Do something else if anything
                End If
            
            End Sub
            
            Private Sub FormMain\_HelpRequested(ByVal sender As Object, ByVal hlpevent As System.Windows.Forms.HelpEventArgs) Handles Me.HelpRequested
            
                Select Case helpTopic
                    Case 1
                        'User want help with topic 1
            
                    Case Else
                        'User called help for something else
            
                End Select
            End Sub
            

            is that better without the extra msgboxes!

            Dave Don't forget to rate messages!
            Find Me On: Web|Facebook|Twitter|LinkedIn
            Waving? dave.m.auld[at]googlewave.com

            T 1 Reply Last reply
            0
            • W William Winner

              So, I'm not sure what's wrong with your code. I did this:

              Private Sub Button3_Click(...)
              AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested

              Select Case MessageBox.Show("Text","Title", MessageBoxButtons.YesNoCancel, _
              MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)

              End Select
              End Sub

              Private Sub MsgBoxHelpRequested(...)
              MessageBox.Show("got here")
              End Sub

              and I "got here". Am I the only one that this works for?

              T Offline
              T Offline
              Trevortni
              wrote on last edited by
              #6

              Actually, I seem to be the only one it doesn't work for. And only in this project. I've copied and pasted my exact code to a new Project, and after taking care of all the blue underlines, it works perfectly. I can't figure out why it's not working in the the real application; the only thing I can think is that the event is never being fired from the MessageBox somehow - I've added handlers for the event in every possible way I can think of, and none of them ever get called. If only I could fire the event myself or break execution when the event is called, it would be so tremendously helpful, but I neither of these seem possible, and I'm getting extremely frustrated.

              D 1 Reply Last reply
              0
              • W William Winner

                So, I'm not sure what's wrong with your code. I did this:

                Private Sub Button3_Click(...)
                AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested

                Select Case MessageBox.Show("Text","Title", MessageBoxButtons.YesNoCancel, _
                MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)

                End Select
                End Sub

                Private Sub MsgBoxHelpRequested(...)
                MessageBox.Show("got here")
                End Sub

                and I "got here". Am I the only one that this works for?

                D Offline
                D Offline
                DaveAuld
                wrote on last edited by
                #7

                Nope, that works for me also. Both Versions of Code, using 2 buttons on form;

                Public Class FormMain

                Private helpTopic As Integer = 0
                
                Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                
                    helpTopic = 1
                    Dim response As MsgBoxResult = MsgBox("the prompt", MsgBoxStyle.MsgBoxHelp + MsgBoxStyle.Information + MsgBoxStyle.YesNo, "The Title")
                
                    If response = vbYes Then
                        'User Selects Yes
                    Else
                        'Do something else if anything
                    End If
                
                End Sub
                
                Private Sub FormMain\_HelpRequested(ByVal sender As Object, ByVal hlpevent As System.Windows.Forms.HelpEventArgs) Handles Me.HelpRequested
                
                    Select Case helpTopic
                        Case 1
                            'User want help with topic 1
                
                        Case Else
                            'User called help for something else
                
                    End Select
                End Sub
                
                Private Sub Button2\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
                    AddHandler Me.HelpRequested, AddressOf Button2Help
                
                    MessageBox.Show("The text", "The caption", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 0, True)
                
                End Sub
                
                Private Sub Button2Help()
                    MsgBox("Some help please")
                End Sub
                

                End Class

                Dave Don't forget to rate messages!
                Find Me On: Web|Facebook|Twitter|LinkedIn
                Waving? dave.m.auld[at]googlewave.com

                1 Reply Last reply
                0
                • D DaveAuld

                  i was only using msgbox to illustrate a point thats all. What are you trying to do then, what i have shown in the example code is the help button being handled, which is what i thought you couldn't achieve?

                  Private helpTopic as integer =0
                  

                  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

                      helpTopic = 1
                      Dim response As MsgBoxResult = MsgBox("the prompt", MsgBoxStyle.MsgBoxHelp + MsgBoxStyle.Information + MsgBoxStyle.YesNo, "The Title")
                  
                      If response = vbYes Then
                          'User Selects Yes
                      Else
                          'Do something else if anything
                      End If
                  
                  End Sub
                  
                  Private Sub FormMain\_HelpRequested(ByVal sender As Object, ByVal hlpevent As System.Windows.Forms.HelpEventArgs) Handles Me.HelpRequested
                  
                      Select Case helpTopic
                          Case 1
                              'User want help with topic 1
                  
                          Case Else
                              'User called help for something else
                  
                      End Select
                  End Sub
                  

                  is that better without the extra msgboxes!

                  Dave Don't forget to rate messages!
                  Find Me On: Web|Facebook|Twitter|LinkedIn
                  Waving? dave.m.auld[at]googlewave.com

                  T Offline
                  T Offline
                  Trevortni
                  wrote on last edited by
                  #8

                  Sorry to snap at you, I got a little annoyed yesterday at people telling me what to do and posting essentially my exact code. Your code isn't the current iteration of my exact code, but it's been tried. Unsuccessfully. :( :( :(

                  1 Reply Last reply
                  0
                  • T Trevortni

                    Actually, I seem to be the only one it doesn't work for. And only in this project. I've copied and pasted my exact code to a new Project, and after taking care of all the blue underlines, it works perfectly. I can't figure out why it's not working in the the real application; the only thing I can think is that the event is never being fired from the MessageBox somehow - I've added handlers for the event in every possible way I can think of, and none of them ever get called. If only I could fire the event myself or break execution when the event is called, it would be so tremendously helpful, but I neither of these seem possible, and I'm getting extremely frustrated.

                    D Offline
                    D Offline
                    DaveAuld
                    wrote on last edited by
                    #9

                    check you haven't got 2 handlers poitint to the same code, that seems to effect things. For example, look at my most recent code i have the Button2Help, if i change the handler to FormMain_HelpRequested (which is handled by Me.HelpRequested) it won't work.

                    Dave Don't forget to rate messages!
                    Find Me On: Web|Facebook|Twitter|LinkedIn
                    Waving? dave.m.auld[at]googlewave.com

                    1 Reply Last reply
                    0
                    • T Trevortni

                      I have a form that is showing a MessageBox using MessageBox.Show, and trying to receive events from the Help button on the MessageBox so I can execute my own code. The Microsoft documentation shows how to do this; however, using what is suggested does not work. Here's a shortened version of my code:

                      Private Function MethodName() As Boolean

                      AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                      Select Case MessageBox.Show("Text", "Title", MessageButtons.YesNoCancel, _
                      MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)
                      Case MsgBoxResult.Yes
                      ' Do stuff
                      Case MsgBoxResult.No
                      ' Do stuff
                      Case MsgBoxResult.Cancel
                      RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                      Return False
                      End Select
                      RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested

                      End Function
                      '
                      '
                      Private Sub MsgBoxHelpRequested(ByVal sender As Object, _
                      ByVal hlpevent As System.Windows.Forms.HelpEventArgs)
                      ' Breakpoint that never gets hit
                      ' More code
                      End Sub

                      I posted this question yesterday on stackoverflow[^], where we get into quite a spirited discussion, with a bunch of suggestions that ultimately never seemed to pan out, if you want to see what I've already tried. Currently I'm working on seeing if there's any way to determine if the event was even raised in the first place - either by trying to manually raise the event and see if my code gets called, or seeing if there's any way to break on an event. Does anybody have any suggestions? Oh, and by the way, Chris Maunder: CodeProject is much better designed than StackOverflow. Reading stackoverflow is a pain on the eyes, trying to comment is a pain in the neck - coming back home here is such a relief. While the people over there are just as nice as here, I wish I had thought to check here yesterday.

                      T Offline
                      T Offline
                      Trevortni
                      wrote on last edited by
                      #10

                      This code is actually getting executed by way of a .dll which Raises an event back on the calling Form that leads to this code. If I move this code back to just before where the code heads out to the .dll, it works. Could something be going on behind the scenes due to the .dll call that could be causing this?

                      modified on Thursday, May 13, 2010 4:58 PM

                      1 Reply Last reply
                      0
                      • T Trevortni

                        I have a form that is showing a MessageBox using MessageBox.Show, and trying to receive events from the Help button on the MessageBox so I can execute my own code. The Microsoft documentation shows how to do this; however, using what is suggested does not work. Here's a shortened version of my code:

                        Private Function MethodName() As Boolean

                        AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                        Select Case MessageBox.Show("Text", "Title", MessageButtons.YesNoCancel, _
                        MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)
                        Case MsgBoxResult.Yes
                        ' Do stuff
                        Case MsgBoxResult.No
                        ' Do stuff
                        Case MsgBoxResult.Cancel
                        RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                        Return False
                        End Select
                        RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested

                        End Function
                        '
                        '
                        Private Sub MsgBoxHelpRequested(ByVal sender As Object, _
                        ByVal hlpevent As System.Windows.Forms.HelpEventArgs)
                        ' Breakpoint that never gets hit
                        ' More code
                        End Sub

                        I posted this question yesterday on stackoverflow[^], where we get into quite a spirited discussion, with a bunch of suggestions that ultimately never seemed to pan out, if you want to see what I've already tried. Currently I'm working on seeing if there's any way to determine if the event was even raised in the first place - either by trying to manually raise the event and see if my code gets called, or seeing if there's any way to break on an event. Does anybody have any suggestions? Oh, and by the way, Chris Maunder: CodeProject is much better designed than StackOverflow. Reading stackoverflow is a pain on the eyes, trying to comment is a pain in the neck - coming back home here is such a relief. While the people over there are just as nice as here, I wish I had thought to check here yesterday.

                        T Offline
                        T Offline
                        Trevortni
                        wrote on last edited by
                        #11

                        OH. MY. GOODNESS. So I started checking the source code for the MessageBox.Show in Reflector. As it turns out, if you don't specify the Owner, as you aren't allowed to do when you want to handle HelpRequested yourself, it uses UnsafeNativeMethods.GetActiveWindow() to determine who to send the HelpRequested to. The moment I saw this, I knew what was going on. The application I'm working in has a splash screen that shows the status to the user that is shown in the .dll. THAT is the ActiveWindow. When I forced it down and called Activate on my Form just before this code, it worked.

                        Trevortni wrote:

                        Private Function MethodName() As Boolean

                        Me.Activate()

                        AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                        Select Case MessageBox.Show("Text", "Title", MessageButtons.YesNoCancel, _
                        MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)
                        Case MsgBoxResult.Yes
                        ' Do stuff
                        Case MsgBoxResult.No
                        ' Do stuff
                        Case MsgBoxResult.Cancel
                        RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                        Return False
                        End Select
                        RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                        End Function
                        '
                        '
                        Private Sub MsgBoxHelpRequested(ByVal sender As Object, _
                        ByVal hlpevent As System.Windows.Forms.HelpEventArgs)
                        ' Breakpoint that finally gets hit
                        ' More code
                        End Sub

                        D H 2 Replies Last reply
                        0
                        • T Trevortni

                          OH. MY. GOODNESS. So I started checking the source code for the MessageBox.Show in Reflector. As it turns out, if you don't specify the Owner, as you aren't allowed to do when you want to handle HelpRequested yourself, it uses UnsafeNativeMethods.GetActiveWindow() to determine who to send the HelpRequested to. The moment I saw this, I knew what was going on. The application I'm working in has a splash screen that shows the status to the user that is shown in the .dll. THAT is the ActiveWindow. When I forced it down and called Activate on my Form just before this code, it worked.

                          Trevortni wrote:

                          Private Function MethodName() As Boolean

                          Me.Activate()

                          AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                          Select Case MessageBox.Show("Text", "Title", MessageButtons.YesNoCancel, _
                          MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)
                          Case MsgBoxResult.Yes
                          ' Do stuff
                          Case MsgBoxResult.No
                          ' Do stuff
                          Case MsgBoxResult.Cancel
                          RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                          Return False
                          End Select
                          RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                          End Function
                          '
                          '
                          Private Sub MsgBoxHelpRequested(ByVal sender As Object, _
                          ByVal hlpevent As System.Windows.Forms.HelpEventArgs)
                          ' Breakpoint that finally gets hit
                          ' More code
                          End Sub

                          D Offline
                          D Offline
                          DaveAuld
                          wrote on last edited by
                          #12

                          good to hear that you have got to the bottom of the problem.

                          Dave Don't forget to rate messages!
                          Find Me On: Web|Facebook|Twitter|LinkedIn
                          Waving? dave.m.auld[at]googlewave.com

                          1 Reply Last reply
                          0
                          • T Trevortni

                            OH. MY. GOODNESS. So I started checking the source code for the MessageBox.Show in Reflector. As it turns out, if you don't specify the Owner, as you aren't allowed to do when you want to handle HelpRequested yourself, it uses UnsafeNativeMethods.GetActiveWindow() to determine who to send the HelpRequested to. The moment I saw this, I knew what was going on. The application I'm working in has a splash screen that shows the status to the user that is shown in the .dll. THAT is the ActiveWindow. When I forced it down and called Activate on my Form just before this code, it worked.

                            Trevortni wrote:

                            Private Function MethodName() As Boolean

                            Me.Activate()

                            AddHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                            Select Case MessageBox.Show("Text", "Title", MessageButtons.YesNoCancel, _
                            MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0, True)
                            Case MsgBoxResult.Yes
                            ' Do stuff
                            Case MsgBoxResult.No
                            ' Do stuff
                            Case MsgBoxResult.Cancel
                            RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                            Return False
                            End Select
                            RemoveHandler Me.HelpRequested, AddressOf Me.MsgBoxHelpRequested
                            End Function
                            '
                            '
                            Private Sub MsgBoxHelpRequested(ByVal sender As Object, _
                            ByVal hlpevent As System.Windows.Forms.HelpEventArgs)
                            ' Breakpoint that finally gets hit
                            ' More code
                            End Sub

                            H Offline
                            H Offline
                            Henry Minute
                            wrote on last edited by
                            #13

                            Kudos to you for posting the solution.

                            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups