Making a list of MDI children (like windows taskbar)


F

feudalac!

Hello...


I have an app with a MDI form. When an user clicks on a menu item - MDI
child form is loaded

I want to put a toolstrip at the bottom of the MDI parent and, when a
MDI child is loaded, create a checkable button on that toolstrip with
that MDI child form's titlebar text as button text.

Then when there is more than one button on the toolstrip (because there
is more then one MDI child form loaded) the user clicks on the button
and activates the form.

When MDI child is closed, i want to remove the toolstripitem.


i figured out how to create the item (But it has no name and i don't
know where to write code that handles that item's click)
and i don't know how to remove the item when mdi form closes (i have no
event...)



Thanks
 
Ad

Advertisements

F

feudalac!

feudalac! said:
Hello...


I have an app with a MDI form. When an user clicks on a menu item - MDI
child form is loaded

I want to put a toolstrip at the bottom of the MDI parent and, when a
MDI child is loaded, create a checkable button on that toolstrip with
that MDI child form's titlebar text as button text.

Then when there is more than one button on the toolstrip (because there
is more then one MDI child form loaded) the user clicks on the button
and activates the form.

When MDI child is closed, i want to remove the toolstripitem.


i figured out how to create the item (But it has no name and i don't
know where to write code that handles that item's click)
and i don't know how to remove the item when mdi form closes (i have no
event...)



Thanks

The forms that are in question are in another DLL and i don't call them
directly because i send some data to them first

they are in dll AMA.Components.Forms
object is fMdi as new AMA.Components.Forms.cMain
and call is fMdi.StartListForm(UserRights,ProgramConfiguration)
so AddHandler fMdi.Closed, AddressOf Me.RemoveToolItem will not work...
 
S

Steve Barnett

I'm a bit new to this stuff, but why not hook in to the FormClosing event of
the MDI child forms. For example,

private void CreateNewForm()
{
frmChild fChild = new frmChild();

fChild.MdiParent = this;
fChild.FormClosing += new FormClosingEventHandler(CloseChild);
fChild.Show();
}

private void CloseChild(object sender, FormClosingEventArgs e)
{
Form sentFrom = (Form)sender;
MessageBox.Show(String.Format("Child form closed: {0}",
sentFrom.Text));
}

When the CloseChild event fires, you should be able to loop round and see
which form was closed and remove it from the toolstrip. Obviously, if all
your forms are the same type, you could use a more explicit cast than "Form"
so could access properties of the form being closed.

Steve
 
F

feudalac!

That would work if i referenced a form directly but i reference a class
and i call a function that loads the form so i can't hook to formclosing
event because the function doesn't have one...


here is the code from the dll AMA.Components.Forms.cMain
public sub StartListForm (usrrig as structureUserRights, progconf as
structureProgramConfiguration, frmParentName as form)
UserRights = usrrig
ProgramConfiguration = progconf
dim frm as New frmList
frm.mdiparent = frmParentName
frm.show
end sub



here is the code from the exe AMA
dim fMdi as new AMA.Components.Forms.cMain
fMdi.StartListForm(UserRights,ProgramConfiguration,me)

now- hooking to a formclosed event doesn't work in this case
 
S

Steve Barnett

You're passing the MDI parent form in to the StartListForm method so, if
your handler were a public method of the MDI form, you should be able to
attach it in StartListForm.

frm.FormClosing += new
FormClosingEventHandler(frmParentName.CloseChild);

I can't test this here, but I can't see why it wouln't work (you'll have to
pass the proper type to StartListForm, rather than just "Form"). Unless I've
completely missed the point, in which case, I'll go away!

Steve
 
Ad

Advertisements

F

feudalac!

I was just gonna post this:
Error 1 'FormClosed' is not an event of 'AMA2.Components.clsMain'.
C:\VB.NET\AllMyAssets2\AllMyAssets2\frmAllMyAssets.vb 336 22 AllMyAssets2

but now i see that i must create an event in that class that is
triggered when the form closes
then event will trigger in my main exe...
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top