******************************************************************************
STATIC FUNCTION DsBldPopUp(fCol,gCol)
LOCAL OldPar := {ALIAS(),INDEXORD(),RECNO()}
LOCAL cRet := .F.
LOCAL dRet := .F.
DeleteObject(pMenu)
MEMORY(-1)
TMenuItem():New():nInitId := 20000
SYSREFRESH()
pMenu := NIL
MENU pMenu POPUP
SELECT MENT
SET ORDER TO 5
GO TOP
DO WHILE !EOF()
IF MENT->MNPOPUP = ShowArr[ShowLbx:nAt,17,1] .OR. MENT->MNPOPUP = 15
DO CASE
CASE MENT->MNSOORT = 1 ; DsMenuVul(dRet) ; dRet := .F. ; MENU
CASE MENT->MNSOORT = 2
SELECT DOC
SET ORDER TO 3
SEEK(VAL(MENT->MNDOC))
IF FOUND()
IF (MENT->MNPOPUP = 15 .AND. ShowArr[ShowLbx:nAt,17,1] <> 13) .OR. ;
(MENT->MNPOPUP = ShowArr[ShowLbx:nAt,17,1] .AND. ;
(DOC->DOCMAIL = 11 .OR. ;
((ShowArr[ShowLbx:nAt,17,2] = "1" .AND. (DOC->DOCMAIL = 2 .OR. DOC->DOCMAIL = 5 .OR. DOC->DOCMAIL = 6 .OR. DOC->DOCMAIL = 9)) .OR. ;
(ShowArr[ShowLbx:nAt,17,2] = "2" .AND. (DOC->DOCMAIL = 3 .OR. DOC->DOCMAIL = 5 .OR. DOC->DOCMAIL = 7 .OR. DOC->DOCMAIL = 9)) .OR. ;
(ShowArr[ShowLbx:nAt,17,2] = "3" .AND. (DOC->DOCMAIL = 4 .OR. DOC->DOCMAIL = 5 .OR. DOC->DOCMAIL = 8 .OR. DOC->DOCMAIL = 9)) .OR. ;
(ShowArr[ShowLbx:nAt,17,2] <> "1" .AND.ShowArr[ShowLbx:nAt,17,2] <> "2" .AND.ShowArr[ShowLbx:nAt,17,2] <> "3"))))
DsMenuVul(dRet,MENT->MNPOPUP,fCol,gCol) ; dRet := .F.
ENDIF
ENDIF
SELECT MENT
CASE MENT->MNSOORT = 3 ; dRet := .T.
CASE MENT->MNSOORT = 4 ; dRet := .F. ; ENDMENU
ENDCASE
cRet := .T.
ENDIF
SKIP
ENDDO
ENDMENU
SELECT(OldPar[1])
SET ORDER TO OldPar[2]
GOTO OldPar[3]
RETURN(cRet)
******************************************************************************
STATIC PROCEDURE DsMenuVul(mRet,mTel,hCol,iCol)
LOCAL cActie := ""
DEFAULT(mTel,0)
DEFAULT(hCol,0)
DEFAULT(iCol,0)
IF mRet ; SEPARATOR ; ENDIF
IF !EMPTY(cActie := MENT->MNACTIE)
IF hCol < iCol
cActie := ALLTRIM(cActie) + ",OpenBase(.T.),EndSub(.T.,,.T.)}"
ELSE
cActie := LEFT(ALLTRIM(cActie),LEN(ALLTRIM(cActie))-1) + ",,,,,,," + IF(mTel=1,".F.",".T.") + ",ShowLbx:nAt),OpenBase(.T.),EndSub(.T.,,.T.)}"
ENDIF
cActie := "{|| ToonWindow(),StartSub(.T.,,.T.)," + ALLTRIM(cActie)
MENUITEM (ALLTRIM(IF(EMPTY(MENT->MNPOPTXT),MENT->MNTEKST,MENT->MNPOPTXT)) + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),"")) BLOCK ({|| TvActie := cActie})
ELSE
MENUITEM (ALLTRIM(IF(EMPTY(MENT->MNPOPTXT),MENT->MNTEKST,MENT->MNPOPTXT)))
ENDIF
RETURN
******************************************************************************