xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

@...GET TBROWSE

Creates a Get object as browser and displays it to the screen

Syntax

@ <nTop>, <nLeft>, <nBottom>, <nRight> ;
      GET <xVar> ;
  TBROWSE <oTBrowse> ;
 [MESSAGE <cMessage>] ;
    [WHEN <lWhen>] ;
   [VALID <lValid>] ;
    [SEND <msg>] ;
 [GUISEND <guimsg>] ;

Arguments

@ <nTop>, <nLeft>, <nBottom>, <nRight>
Numeric values indicating the screen coordinates for the upper left and the lower right corner of the browse output. The range for rows on the screen is 0 to MaxRow(), and for columns it is 0 to MaxCol(). The coordinate 0,0 is the upper left corner of the screen.
GET <xVar>
This is a memory or field variable holding a logical value. It is required as a place holder for the Get, and is not changed when the READ command is terminated.
TBROWSE <oTBrowse>
This must be a completely configured TBrowse() object to be associated with the new Get.
MESSAGE <cMessage>
This is an optional character string displayed in the message row when the TBrowse object has input focus. The message row is defined with the MSG AT option of the READ command.
WHEN <lWhen>
This is a logical expression or a code block returning a logical value. If specified, <lWhen> must result in .T. (true) to allow editing. If the expression yields .F. (false), the TBrowse object cannot receive input focus.
VALID <lValid>
This is a logical expression or a code block returning a logical value. If specified, <lValid> must result in .T. (true) to end browsing. When the result is .F. (false), the currently selected item is invalid and the user cannot leave the TBrowse unless browsing is cancelled.
SEND <msg>
This is an optional message to be sent to the Get object before it is displayed. Refer to the Get class for possible messages that can be sent to the Get object.
GUISEND <guimsg>
This is an optional message to be sent to the HbListbox() object associated with the Get() object before both are displayed. Refer to the TBrowse class for possible messages that can be sent to the TBrowse object.

Description

The @...GET TBROWSE command creates a Get() object and assigns a TBrowse() object to the oGet:control instance variable. The TBrowse object must be configured and displays data of the underlying data source (database or array) in a text mode browse view which and allows a user navigate the data source within the READ command.

The Get object created with @...GET TBROWSE is stored in the current Getlist array. The Get object communicates with the associated TBrowse object while the READ command is active. This communication ensures that focus and selection changes are properly displayed on the screen.

Info

See also:@...GET, Get(), TBrowse()
Category: Get system , Input commands
Source:rtl\listbox.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example combines three Get entry fields with a browse
// and three push buttons. When the database is navigated
// and the user selects a record with the Enter key, READ
// is terminated and restarted with new data read from the
// selected record.

   #include "GetExit.ch"
   #include "Inkey.ch"

   PROCEDURE Main
      LOCAL cLName, cFName, cPhone
      LOCAL lBtn1   := .F.
      LOCAL lBtn2   := .F.
      LOCAL lBtn3   := .F.
      LOCAL nBtn    := 0
      LOCAL dummy   := NIL
      LOCAL cGetClr := "W+/B,W+/R,N/BG,GR+/BG"
      LOCAL cBtnClr := "N/G,W+/G,GR+/N,GR+/G"
      LOCAL oTBrowse, aCOlumns[3], bSkip, bSaved

      SET EVENTMASK TO INKEY_ALL
      SET COLOR TO N/BG
      CLS

      USE Customer ALIAS Cust
      oTBrowse           := TBrowseDb( 8, 50, 14, 72 )
      oTBrowse:colorSPec := cGetClr
      oTBrowse:headSep   := "-"
      oTBrowse:cargo     := Recno()

      aColumns[1] := TBColumnNew( "Last" , {|| CUst->LastName  } )
      aColumns[2] := TBColumnNew( "First", {|| CUst->FirstName } )
      aColumns[3] := TBColumnNew( "Phone", {|| CUst->Phone     } )

      AEval( aCOlumns, {|o| oTBrowse:addColumn(o) } )

      cFName := Cust->FirstName
      cLName := Cust->LastName
      cPhone := Cust->Phone

      @  8, 20 GET cFName ;
           CAPTION "&First name:" ;
             COLOR cGetClr

      @ 10, 20 GET cLName ;
           CAPTION " &Last name:" ;
             COLOR cGetClr

      @ 12, 20 GET cPhone ;
           CAPTION "     &Phone:" ;
             COLOR cGetClr

      @  8, 50, 14, 72 GET dummy ;
                   TBROWSE oTBrowse ;
                   GUISEND forceStable() ;
                     VALID {|| nBtn := RecChanged( oTBrowse ), .T. }

      @ 16, 20 GET lBtn1 PUSHBUTTON ;
           CAPTION " &Save " ;
             COLOR cBtnClr ;
             STATE {|| nBtn := IsPressed( 1 ) }

      @ 16, 30 GET lBtn2 PUSHBUTTON ;
           CAPTION " &Undo " ;
             COLOR cBtnClr ;
             STATE {|| nBtn := IsPressed( 2 ) }

      @ 16, 40 GET lBtn3 PUSHBUTTON ;
           CAPTION " E&xit " ;
             COLOR cBtnClr ;
             STATE {|| nBtn := IsPressed( 3 ) }

      DO WHILE nBtn == 0
         READ SAVE

         DO CASE
         CASE nBtn == 1
            IF RLock()
               REPLACE Cust->FirstName WITH cFName
               REPLACE Cust->LastName  WITH cLName
               REPLACE Cust->Phone     WITH cPhone
               DbCommit()
               DbUnlock()
            ENDIF

         CASE nBtn == 2
            cFName := Cust->FirstName
            cLName := Cust->LastName
            cPhone := Cust->Phone
            nBtn   := 0
            AEval( GetList, {|oGet| oGet:display() } )
         CASE nBtn == 3
           nBtn := 0
         ENDCASE
      ENDDO

      ASize( GetList, 0 )
      CLOSE ALL
   RETURN


   FUNCTION RecChanged()
      LOCAL oGet     := GetActive()
      LOCAL oTBrowse := oGet:control
      LOCAL nButton  := 0

      IF oGet:exitState == GE_ENTER
         IF oTBrowse:cargo <> Recno()
            ReadKill( .T. )
            nButton := 2
         ENDIF
      ELSE
         DbGoto( oTBrowse:cargo )
         oTBrowse:refreshAll()
         oTBrowse:forceStable()
      ENDIF

   RETURN nButton


   FUNCTION IsPressed( nButton )
      IF GetActive():control:buffer
         ReadKill( .T. )
      ELSE
         nButton := 0
      ENDIF
   RETURN nButton

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe