xHarbour Reference Documentation > Function Reference |
Creates a new window.
WOpen( <nTop> , ; <nLeft> , ; <nBottom> , ; <nRight> , ; [<lClear>] ) --> nWindowID
The function returns the ID of the new window as a numeric value. this Window ID must be passed to WSelect() to select it as the current window.
See also: | WBoard(), WClose(), WSelect(), WStack() |
Category: | CT:Window , Windows (text mode) |
Source: | ct\ctwin.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example opens three windows using different colors. The // windows are selected with Ctrl+Tab and can be moved interactively // with the cursor keys when Alt+M is pressed. #include "Inkey.ch" #define K_CTRL_SH_TAB 423 PROCEDURE Main LOCAL nKey, nWin, aWin LOCAL nT := 4, nL := 4, nW := 50, nH := 15 LOCAL aColor := { "W+/B", "W+/R", "W+/G", "W+/BG" } SET COLOR TO (aColor[1]) CLS WBoard( 2, 2, MaxRow()-2, MaxCol()-2 ) WMode( .T., .T., .T., .T. ) WSetMove( .F. ) WSetShadow( 8 ) SET COLOR TO N/W @ 2, 2 CLEAR TO MaxRow()-2, MaxCol()-2 FOR i:=1 TO 3 SetColor( aColor[i+1] ) nWin := WOpen( nT, nL, nT+nH, nL+nW, .T. ) WBox() @ 0,0 SAY "Window: " + Str(i,1) nT += 2 nL += 4 NEXT aWin := WStack() DO WHILE .T. nKey := Inkey(0) DO CASE CASE nKey == K_ESC EXIT CASE nKey == K_CTRL_TAB i := AScan( aWin, nWin ) + 1 IF i > Len( aWin ) // Skip over entire screen i := 2 ENDIF nWin := aWin[i] WSelect( nWin ) SetColor( aColor[i] ) CASE nKey == K_CTRL_SH_TAB i := AScan( aWin, nWin ) - 1 IF i < 2 // Skip over entire screen i := Len( aWin ) ENDIF nWin := aWin[i] WSelect( nWin ) SetColor( aColor[i] ) CASE nKey == K_ALT_M WSetMove( .NOT. WSetMove() ) IF WSetMove() ? "Cursor keys move window" ELSE ? "Moveing window switched off" ENDIF CASE nKey == K_UP IF WSetMove() nT := WRow() - 1 nL := WCol() WMove( nT, nL ) ELSE ? "Press Alt+M to move window" ENDIF CASE nKey == K_DOWN IF WSetMove() nT := WRow() + 1 nL := WCol() WMove( nT, nL ) ELSE ? "Press Alt+M to move window" ENDIF CASE nKey == K_LEFT IF WSetMove() nT := WRow() nL := WCol() - 1 WMove( nT, nL ) ELSE ? "Press Alt+M to move window" ENDIF CASE nKey == K_RIGHT IF WSetMove() nT := WRow() nL := WCol() + 1 WMove( nT, nL ) ELSE ? "Press Alt+M to move window" ENDIF OTHERWISE ? "Key:", nKey ENDCASE ENDDO WAClose() RETURN
http://www.xHarbour.com