implement a shared stack

dubem1

Newcomer
Joined
Dec 5, 2002
Messages
20
Hello,

All my form are derived from a base form. Each time a form is opened, I want to add the name (or the id) of the form is a shared stack. I thought about declaring the stack in the base form. But now, how should I implement this? I need each form to add is name in the stack...How?? raising an event in the OnLoad method or just calling a method in the base form? Same onClosing. Any idea how to implement this?

Thank you

Martin
 
Sounds like you've got a good idea for it to me. Declare it as Public Shared in the base form and use the appropriate events. Are you sure a Stack is the structure you want though? Unless they are all modal, seems like you'd run into problems trying to remove them.
 
Yep. As tim said.

The only way I see (in fact thats how we do it here in our project) is to have a FormManager Class, which internally also managers the stack, plus some events which are fired by the forms (closing, status changes, requests for additional forms to be opened), plus a defined interface which all forms must implement (through this interface the Manger controls the forms).

+++

OK, we do it with usercontrols _and_ forms, but you get the idea, hopefully.
 
Yes, they are modal, that's why I thought about a stack.
I can't figure how to use event in this case (base form versus inherited form). Any example how to do it? If I raise the event in the inherited form, how the base form could catch it. Any help will be very appreciated
Thanks
 
Why do you need to store each form...? Can you not use the form's built-in Owner property? As long as you pass in "this" or "Me" when calling ShowDialog, the new modal window will have a reference to the opening form.

-Nerseus
 
Because I have circular form reference.

Form 1 can open form 2
Form 2 can open form 3
Form 3 can open form 1 (only if form 1 isn't already open)

That's why I need to check if the form is opened.

Any idea how to implement this?
Thanks
 
Well if they're all being opened modally the Owner property will still work. Since you need to create a new instance of each form every time you show it, each will get its own Owner property.

-Nerseus
 
Back
Top