DragOver

WLast(), WOnTop(), WOutput()

These three functions tell you about active windows and where output is going. WONTOP() tells you which window is active now. WLAST() tells you which window was active before the one that's active now. WOUTPUT() tells you where output is going now.

All three of these functions can either give you the name of the window that has the specified status (last active, currently active, receiving output) or tell you whether a particular window has that status.

Usage

cReturnValue = WLAST() lReturnValue = WLAST( cWindow ) cReturnValue = WONTOP()  lReturnValue = WONTOP( cWindow )
WONTOP() without a parameter returns the name of the window that's "on top," that is, the active window. Normally, you can identify this window because its title bar is a different color than other windows' title bars. If you pass a window name, WONTOP() tells you whether or not it's on top. Toolbars can never be WONTOP(), though other system windows can. The Command Window is also never WONTOP().

If the parameter is omitted, WLAST() returns the name of the window that was active just before the current active window (the previous WONTOP()). If you pass the name of a window, the return value tells whether that window was active just before the current active window.

When you click from one window to another, the window you click on becomes WONTOP(), while the one you left becomes WLAST(). Issuing ACTIVATE WINDOW makes the named window WONTOP(). However, the Command Window is never WONTOP() or WLAST().

There's a subtle point when using a form set (or a 2.x screen set). When you move from one form to another in the set, the DEACTIVATE method of the form you're leaving fires. By the time that happens, the form you're leaving has become WLAST() and the new form is WONTOP(). When using 2.x-style screen sets, the same thing is true for the DEACTIVATE clause of the READ command—by the time it executes, the new window is WONTOP() and the one you're leaving is WLAST().

However, except when building developer's tools, checking WONTOP() and WLAST() and changing them with ACTIVATE WINDOW should be much less common in Visual FoxPro than in FoxPro 2.x. Since pretty much every window involved in an application will be a form, you can do these manipulations using form and formset properties and methods instead.

A hidden window can't be WONTOP() even if you use the optional SAME clause of HIDE WINDOW. A window must be visible to be WONTOP().

Example

* Open the Watch window * window and put WONTOP() and WLAST() in it * Then, try this: DEFINE WINDOW test1 FROM 0,0 TO 10,30 DEFINE WINDOW test2 FROM 0,40 TO 10,70 ACTIVATE WINDOW test1 * notice that WONTOP() is now "TEST1" * click into the Command window * now WLAST() is "TEST1", too ACTIVATE WINDOW test2 * WONTOP() becomes "TEST2" * Click between the two windows and watch what happens. * Note that clicking on a window doesn't make it WONTOP(). * This isn't true with forms.

Usage

cReturnValue = WOUTPUT() lReturnValue = WOUTPUT( cWindow )
Without a parameter, WOUTPUT() tells you the name of the window to which any output will be sent (the "output window"). If you pass a window name, you find out whether that window is the output window.

Issuing ACTIVATE WINDOW changes WOUTPUT() to the named window, if it's capable of receiving output. Clicking on a window created with DEFINE WINDOW does not make it WOUTPUT(), but clicking on a form does.

WONTOP() and WOUTPUT() often have the same value, but not always. There are many windows that cannot be WOUTPUT() because they can't receive output. This is true of all system windows and of Browse windows. (In FoxPro 2.x, comparing WONTOP() to WOUTPUT() was one way of determining whether a Browse or a READ window was active when coordinating Browse with READ.)

Output from commands (like DIR, ?, and COUNT) that you probably think of as going to the main FoxPro window actually goes to WOUTPUT(). To have this output go to the main FoxPro window, you can issue ACTIVATE SCREEN before the command that generates the output. However, as we've mentioned elsewhere, using the Screen raises various issues, because some applications may use only top-level windows and dispense with the Screen entirely.

WOUTPUT() can point to a hidden window, which can be confusing when your output seems to disappear entirely.

Example

* open the Watch window and put WOUTPUT() in it * Then: DEFINE WINDOW test1 FROM 0,0 TO 10,30 DEFINE WINDOW test2 FROM 0,40 TO 10,70 ACTIVATE WINDOW test1 * note that WOUTPUT() is now "TEST1" ACTIVATE WINDOW test2 * WOUTPUT() is now "TEST2" * Click on Debug Window - WOUTPUT() doesn't change * Click between the windows - WOUTPUT() doesn't change

See Also

Activate Screen, Activate Window, ActiveForm, Define Window, Hide Window, Show, Show Window, WTitle()


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net