次の方法で共有


_FindWindowP( ) API Library Routine

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

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

Remarks

_FindWindowP( ) returns an integer indicating the portion of the window where the point is located. For possible return values, see _FindWindow( ) API Library Routine.

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 _FindWindowP( ) to get the window handle for the mouse down position.

Visual FoxPro Code

WAIT WINDOW "Click Mouse In Window" NOWAIT
SET LIBRARY TO FINDWINP

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

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

   switch (where = _FindWindowP(&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;
   }
   _GlobalToLocalP(&mousePos, wh);
   _PutStr("\nPosition relative to window:");
   putLong(mousePos.v, 5);
   _PutChr(' ');
   putLong(mousePos.h, 5);
}

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

See Also

_FindWindow( ) API Library Routine | _MousePos( ) API Library Routine | Accessing the Visual FoxPro API