MSM-Workstation
Macros

Go back to the alphabetic list of macros
Go back to the first page of this tutorial

%%SetFocus ( Object )

Set focus to a window or control.

Object The window or control that is to receive focus. If none is specified, the current object will be used by default.

The macro %%SetFocus is used to control the focus, which indicates where user input is expected.

Note that if Object is not specified, focus is set to the current object. This highlights the difference between the "current object" and the "object with focus". Typically these two are the same, but not always. For instance, during Create code for an object the object is the "current" object, but it doesn't have focus.

Example

%%SetFocus(Lab.TestNo)
Set the focus to the control called "TestNo" on the window called "Lab".

%%SetFocus(OK)
Set the focus to the control called "OK" on the current window.

%%SetFocus(@where.)
Set the focus to the window identified by the local variable where.

%%SetFocus($MSM.)
Set the focus to the MSM window. This form exploits an MSM extension to the MWAPI standard.

See also

%%CurrCtl, %%CurrWin, %%Focus, %%FocusCtl and %%FocusWin.