Mr felis,

I tried it and it worked OK. Here is the code:

Option Explicit

Private WithEvents mForm As Form

Private Sub MDIForm_Click()
Set mForm = New Form1
mForm.Show
mForm_Deactivate
End Sub

Private Sub mForm_Deactivate()
Set mForm = ActiveForm
Me.Caption = mForm.hWnd
End Sub

Also in form1 (just for testing)

Option Explicit

Private Sub Form_Load()
Me.Caption = hWnd
End Sub

"mrfelis" <mrfelis@yahoo.NOSPAM.com> wrote in message
news:3a77305b$1@news.devx.com...
> Michael Culley <mike@vbdotcom.com> wrote in message
> news:3a76137c@news.devx.com...
> > mr felis,
> >
> > you only need to get the events of 1 form - the active one. When you get

a
> > form_deactive event just change the variable to be the new form. There

> would
> Does the MDIForm.ActiveForm property get changed before or after the child
> form_deactivate? If it is after, who would you catch the event for the
> activating form using the single variable?
>
> The object array inside a collection raising evnets could work though.
> --
> ~~~
> !ti timda I ,KO
> .em deppals nocaeB sivaM
> !draH
> ~~
> C'Ya,
> mrfelis@yahoo!com
> Michael Culley <mike@vbdotcom.com> wrote in message
> news:3a76137c@news.devx.com...
> > mr felis,
> >
> > you only need to get the events of 1 form - the active one. When you get

a
> > form_deactive event just change the variable to be the new form. There

> would
> > be some additional stuffing around when no forms were visible but it

most
> > likely would be workable.
> >
> > We use a different method. We have a usercontrol on the MDI form (we

call
> it
> > the AM control) and a control on every MDI child form (called the FM
> > control - inhouse joke). When the FM control detects that the form loses
> > focus it sends a message to the AM control which raises an event on the

> MDI
> > form. It also serves other purposes such as toolbar control, sending
> > messages between forms etc.
> >
> > >The problem lies in VB not allowing WithEvents to be used with arrays

> >
> > There are ways around this. Which boils down to creating an array of

> classes
> > that has a withevents variable in it and then having the classes call a
> > central location.
> >
> > Michael Culley
> >
> > "mrfelis" <mrfelis@yahoo.NOSPAM.com> wrote in message
> > news:3a7600ac$1@news.devx.com...
> > > Tim Coulter <tim.coulter@wanadoo.fr> wrote in message
> > > news:3a75de9c$1@news.devx.com...
> > > >
> > > > What I really want to do is raise events within child forms which

can
> be
> > > Sinking events for MDI children may prove to be very limited in use.

The
> > > problem lies in VB not allowing WithEvents to be used with arrays. So

> you
> > > will only be able Sink an Event of the activating form if you limit

the
> > > number of mdi children to that allow loaded. You'll need one variable

> for
> > > each form. Then each event would have to be coded separately. This can

> get
> > > very messy.
> > >
> > > Since VB only allows 1 MDI form per application, why not just code

> public
> > > subs inplace of event sinks?
> > >
> > > > From your explanation, I now understand that I need to intercept the
> > > WM_MDIACTIVATE
> > > > message to the MDIClient window. But can you please tell me how to

get
> a
> > >
> > > Well, you could put the code into form_Activate event for the mdi

child
> > > forms as the last line in Tom's post indicates. This should be clean

> > enough
> > > unless you have different form types to be shown as mdi children.
> > >
> > > Here's an example:
> > >
> > > 'MDI form code
> > > Option Explicit
> > >
> > > Public Sub Activated()
> > > Me.Caption = "MDI form: Child " & ActiveForm.Caption
> > > End Sub
> > >
> > >
> > > Private Sub mnuNew_Click()
> > > With New frmChild
> > > .Caption = Forms.Count
> > > .Show
> > > End With
> > > End Sub
> > >
> > > 'mdi child form code
> > > Private Sub Form_Activate()
> > > MDIForm1.Activated
> > > End Sub
> > >
> > >
> > >
> > > --
> > > ~~~
> > > !ti timda I ,KO
> > > .em deppals nocaeB sivaM
> > > !draH
> > > ~~
> > > C'Ya,
> > > mrfelis@yahoo!com
> > >
> > >
> > >

> >
> >

>
>