Home All Groups Group Topic Archive Search About

Print information when ANY control is used

Author
1 Apr 2005 4:37 AM
Tom
I have an application with hundreds of controls that has
an error that is difficult to reproduce.  I would like to
instrument the software to trace everything the user does
so I can reproduce it.  How can I write selected
information to a file each time the user uses ANY
control? (I mainly have buttons, textboxes and
comboboxes.)  I would like to do this without explicitly
writing a handling routine for each control and also
without disturbing the handling routines that already
exist.

Thanks

Author
1 Apr 2005 7:40 AM
Cor Ligthert
Tom,

You can create an event in a recursive loop for an event that you are not
using and know that it is firing by instance Enter (which does not fire for
a button, therefore search for that what fits you the best)

The events for that you can build in one time by instance using this
routine.

\\\
Private Sub Form1_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        doset(Me)
    End Sub
    Private Sub doSet(ByVal parentCtr As Control)
        Dim ctr As Control
        For Each ctr In parentCtr.Controls
            AddHandler ctr.Enter, AddressOf meEnter
            doSet(ctr)
        Next
    End Sub
///

I hope this helps,

Cor