showdialog ; is there a property showing it?

  • Thread starter Thread starter Josh Golden
  • Start date Start date
J

Josh Golden

3 forms.
form 1, when button clicked instantiates form 2 which opens but is not
shown. form 2 instantiates form 3 as showdialog. form 3 finishes, raises
an event that form 2 catches. during the catch, form 2 closes and disposes
the instance of form 3, opens itself as showdialog, and displays some data
to the user. the user can select one of these data and upon doing so raises
an event that form 1 catches (and closes and disposes of form 2). all is
good.

but following the same scenario, if after form 3 is closed and disposed and
form 2 uses me.showdialog. if the user doesn't like the data he can click a
button on form 2 and instantiate form 3 again. when that button is clicked,
form 2 calls me.hide because I can't close form2. problem is when form3 is
closing again, it raises an event which form2 catches, but that event wants
to call me.showdialog. at this point, i have called me.showdialog twice
which is no good.

so basically i want this

if me.<someproperty> = "IwasOpenedAsShowDialog" then
me.show
else
me.showdialog
endif

thanks
 
Josh,

What holds you to use a shared swBool for that?
Mostly it makes things easier as well after 2 years when you read the
program again.

Just my thought about this?

Cor
 
i'm sorry cor, i am unable to follow what you wrote. can you try to explain
it again?
 
Hi Josh,

Thinking about it, it is even simpler to set it as a public value in your
form.
Public swOpenAsDialog as boolean.
You can set that before you do the open.
Simple however very efficient.

Cor
 
i'm sorry cor, i am unable to follow what you wrote. can you try to explain
it again?

I'm not a .NET expert, but I know when this question was asked in the VB6
groups our answer was "there is no easy way to tell if a window has been
shown modally." It's probably still the same with .NET.

I think Cor is suggesting that you track the status of the window yourself
with a Boolean variable that you set based on how you show the window. It's
your code, after all. Only you will be showing the form, so set this
variable at the same time to indicate HOW you showed the form. More work on
your part? Yes, a little. But it might be your only recourse.
 
* "Josh Golden said:
form 1, when button clicked instantiates form 2 which opens but is not
shown. form 2 instantiates form 3 as showdialog. form 3 finishes, raises
an event that form 2 catches. during the catch, form 2 closes and disposes
the instance of form 3, opens itself as showdialog, and displays some data
to the user. the user can select one of these data and upon doing so raises
an event that form 1 catches (and closes and disposes of form 2). all is
good.

but following the same scenario, if after form 3 is closed and disposed and
form 2 uses me.showdialog. if the user doesn't like the data he can click a
button on form 2 and instantiate form 3 again. when that button is clicked,
form 2 calls me.hide because I can't close form2. problem is when form3 is
closing again, it raises an event which form2 catches, but that event wants
to call me.showdialog. at this point, i have called me.showdialog twice
which is no good.

so basically i want this

if me.<someproperty> = "IwasOpenedAsShowDialog" then
me.show
else
me.showdialog
endif

If you are calling a form's 'Show' or 'ShowDialog' method twice on the
/same/ instance, the form will only be shown one time. What do you mean
by "which opens but is now shown"?
 
Back
Top