471,320 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,320 software developers and data experts.

ShowDialog question

I would like to detect when a form is invoked as the result of a ShowDialog
call.

Anyone have any ideas or suggestions on how to do that?

TIA,

Richard Rosenheim
Jul 21 '05 #1
3 3516
Richard,

Sometimes I see here messages I don't absolutly not understand.
Who is calling the form using a ShowDialog.

However you can always overload the showdialogoperator with me/this.
Which set the parent of the form.

I hope this helps?

Cor
Jul 21 '05 #2
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

"Cor Ligthert" <no************@planet.nl> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl...
Richard,

Sometimes I see here messages I don't absolutly not understand.
Who is calling the form using a ShowDialog.

However you can always overload the showdialogoperator with me/this.
Which set the parent of the form.

I hope this helps?

Cor

Jul 21 '05 #3
Richard,

The showdialog is expresly created in this way that there is no processing
done.

What you ask is often thought, however think it again over what you want to
do, you are not the first.

Programming is mostly making a chain of from each other dependend
instructions (althoug that are very much repeated instructions). Although
you see a lot of multithreading in this newsgroup, is my expirience that
when I don't use queues it is in most cases hard to use multithreading on an
efficient way (This expirience is very old)

The route you are taking now, makes that your would do yourself the
synchronization. Probably will that take (to keep that working well) more
time than you need for building your program without that.

When you want it coute a coute, than you can make your own openfiledialog,
that would probably take less time than the path you try to achieve not.

Or as another approach start the process you want to do while the
OpenFileDialog is showed in a seperated thread.

I hope this gives some idea's

Cor
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by NanoWizard | last post: by
4 posts views Thread by Mike | last post: by
4 posts views Thread by Dennis Sjogren | last post: by
4 posts views Thread by Jm | last post: by
3 posts views Thread by Richard L Rosenheim | last post: by
14 posts views Thread by shark | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.