by vensanto » Thu Mar 13, 2014 4:16 pm
the problem is when i close the window
anytime go to error
regards
********************************************************************************************************************* // xBROWSE
Function XBRW_DB(nDBF,aDB,nFUN,nDES,nSRC,nSTA,nFIL,nBUT,oUSR,nSCH,nICO,bSALDO,nTAG,bCOLOR,bPOP,oFONT,bGO,nUFLT,bUKEY)
Local oWIN,oICO,oXDBF,oBAR,oPOPEXP
Local oBRW,nUSR:=0
Local oINS,oMOD,oCAN,oVIS,oANT,oSTA,oSRC,oFLT,oEXP
Local nUNO:=StrTran(IIF(AT("/",nDES)>0,Left(nDES,Len(nDES)-2),nDES) ,CHR(34),"")
Local nDUE:=StrTran(IIF(AT("/",nDES)>0,Left(nUNO,Len(nUNO)-1)+Right(nDES,1),nDES),CHR(34),"")
Local nTIT:=nDUE
Local nFILE:=Upper(StrTran(Alltrim(nTIT)," ","_"))
Local nARG:={}
Local nBT1:=IIF(nBUT<>NIL,IIF(AT("1",nBUT)>0,.T.,.F.),.T.) // Ins
Local nBT2:=IIF(nBUT<>NIL,IIF(AT("2",nBUT)>0,.T.,.F.),.T.) // Mod
Local nBT3:=IIF(nBUT<>NIL,IIF(AT("3",nBUT)>0,.T.,.F.),.T.) // Can
Local nBT4:=IIF(nBUT<>NIL,IIF(AT("4",nBUT)>0,.T.,.F.),.T.) // Vis
Local nBT5:=IIF(nBUT<>NIL,IIF(AT("5",nBUT)>0,.T.,.F.),.T.) // Ante
Local nBT6:=IIF(nBUT<>NIL,IIF(AT("6",nBUT)>0,.T.,.F.),.T.) // Stampa
Local nBT7:=IIF(nBUT<>NIL,IIF(AT("7",nBUT)>0,.T.,.F.),.T.) // Ricerca
Local nBT8:=IIF(nBUT<>NIL,IIF(AT("8",nBUT)>0,.T.,.F.),.T.) // Filtro
Local nBT9:=IIF(nBUT<>NIL,IIF(AT("9",nBUT)>0,.T.,.F.),.T.) // Export
Local oBUT1,oBUT2,oBUT3,oBUT4,oBUT5,oBUT6,oBUT7,oBUT8,oBUT9
Local oSALDO,nSALDO:="",nAREA
Local nUSRFLT:=IIF(nUFLT<>NIL,.T.,.F.)
oXDBF:=APRI_DB(nDBF)
(oXDBF)->(DBSetIndex(nDBF))
IF Len(aDB) > 0
IF !Empty( aDB[1][5] )
(oXDBF)->(DBSetOrder( aDB[1][5] ))
Endif
Endif
IF nFIL<>NIL
IF !Empty(AllTrim(nFIL))
(oXDBF)->( CMFILTER( nFIL ) )
Endif
Endif
(oXDBF)->(DBGoTop())
IF bGO<>NIL
(oXDBF)->(DBGoBottom())
Endif
nAREA:=ALIAS()
IF !Empty(nICO)
DEFINE ICON oICO RESOURCE (nICO+"_ICO")
Else
DEFINE ICON oICO RESOURCE (nFUN+"_ICO")
Endif
DEFINE WINDOW oWIN MDICHILD TITLE nTIT ICON oICO FROM 0,0 TO 0,0 PIXEL
oBRW:=XBRW_CREA(oWIN,aDB,oXDBF,,oFONT,,,,,,nTAG,,bCOLOR)
nARG:={oWIN,oXDBF,oBRW,oICO,nFUN,nUNO,nDUE,nSRC,aDB,nSCH,nICO,nDBF,bSALDO,oSALDO,nTAG,bCOLOR,nUSRFLT,bUKEY}
DEFINE BUTTONBAR oBAR OF oWIN SIZE 70,60 TOP
oBAR:l2007:=.T.
...
oBRW:bKeyDown :={|Key| XBRW_KEY(Key,nARG,oINS,oMOD,oCAN,oVIS,oANT,oSTA,oSRC,oFLT,oEXP,bUKEY)}
oBRW:bRClicked :={|R,C| XBRW_POP(R,C,nARG,oINS,oMOD,oCAN,oVIS,oANT,oSTA,oSRC,oFLT,oEXP,bPOP)}
oWIN:oClient:=oBRW
oWIN:SetControl(oBRW)
ACTIVATE WINDOW oWIN ON INIT WndAdjClient(oWIN:hWnd) ;
VALID ( oBrw:bKeyCount:={||0} , oBrw:bKeyNo := {||0} , CLOSE_DB(oXDBF) , .T. )
Return .T.
************************ // Close DataBase
Function CLOSE_DB(oDBF)
IF oDBF<>NIL
(oDBF)->(DBCloseArea())
Return .T.
Endif
Return .F.