Partager via


_WOpen( ) API Library Routine

Creates a new window at the coordinates specified by the top, left, bottom, and right parameters.

WHANDLE _WOpen(int top, int left, int bottom, int right, int flag, 
         int scheme_num, Scheme FAR *scheme, char FAR *bord)
int top;                     /* Row of top coordinate. */
int left;                     /* Column of left coordinate. */
int bottom;                  /* Row of bottom coordinate.  */
int right;                     /* Column of right coordinate. */
int flag;                     /* Attributes. */
int scheme_num;            /* Color scheme. */
Scheme FAR *scheme;      /* Points to color scheme to use. */
char FAR *bord;            /* Border type. */

Remarks

The window coordinates may be off the screen, but the height can't exceed 120 and the width can't exceed 264. Additional memory is allocated to hold the off-screen image of this window.

The flag parameter determines the attributes for this window. The flag may be one or more of the following flag values. You can combine multiple flag values using the C-language | or + operator. Typical window borders are defined in PRO_EXT.H.

flag Value Window attribute
WCURSOR The insertion point may be displayed in this window.
ZOOM The user may zoom the window.
ADJ The user may adjust the size of the window.
CLOSE The user may close the window.
MOVE The user may move the window.
AUTOSCROLL The window scrolls when output rolls off the bottom line.
WEVENT The window receives, activates, and deactivates events.
SHADOW The window casts a shadow.
WMODAL The user can't send this window to the back.
WMINIMIZE The user can minimize this window.

The scheme_num may be any valid color scheme number, or – 1 to indicate that the scheme parameter points to the color scheme to use.

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 windows using a number of different color schemes and borders. In particular, note the custom color scheme.

Visual FoxPro Code

SET LIBRARY TO WOPEN 

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   WHANDLE wh;

   Scheme customScheme =
   {
      (char) (BLACK_ON      | WHITE),
      (char) (RED_ON      | BLACK      | BLINK),
      (char) (WHITE_ON      | WHITE      | BRIGHT),
      (char) (CYAN_ON      | BLUE      | BRIGHT),
      (char) (GREEN_ON      | BROWN),
      (char) (BROWN_ON      | BROWN      | BRIGHT),
      (char) (MAGENTA_ON   | MAGENTA   | BRIGHT),
      (char) (RED_ON      | MAGENTA   | BRIGHT | BLINK),
      (char) (BROWN_ON      | GREEN      | BRIGHT),
      (char) (BLACK_ON      | CYAN),
      (char) (BLUE_ON      | CYAN),
   };

   _Execute("WAIT WINDOW 'Press any key to see a window \
      in WINDOW_SCHEME with WO_DOUBLEBOX border'");

   wh = _WOpen(2,2,20,70,WEVENT | CLOSE,WINDOW_SCHEME,(Scheme FAR *) 0,
      WO_DOUBLEBOX);
   _WShow(wh);

   _Execute("WAIT WINDOW 'Press any key to see a window \
      in ALERT_SCHEME with WO_SINGLEBOX border'");
   _WClose(wh);

   wh = _WOpen(2,2,20,70,WEVENT | CLOSE,ALERT_SCHEME, (Scheme FAR *) 0,
      WO_SINGLEBOX);
   _WShow(wh);

   _Execute("WAIT WINDOW 'Press any key to see a window \
      in WINDOW_SCHEME with WO_PANELBORDER border'");
   _WClose(wh);

   wh = _WOpen(2,2,20,70,WEVENT | CLOSE,WINDOW_SCHEME,(Scheme FAR *) 0,
      WO_PANELBORDER);
   _WShow(wh);

   _Execute("WAIT WINDOW 'Press any key to see a window \
      in a custom scheme with WO_SYSTEMBORDER border'");
   _WClose(wh);


   wh = _WOpen(2,2,20,70,WEVENT | CLOSE,-1,(Scheme FAR *) customScheme,
      WO_SYSTEMBORDER);
   _WShow(wh);


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

See Also

_WClose( ) API Library Routine | _WSelect( ) API Library Routine | _WSetTitle( ) API Library Routine | _WShow( ) API Library Routine | Accessing the Visual FoxPro API API Library Routine