xHarbour Reference Documentation > Command Reference |
Creates a Get object as browser and displays it to the screen
@ <nTop>, <nLeft>, <nBottom>, <nRight> ; GET <xVar> ; TBROWSE <oTBrowse> ; [MESSAGE <cMessage>] ; [WHEN <lWhen>] ; [VALID <lValid>] ; [SEND <msg>] ; [GUISEND <guimsg>] ;
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.
See also: | @...GET, Get(), TBrowse() |
Category: | Get system , Input commands |
Source: | rtl\listbox.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// 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
http://www.xHarbour.com