Cor,
Yes, in re-reading it, it probably wasn't my clearest question. I was also
trying not to write a long winded question either (like this one).
As you know, when ShowDialog is invoked, (along with possibly doing other
things), it causes the form to be displayed. Then it waits until
DialogResult is assigned a value, at which point it returns the value to the
parent and exits.
I would like to detect when the form has been displayed, so that while
ShowDialog is waiting for the value of DialogResult to be assigned, my
dialog can do some processing. My processing routine would be displaying
status information, so I don't want the processing to begin before the form
is actually displayed.
So, I can't just do something like this:
Public Overloads Function ShowDialog() As DialogResult
DoProcessing
Return MyBase.ShowDialog()
End Function
Nor, do I know exactly what all ShowDialog does internally, so I don't think
I really want to anything like this:
Public Overloads Function ShowDialog() As DialogResult
Me.Show
DoProcessing
Return MyBase.ShowDialog()
End Function
One possible approach would be to enable a timer, allowing a little time to
elapse (hopefully enough time for the form to display) and then calling the
processing routine.
The approach I'm currently utilizing is to set a flag in the ShowDialog
event, and then having the Activated event invoke the processing routine
when the flag is set. I needed the flag to prevent the Activated event from
invoking the processing routine every time the form gets the focus. And by
initializing the flag in the ShowDialog event, the code will still work if
the same instance of the form ever gets invoked more than once by a call to
ShowDialog.
While this approach seems to work, I'm not sure if it's the proper or best
way of dealing with the problem. Hence, the reason behind my original
question.
Richard Rosenheim