//-------------------------------------------------------------------
/*/{Protheus.doc}
Função de exemplo de relacionamento entre browses
@author Julio Teixeira
@since 29/01/2024
@version 1.0
/*/
//-------------------------------------------------------------------
User Function BrwRelat()
Local aCoors AS ARRAY
Local aRelation AS ARRAY
Local oPanelUp AS OBJECT
Local oFWLayer AS OBJECT
Local oPanelDown AS OBJECT
Local oDlgPrinc AS OBJECT
Local oBrowseUp AS OBJECT
Local oBrwDown AS OBJECT
Local oRelation AS OBJECT
aCoors := FWGetDialogSize( oMainWnd )
Define MsDialog oDlgPrinc Title "BrwRelat" From aCoors[1],aCoors[2] To aCoors[3],aCoors[4] Pixel
// Cria o container onde serão colocados os browses
oFWLayer := FWLayer():New()
oFWLayer:Init( oDlgPrinc, .F., .T. )
// Define Painel Superior
oFWLayer:AddLine( 'UPLINE', 55, .F. )
oFWLayer:AddCollumn( 'UPCOL', 100, .T., 'UPLINE' )
// Obtém objeto painel superior
oPanelUp := oFWLayer:GetColPanel( 'UPCOL', 'UPLINE' )
// Painel Inferior
oFWLayer:AddLine( 'DOWNLINE', 45, .F. )
oFWLayer:AddCollumn( 'DOWNCOL' , 100, .T., 'DOWNLINE' )
// Obtém objeto painel inferior
oPanelDown := oFWLayer:GetColPanel( 'DOWNCOL' , 'DOWNLINE' )
// FWMBrowse superior
oBrowseUp := FWMBrowse():New()
oBrowseUp:SetOwner( oPanelUp )
oBrowseUp:SetDescription( "Cabeçalho" )
oBrowseUp:DisableDetails()
oBrowseUp:SetAlias( 'SF1' )
oBrowseUp:Activate()
// FWMBrowse inferior
oBrwDown := FWMBrowse():New()
oBrwDown:SetOwner( oPanelDown )
oBrwDown:SetDescription( "Itens" )
oBrwDown:DisableDetails()
oBrwDown:SetAlias( 'SD1' )
oBrwDown:Activate()
// Relacionamento entre os browses
oRelation := FWBrwRelation():New()
aRelation := { { 'D1_FILIAL', 'F1_FILIAL' }, { 'D1_DOC', 'F1_DOC' }, {'D1_SERIE','F1_SERIE'}, {'D1_FORNECE','F1_FORNECE'}, {'D1_LOJA','F1_LOJA'} }
oRelation:AddRelation( oBrowseUp , oBrwDown , aRelation )
oRelation:Activate()
Activate MsDialog oDlgPrinc Center
oBrowseUp:DeActivate()
oBrowseUp:Destroy()
oBrwDown:DeActivate()
oBrwDown:Destroy()
FreeObj(oBrowseUp)
FreeObj(oBrwDown)
FreeObj(oRelation)
FreeObj(oDlgPrinc)
FreeObj(oPanelUp)
FreeObj(oFWLayer)
FreeObj(oPanelDown)
Return