Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determine which mdi form has the focus

Status
Not open for further replies.

hinchdog

Programmer
Feb 14, 2001
380
US
is there a quick and easy way to determine which child mdi form has the current focus from the parent?
 
from MSDN:

ActiveForm Property


Returns the form that is the active window. If an MDIForm object is active or is referenced, it specifies the active MDI child form.

Syntax

object.ActiveForm

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Use the ActiveForm property to access a form's properties or to invoke its methods — for example, Screen.ActiveForm.MousePointer = 4.

This property is especially useful in a multiple-document interface (MDI) application where a button on a toolbar must initiate an action on a control in an MDI child form. When a user clicks the Copy button on the toolbar, your code can reference the text in the active control on the MDI child form — for example, ActiveForm.ActiveControl.SelText.

When a control on a form has the focus, that form is the active form on the screen (Screen.ActiveForm). In addition, an MDIForm object can contain one child form that is the active form within the context of the MDI parent form (MDIForm.ActiveForm). The ActiveForm on the screen isn't necessarily the same as the ActiveForm in the MDI form, such as when a dialog box is active. For this reason, specify the MDIForm with ActiveForm when there is a chance of a dialog box being the ActiveForm property setting.

Note When an active MDI child form isn't maximized, the title bars of both the parent form and the child form appear active.

If you plan to pass Screen.ActiveForm or MDIForm.ActiveForm to a procedure, you must declare the argument in that procedure with the generic type (As Form) rather than a specific form type (As MyForm) even if ActiveForm always refers to the same type of form.

The ActiveForm property determines the default value for the ProjectTemplate object.


--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top