Share via


_WSetPort( ) API Library Routine

Changes the user output window to be the specified window.

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

Remarks

_WSetPort( ) returns the handle of the previous user output window.

Note

If your routine changes the user output window, be sure to restore the user output window before returning to Visual FoxPro.

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 makes this the output port. It writes some text to this window before switching back to the original output port.

Visual FoxPro Code

SET LIBRARY TO WSETPORT

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 Example(ParamBlk FAR *parm)
{

   WHANDLE wh;
   WHANDLE oldPort;

   wh = _WOpen(2,10,23,70,WEVENT | CLOSE,WINDOW_SCHEME,(Scheme FAR *)0,
      WO_SYSTEMBORDER);
   _WShow(wh);

   _PutStr("\n1) _WGetPort() ="); putLong(_WGetPort(), 10);

   oldPort = _WSetPort(wh);
   _PutStr("\n2) _WSetPort(wh) ="); putLong(oldPort, 10);

   _PutStr("\n3) _WGetPort() ="); putLong(_WGetPort(), 10);

   oldPort = _WSetPort(oldPort);
   _PutStr("\n4) _WSetPort(oldPort) =");  putLong(oldPort, 10);

   _PutStr("\nShould be back where we started.");
}

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

See Also

Reference

_WGetPort( ) API Library Routine

_PutStr( ) API Library Routine

_WShow( ) API Library Routine

Other Resources

API Library Construction

Input and Output (Visual FoxPro)