views:

1309

answers:

2

I would like to be able to catch a child window focus event, in an mdi form.

If i loose focus to the entire mdi application, then click on a child, it works, but if I had two child forms open, I cannot catch the focus event when clicking between them.

I am using Dotnet Framework 2.0, and I need the code solution that will run fine on a windows 2000 machine, and up.

Thanks in advance for all help and advice,

-regards Jeremy

+1  A: 

I think you're looking for the Form.MdiChildActivate event. This event will be fired in your MDI parent form.

lc
+1  A: 

override the child forms Activated event.

sample code:

private void addChild(){
        frmChild mychild = new frmChild();
        mychild.Activated += FActivated;
        mychild.MdiParent = this;
        mychild.Show();
}

private void FActivated(object sender, EventArgs e)
{
    MessageBox.Show("Activated one of the child.");
}
junmats