Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 866997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:54:09+00:00 2026-05-15T09:54:09+00:00

We have a large WinForms app, and there is a built-in bug reporting system

  • 0

We have a large WinForms app, and there is a built-in bug reporting system that can be activated during testing via the F5 Key. I am capturing the F5 key with .Net’s PreFilterMessage system. This works fine on the main forms, modal dialog boxes, etc.

Unfortunately, the program also displays windows messageboxes when it needs to. When there is a bug with that, e.g., wrong text in the messagebox or it shouldn’t be there, the messagefilter isn’t executed at all when the messagebox is up!

I realize I could fix it by either rewriting my own messagebox routine, or kicking off a separate thread that polls GetAsyncKeyState and calls the error reporter from there. However I was hoping for a method that was less of a hack. Here’s code that manifests the problem:

Public Class Form1 
    Implements IMessageFilter

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
    MsgBox("now, a messagebox is up!")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Application.AddMessageFilter(Me)
End Sub

Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) _
 As Boolean Implements IMessageFilter.PreFilterMessage

    Const VK_F5 As Int32 = &H74
    Const WM_KEYDOWN As Integer = &H100

    If m.Msg = WM_KEYDOWN And m.WParam.ToInt32 = VK_F5 Then
        ' In reality code here takes a screenshot, saves the program state, and shows a bug report interface '
        IO.File.AppendAllText("c:\bugs.txt", InputBox("Describe the bug:"))
    End If

End Function
End Class

Many thanks.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:54:10+00:00Added an answer on May 15, 2026 at 9:54 am

    IMessageFilters are a .Net feature and are invoked by the .Net message loop.

    Since MessageBox.Show runs the native message loop (inside the MessageBox API call), the IMessageFilters are not called in it.

    You need to make a keyboard hook, like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have a Winforms app that is installed on a large number of
I have a .NET Winforms app (created in VS2005) that I deploy using ClickOnce.
I have inherited a large admin winforms application that shares a 'Common' library of
I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment,
I have a large vb6/sql database app (hundreds of tables, classes, and forms) that
I have a WinForms application for editing text in a large RichTextBox control. Can
In a winforms application I have a MyForm.cs that starts to get quite large.
I currently have a WinForms application that downloads large amounts of data from a
I have a fairly large CRUD winform app that is set up to display
I have multiple winforms applications that download large sets of reference data on startup.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.