Condividi tramite


_FindWindow( ) API Library Routine

Places the handle of the window that the point pt belongs to on the screen into wh.

int _FindWindow(WHANDLE FAR *wh, Point pt)
WHANDLE FAR *wh;      /* Pointer to window handle. */
Point pt;                     /* Point. */

Remarks

_FindWindow( ) returns an integer indicating the portion of the window where the point is located. For example, _FindWindow( ) returns the value inContent if the point is inside the window.

Possible return values, as defined in PRO_EXT.H, are listed in the following table.

_FindWindow( ) Return Values

Value

Point Location

inBorder

In the window border

inHelp

In the help region

inContent

In the content/text area

inDrag

On the title bar

inGrow

On the size control

inGoAway

On the close box

inZoom

On the zoom control

inVUpArrow

On the up arrow in the vertical scroll bar

inVDownArrow

On the down arrow in the vertical scroll bar

inVPageUp

In the page up region of the vertical scroll bar

inVPageDown

In the page down region of the vertical scroll bar

inVThumb

On the thumb in the vertical scroll bar

inHUpArrow

On the right arrow in the horizontal scroll bar

inHDownArrow

On the left arrow in the horizontal scroll bar

inHPageUp

In the page right region of the horizontal scroll bar

inHPageDown

In the page left region of the horizontal scroll bar

inHThumb

On the thumb in the horizontal scroll bar

inMenuBar

On the menu bar

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 waits for a left mouse button click and then uses _FindWindow( ) to get the window handle for the mouse down position.

Visual FoxPro Code

WAIT WINDOW  "Click mouse on a window" NOWAIT
SET LIBRARY TO FINDWIND

C Code

#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 FindWindowFn(ParamBlk FAR *parm)
{
   WHANDLE wh;
   Point mousePos;
   int where;

//  Get mouse position when left button goes down
   while (_InKey(0, MOUSEACTIVE | HIDECURSOR) != 151);
   while (!_MousePos(&mousePos));

   switch (where = _FindWindow(&wh, mousePos))
   {
      case inBorder:
         _PutStr("\nMouse down inBorder"); break;
      case inHelp:
         _PutStr("\nMouse down inHelp"); break;
      case inContent:
         _PutStr("\nMouse down inContent"); break;
      case inDrag:
         _PutStr("\nMouse down inDrag"); break;
      case inGrow:
         _PutStr("\nMouse down inGrow"); break;
      case inGoAway:
         _PutStr("\nMouse down inGoAway"); break;
      case inZoom:
         _PutStr("\nMouse down inZoom"); break;
      case inVUpArrow:
         _PutStr("\nMouse down inVUpArrow"); break;
      case inVDownArrow:
         _PutStr("\nMouse down inVDownArrow"); break;
      case inVPageUp:
         _PutStr("\nMouse down inVPageUp"); break;
      case inVPageDown:
         _PutStr("\nMouse down inVPageDown"); break;
      case inVThumb:
         _PutStr("\nMouse down inVThumb"); break;
      case inHUpArrow:
         _PutStr("\nMouse down inHUpArrow"); break;
      case inHDownArrow:
         _PutStr("\nMouse down inHDownArrow"); break;
      case inHPageUp:
         _PutStr("\nMouse down inHPageUp"); break;
      case inHPageDown:
         _PutStr("\nMouse down inHPageDown"); break;
      case inHThumb:
         _PutStr("\nMouse down inHThumb"); break;
      case inMenuBar:
         _PutStr("\nMouse down inMenuBar"); break;
      default:
         _PutStr("\nMouse down someplace else"); break;
   }
   _GlobalToLocal(&mousePos, wh);
   _PutStr("\nPosition relative to window:");
   putLong(mousePos.v, 5);
   _PutChr(' ');
   putLong(mousePos.h, 5);
}

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

See Also

Reference

_MousePos( ) API Library Routine

_FindWindowP( ) API Library Routine

Other Resources

API Library Construction

Accessing the Visual FoxPro API