Mdi child looses focus


I have an Mdi application with a child window containing an editor (and a
list). When I switch between Mdi children, I manage to give the focus to the
editor child in the Mdi child. However, when I switch between applications,
the focus of the editor is lost.

I catch WM_ActivateApp in the main window, and i successfully identifies the
top Mdi child, but I fail to give focus to the editor.

I use this in the Mdi child window procedure:

      If LParam=Mdi Then Begin        { if activated }
        Proj:=GetProject(Mdi);        { get object for Mdi child }
        SetFocus(Proj^.Edit);        { sets focus to the editor child }

I have this in the window procedure of the main window:

      If WParam<>0 Then Begin        { if activated }
        If GetTopProject(Proj) Then Begin    { get object for Mdi child }
          WriteLn('Focus');        { to show that we really get here }
          SetFocus(Proj^.Edit);        { has no effect }

Why does this not work?

kill the spammer to mail me