Amigos
El SetBrnGet es de TSBrowse, como es en xBrowse?
Que sirve para poder pulsar una tecla asignada para realizar una acción cuando estamos usando bEditBlock, además permite colocar una imagen
Gracias por la ayuda.
Saludos,
Adhemar
#include "fivewin.ch"
REQUEST DBFCDX
function Main()
local oWnd, oBar, oFont
Private lPued:=.T.
RDDSetDefault( "DBFCDX" )
SET DELETED ON
if ! File( 'TestTrn.Dbf' )
CreateTestDbf()
endif
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE WINDOW oWnd MDI
oWnd:SetFont( oFont )
DEFINE BUTTONBAR oBar OF oWnd SIZE 100,32 2007
SET MESSAGE OF oWnd TO '' 2007
DEFINE BUTTON OF oBar PROMPT "XBrowse" ACTION XbrAppend( This )
DEFINE BUTTON OF oBar PROMPT "Quit" ACTION oWnd:End()
ACTIVATE WINDOW oWnd
RELEASE FONT oFont
return 0
static function XbrAppend( oBtn )
local oWnd, oBrw
oBtn:Disable()
USE TESTTRN NEW ALIAS TRN EXCLUSIVE
DEFINE WINDOW oWnd MDICHILD OF WndMain()
@ 0,0 XBROWSE oBrw OF oWnd ;
COLUMNS 'Code', 'Item', 'Rate', 'Quantity' ;
ALIAS 'TRN' CELL LINES FASTEDIT
oBrw:Amount := { || oBrw:Rate:Value * oBrw:Quantity:Value }
WITH OBJECT oBrw
:Cargo := 0
WITH OBJECT :Code
:nEditType := 5 //EDIT_BUTTON
:bEditBlock := { || SelectItem( oBrw ) }
END
:Quantity:nEditType := EDIT_GET
:bPastEof := { || (oBrw:cAlias)->( AppendRec( oBrw ) ) }
:bChange := { || (oBrw:cAlias)->( CheckAppend( oBrw ) ) }
END
oBrw:CreateFromCode()
oWnd:oClient := oBrw
oWnd:bPostEnd := { || TRN->( DbCloseArea() ), oBtn:Enable() }
ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus() ;
VALID CheckAppend( oBrw, .t. )
return nil
static function AppendRec( oBrw )
if oBrw:Cargo == 0 // not in append mode
APPEND BLANK
GO BOTTOM
oBrw:Cargo := RecNo()
oBrw:Refresh()
oBrw:GoLeftMost()
oBrw:Code:Edit()
endif
return nil
static function CheckAppend( oBrw, lExit )
local nRecNo := RecNo()
DEFAULT lExit := .f.
if oBrw:Cargo > 0 .and. ( lExit .or. oBrw:Cargo != nRecNo )
GOTO oBrw:Cargo
DELETE
oBrw:Cargo := 0
if ! lExit
GOTO nRecNo
oBrw:Refresh()
endif
endif
if lExit
PACK
endif
return .t.
static function SelectItem( oBrw1 )
local aItems := { { 1, "Item.1", 20 }, { 2, "Item.2", 30 }, { 3, "Item.3", 40 } }
local nRet := oBrw1:Code:Value
XBROWSER aItems ;
SETUP ( oBrw:cHeaders := { "Code", "Item", "Rate" } ) ;
SELECT ( nRet := oBrw:aRow[ 1 ], ;
oBrw1:Item:Value := oBrw:aRow[ 2 ], ;
oBrw1:Rate:Value := oBrw:aRow[ 3 ], ;
oBrw1:Cargo := 0, ;
oBrw1:nColSel := 4, ;
oBrw1:Refresh() )
return nRet
//----------------------------------------------------------------------------//
static function CreateTestDbf()
local aCols := { ;
{ "CODE", "N", 4, 0 }, ;
{ "ITEM", "C", 20, 0 }, ;
{ "RATE", "N", 6, 2 }, ;
{ "QUANTITY", "N", 4, 0 } }
DBCREATE( "TESTTRN", aCols )
USE TESTTRN EXCLUSIVE
APPEND BLANK
FIELD->CODE := 1
FIELD->ITEM := "Item.1"
FIELD->RATE := 20
FIELD->QUANTITY := 3
CLOSE TESTTRN
return nil
static function XbrAppend( oBtn )
local oWnd, oBrw
oBtn:Disable()
USE TESTTRN NEW ALIAS TRN EXCLUSIVE
DEFINE WINDOW oWnd MDICHILD OF WndMain()
@ 0,0 XBROWSE oBrw OF oWnd ;
COLUMNS 'Code', 'Item', 'Rate', 'Quantity' ;
ALIAS 'TRN' CELL LINES FASTEDIT
oBrw:Amount := { || oBrw:Rate:Value * oBrw:Quantity:Value }
WITH OBJECT oBrw
:Cargo := 0
WITH OBJECT :Code
:nEditType := 5 //EDIT_BUTTON
:bEditBlock := { || SelectItem( oBrw ) }
END
:Quantity:nEditType := EDIT_GET
:bPastEof := { || (oBrw:cAlias)->( AppendRec( oBrw ) ) }
:bChange := { || (oBrw:cAlias)->( CheckAppend( oBrw ) ) }
END
oBrw:bKeyDown = { | nKey | If( oBrw:nColSel == 1 .and. nKey == VK_F2, oBrw:SelectedCol():RunBtnAction(), ) }
oBrw:CreateFromCode()
oWnd:oClient := oBrw
oWnd:bPostEnd := { || TRN->( DbCloseArea() ), oBtn:Enable() }
ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus() ;
VALID CheckAppend( oBrw, .t. )
return nil
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 23 guests