Logo

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.

hWnd

Internally, the Windows operating systems manage all windows objects and many controls (which are really windows internally) using what are called “handles.” A handle is just a numeric reference to a particular window. Certain Windows API functions expect a window handle, or hWnd. Prior to VFP 7, Visual FoxPro internally managed all of the forms and controls in a Visual FoxPro application, and did not bother with the overhead of creating the Windows structures needed to provide a handle.. Now, you simply have to ask a form for its hWnd property.

Usage

nhWnd = oObject.hWnd()

Only four kinds of objects have hWnd properties: forms, toolbars, and the _SCREEN and _VFP objects. hWnd contains a numeric value representing the window handle. This value can be passed to API calls that manipulate windows.

Example

* AnimateWindow is an API that applies animation effects when
* Windows are opened or closed.
DECLARE AnimateWindow IN Win32API ;
    LONG Thehwnd, LONG TimeInMilliSeconds, LONG Flags
oForm = CREATEOBJECT("Form")

* When the flag is 1, it "rolls" the form on from left to right.
AnimateWindow(oForm.hWnd, 500, 1)

* Try this with flags of 2, 5 and 16; and vary the number
* of milliseconds for some cool effects.
* A word of caution for this API: This window misbehaves.
* oForm.Hide now claims to be read-only, and oForm.Visible
* accepts values but doesn't change. Test your code using APIs
* <I></i>like these <i>thoroughly</I> before putting it into production.

See Also

Declare-DLL, Form, FoxTools, _SCREEN, Toolbar, _VFP