Compartir a través de


_EdScrollToPos( ) API Library Routine

Ensures that the offset position you specify in the file in the designated editing window is visible.

void _EdScrollToPos(WHANDLE wh, EDPOS thePos, int Center)
WHANDLE wh;            /* Handle of editing window. */
EDPOS thePos;               /* Offset position to make visible. */
int Center;                  /* Whether or not to center position
 in window. */

Remarks

_EdScrollToPos( ) doesn't move the insertion point. Specify Center as TRUE to center the position vertically in the window, or as FALSE to not center the position vertically.

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 opens for editing a file specified by a parameter. After scrolling to the top of the file by calling _EdScrollToPos( ), the procedure calls _EdPosInView( ) to check whether the top of file and bottom of file are in view, and prints the results on the screen. Then it scrolls to the bottom of the file by calling _EdScrollToPos( ), and again calls _EdPosInView( ) to check whether the top of file and bottom of file are in view.

Visual FoxPro Code

SET LIBRARY TO EDSCTOPO
= POSINVIEW("x")

C Code

#include <pro_ext.h>

void putLong(long n)
{
   Value val;

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

   _PutValue(&val);
}

FAR Example(ParamBlk FAR *parm)
{
#define pFILENAME ((char FAR *) _HandToPtr(parm->p[0].val.ev_handle))

   WHANDLE wh;
   EDENV EdEnv;

   if (!_SetHandSize(parm->p[0].val.ev_handle, 
      parm->p[0].val.ev_length+1)) {
      _Error(182); // "Insufficient memory"
   }
   pFILENAME[parm->p[0].val.ev_length] = '\0';

   _HLock(parm->p[0].val.ev_handle);
   wh = _EdOpenFile(pFILENAME, FO_READONLY);
   _HUnLock(parm->p[0].val.ev_handle);

   _EdGetEnv(wh, &EdEnv);

   _EdScrollToPos(wh, 0, FALSE);
   _PutStr("\n_EdScrollToPos(wh, 0)");
   _PutStr("\n_EdPosInView(wh, 0) =");
   putLong(_EdPosInView(wh, 0));
   _PutStr("\n_EdPosInView(wh, EdEnv.length) =");
   putLong(_EdPosInView(wh, EdEnv.length));

   _EdScrollToPos(wh, EdEnv.length, FALSE);
   _PutStr("\n_EdScrollToPos(wh, EdEnv.length)");
   _PutStr("\n_EdPosInView(wh, 0) =");
   putLong(_EdPosInView(wh, 0));
   _PutStr("\n_EdPosInView(wh, EdEnv.length) =");
   putLong(_EdPosInView(wh, EdEnv.length));
}

FoxInfo myFoxInfo[] = {
   {"POSINVIEW", (FPFI) Example, 1, "C"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

Reference

_EdPosInView( ) API Library Routine

SYS(2002) - Turn Insertion Point On or Off

_EdInsert( ) API Library Routine

Other Resources

API Library Construction

Accessing the Visual FoxPro API