I solved a similar problem by simply creating a wrapper function for the MessageBox.Show () calls, and then replacing all the calls in our application with this function.
something like:
Public Function My_MessageBox(ByVal pstrMsg As String, _ Optional ByVal pstrCaption As String = "", _ Optional ByVal pButtons As Windows.Forms.MessageBoxButtons = MessageBoxButtons.OK, _ Optional ByVal pIcon As Windows.Forms.MessageBoxIcon = MessageBoxIcon.None, _ Optional ByVal pDefButton As Windows.Forms.MessageBoxDefaultButton = MessageBoxDefaultButton.Button1) _ As Windows.Forms.DialogResult Dim rval As Windows.Forms.DialogResult If glAutomated Then ' if automation is running, we don't want to show ' the box to the user, just retrieve the result stored rval = AutomateThisMessageBox("MsgBox" & pstrCaption.Replace(" ", "")) Else rval = MessageBox.Show(pstrMsg, pstrCaption, pButtons, pIcon, pDefButton) If glRecording Then 'Only record the result when in "record" mode Hooks.RecordMessageBox(pstrCaption.Replace(" ", ""), rval.ToString) End If End If Return rval End Function
Usage: just like Messagebox.Show is currently in use, just replace Name in the new function, for example:
MessageBox.Show("This is a test", "Test Msg", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
becomes
My_MessageBox("This is a test", "Test Msg", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
Edit:
Just re-read the end of your question about all the different dialogs. I suggest that a similar technique can be used in a general sense. Or various wrappers for all the dialogs you need (open the / etc file)
source share