_WhToHwnd( ) API Library Routine

Returns the Windows HWND of the specified WHANDLE.

HWND_WhToHwnd(WHANDLE wh)
WHANDLE wh;            /* Window handle. */

Remarks

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example creates a window and then obtains the Windows HWND for the window with the callback _WhToHwnd( ). Then, to verify the value returned by _WhToHwnd( ), the example uses the HWND as an argument to a Windows function.

Visual FoxPro Code

SET LIBRARY TO WHTOHWND

C Code

#include <windows.h>
#include <pro_ext.h>

void putLong(long n, int width)
{
   Value val;

   val.ev_type = 'I';
   val.ev_long = n;
   val.ev_width = width;

   _PutValue(&val);
}

FAR WhToHwndEx(ParamBlk FAR *parm)
{
   RECT Rect;
   HWND hwnd;
   WHANDLE wh;
   Value val;

   wh = _WOpenP(10,10,120,240,CLOSE,WINDOW_SCHEME, (Scheme FAR *) 0,
      WO_SYSTEMBORDER);
   _WShow(wh);

//   Get Windows window handle and use as a parameter 
//   to a Windows function
   hwnd = _WhToHwnd(wh);
   GetWindowRect(hwnd, &Rect); // Windows function

   _PutStr("\ntop   ="); putLong(Rect.top, 5);
   _PutStr("\nleft ="); putLong(Rect.left, 5);
   _PutStr("\nbottom ="); putLong(Rect.bottom, 5);
   _PutStr("\nright  ="); putLong(Rect.right, 5);
}

FoxInfo myFoxInfo[] = {
   {"ONLOAD", WhToHwndEx, CALLONLOAD,  ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_WFindTitle( ) API Library Routine | _WOpen( ) API Library Routine | Accessing the Visual FoxPro API