Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
WEXIST()
, WMAXIMUM()
, WMINIMUM()
, WREAD()
, WVISIBLE()
The windows of my soul I throw
Wide open to the sun.
—John Greenleaf Whittier, My Psalm
These functions tell you about the current status of a window. All accept a parameter specifying the window; pass the name (not the title—see WTITLE()
) of the window. For some, the window parameter is optional. Those functions return information about the active window if no window is specified.
These functions return information about user-defined windows, system windows and toolbars. With forms, the WindowState and Visible properties provide much of the same information, while MaxButton and MinButton let you find out if a form can be maximized or minimized.
lWindowExists = WEXIST( cWindow )
For user-defined windows, WEXIST()
tells you whether a window has been defined. If so, the function returns .T. It doesn’t matter whether the window has ever been activated or whether it’s visible; it just needs to have been defined. You must name a window for this command since, by definition, the active window exists.
For system windows, WEXIST()
indicates whether the window is active. It need not be visible (it could be hidden), but it must be active for WEXIST()
to return .T.
In earlier versions of VFP, there were two exceptions. WEXIST(“Command”) always returned .T., even in a runtime executable. WEXIST(“Debug”) always returned .T. once the Debug window had been opened in a session, regardless of its current state. In VFP 5 and later, both calls return .F.
* first, a user-defined window
CLEAR ALL
? WEXIST("test") && Returns .F.
DEFINE WINDOW test FROM 0,0 TO 10,10
? WEXIST("test") && Returns .T.
* now a system window
CLEAR ALL
? WEXIST("Trace") && Returns .F.
ACTIVATE WINDOW Trace
? WEXIST("Trace") && Returns .T.
HIDE WINDOW Trace
? WEXIST("Trace") && Returns .T.
RELEASE WINDOW Trace
? WEXIST("Trace") && Returns .F.
lIsMaximized = WMAXIMUM( [ cWindow ] )
lIsMinimized = WMINIMUM( [ cWindow ] )
This pair of functions tells you whether the specified window is maximized or minimized, respectively. They always return .F. for toolbars because toolbars can’t be minimized or maximized.
A user-defined window can only be maximized if it was defined with the ZOOM keyword. Similarly, it can only be minimized if it was defined with the MINIMIZE keyword.
DEFINE WINDOW test FROM 0,0 TO 10,40 ZOOM MINIMIZE
ACTIVATE WINDOW test
? WMAXIMUM("test") && Returns .F.
? WMINIMUM("test") && Returns .F.
ZOOM WINDOW test MAX
? WMAXIMUM("test") && Returns .T.
ZOOM WINDOW test MIN
? WMINIMUM("test") && Returns .T.
lInRead = WREAD( [ cWindow ] )
WREAD()
tells you whether the specified window is part of the active FoxPro 2.x style READ. WREAD()
returns .T. if there is an active READ and the window either contains at least one @..GET or @..EDIT object from that READ, or is listed in the WITH clause for the READ.
WREAD()
was important in some of the schemes for event-driven applications necessary in 2.x. We can’t see much reason to use it in Visual FoxPro, except in legacy applications.
* Before entering the following code in the command window,
* open the Debugger and put the string
* WREAD("test")
* in the Watch window
DEFINE WINDOW test FROM 0,0 TO 10,40
ACTIVATE WINDOW test
* Note that WREAD("test") is .F.
CLEAR
@0,0 GET x DEFAULT "abc"
READ
* Now WREAD("test") is .T.
lIsVisible = WVISIBLE( cWindow )
WVISIBLE()
tells you whether the specified window is visible right now. Like WEXIST()
, it requires you to name a window, presumably on the principle that you can see the active window, so you know it’s visible.
WVISIBLE()
returns .T. if the window has been activated and hasn’t been hidden. Otherwise, it returns .F. WVISIBLE()
doesn’t care if the window is in the viewable area of the screen, only that it’s active and not hidden. So a window with negative coordinates is WVISIBLE()
.
DEFINE WINDOW test FROM 0,0 TO 10,40
? WVISIBLE("test") && Returns .F.
ACTIVATE WINDOW test
? WVISIBLE("test") && Returns .T.
HIDE WINDOW test
? WVISIBLE("test") && Returns .F.
SHOW WINDOW test
? WVISIBLE("test") && Returns .T.
Activate Window, Deactivate Window, Define Window, Hide Window, Modify Window, Read, Release Window, Show Window, Visible, WindowState, WTitle(), Zoom Window