>My framework uses a toplevel form instead of _SCREEN. When the toplevel form is activated, _SCREEN.ActiveForm returns the correct object reference to the toplevel form.
>
>The same holds true with other modeless child forms which are activated on top of the toplevel form
and when I shift focus between these child forms (firing the form's Activate event), _SCREEN.ActiveForm will always return the correct active form's object reference.
>
>The problem occurs when I shift focus back to the toplevel form after a child form has been activated. _SCREEN.ActiveForm will always return the reference to the last child form activated even after the toplevel form's Activate event has fired and now has focus.
>
>Since I need a reference to the current active form, my solution is the following code in Activate event of the form base class:
>
>IF VARTYPE(goApp) = "O" AND NOT goApp.oActiveForm = This
> goApp.oActiveForm = This
>ENDIF
>
>If anyone has a more elegant solution (or if I'm missing something) please let me know.
Jeff,
This happens with top-level forms, .ActiveForm will sometimes contain the reference sometimes not (depending on what had the focus last). For example, open the Debugger, before starting the top level form then look at _SCREEN.ActiveForm in the Debugger, and you'll probably see the form. Next, click on the main VFP window and go back to the Debugger. You'll probably see, "Expression could not be evaluated". The Forms collection suffers from the same thing.
George
Ubi caritas et amor, deus ibi est