JavaScript Editor js editor     Web development 

Main Page

Ensures that the selected text in the designated window is visible.

void _EdScrollToSel(WHANDLE wh, int Center)
WHANDLE wh;            /* Handle of editing window. */
int Center;                  /* Whether to center anchor point in
 window. */


Specify Center as TRUE to center the anchor point vertically in the window, or as FALSE to not center the anchor point.

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


The following example opens for editing a file specified by a parameter. The example makes a selection near the bottom of the file. After the user presses a key in response to a Visual FoxPro WAIT command, the example scrolls the editing window to the selection by calling _EdScrollToSel(В ). The example then repeats the operation for a selection made near the top of the file.

Visual FoxPro Code

В Copy Code
= TOSEL("x")

C Code

В Copy Code
#include <pro_ext.h>

void putLong(long n)
   Value val;

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


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, 
      _Error(182); // "Insufficient memory"
   pFILENAME[parm->p[0].val.ev_length] = '\0';

   wh = _EdOpenFile(pFILENAME, FO_READONLY);

   _EdScrollToPos(wh, 0, TRUE);

   _EdGetEnv(wh, &EdEnv);
   _EdSelect(wh, EdEnv.length - 16, EdEnv.length);

   _PutStr("\nMade selection at end of file.");
   _Execute("WAIT WINDOW 'Press any key to scroll to selection.'");

   _EdScrollToSel(wh, TRUE);
   _EdSelect(wh, 1, 16);

   _PutStr("\nMade selection at beginning of file.");
   _Execute("WAIT WINDOW 'Press any key to scroll to selection.'");

   _EdScrollToSel(wh, TRUE);

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

See Also

JavaScript Editor js editor     Web development