The reason for the menu to be changed while running my application, has to do with priorities, but also with adding documents in menus that have been added, etc.
Code: Select all
FUNCTION BuildMenu1
LOCAL OldPar := {ALIAS(),INDEXORD(),RECNO()}
DeleteObject(oMenu)
MEMORY(-1)
SYSREFRESH()
SELECT US
SET ORDER TO 3
SEEK(UPPER(nUser))
oMenu := NIL
MENU oMenu
FOR i=1 TO 8
IF i<> 4
SELECT MEN
SET ORDER TO i
ELSE
SELECT MENT
SET ORDER TO 3
ENDIF
GO TOP
IF !EOF() .AND. &("MEN"+IF(i=4,"T","")+"->MNNR") = i .AND. &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 0
IF xPriority >= &("MEN"+IF(i=4,"T","")+"->MNPRIOR") .AND. (US->RSCHERM .OR. (!US->RSCHERM .AND. i <> 6))
MENUITEM &("oMenu"+STR(i,1,0)) PROMPT ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT")))
MENU
SKIP
IF i = 4 .AND. MENT->MNSOORT = 3 ; SKIP ; ENDIF
DO WHILE !EOF() .AND. &("MEN"+IF(i=4,"T","")+"->MNNR") = i
IF ((xPriority >= &("MEN"+IF(i=4,"T","")+"->MNPRIOR")) .OR. (IF(i=4,.T.,MEN->MNPRIVE .AND. xBoekExt<>"PAR"))) .AND. ((i = 4 .OR. (i <> 4 .AND. ((PAR->BKWISSEL .AND. MEN->MNBOEKH .AND. (!EMPTY(US->UBOEPATH) .AND. ALLTRIM(US->UBOEPATH) <> "\") .OR. (PAR->DOSBOEKH .AND. DOSS->DOSBOEKH)) .OR. !MEN->MNBOEKH)))) .AND. (&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 0 .OR. (&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") <> 0)) .AND. (i = 4 .OR. (i <> 4 .AND. ((!US->RSCHERM .AND. i <> 6) .OR. (US->RSCHERM .AND. (i = 6 .OR. !MEN->MNSCHERM)))))
IF i<>4 .OR. !MENT->MNPOPACT
IF (&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 0) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 1 .AND. PAR->OZDOSSIER) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 2 .AND. PAR->OZONDERW ) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 3 .AND. PAR->OZONDERV ) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 4 .AND. PAR->OZDATUM ) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 5 .AND. PAR->OZNUMMER ) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 6 .AND. (PAR->OZDOSSIER .OR. PAR->OZONDERW .OR. PAR->OZONDERV .OR. PAR->OZDATUM .OR. PAR->OZNUMMER))
IF i=4 .OR. (i<>4 .AND. (MEN->MNSRTBH = 0 .OR. ((((&(xBoekExt+"->SRTBOEKH") <> 2 .AND. MEN->MNSRTBH = 1) .OR. (&(xBoekExt+"->SRTBOEKH") = 2 .AND. MEN->MNSRTBH = 2))))))
DO CASE
CASE &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 1 ; VulMenu1(i) ; MENU
CASE &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 2 ; VulMenu1(i)
CASE &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 3 ; SEPARATOR
CASE &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 4 ; ENDMENU
ENDCASE
ENDIF
ENDIF
ENDIF
ENDIF
SKIP
ENDDO
ENDMENU
ENDIF
ENDIF
NEXT
ENDMENU
SELECT(OldPar[1])
SET ORDER TO OldPar[2]
GOTO OldPar[3]
RETURN(.T.)
******************************************************************************
PROCEDURE VulMenu1(i)
LOCAL cActie
IF !EMPTY(cActie := &("MEN"+IF(i=4,"T","")+"->MNACTIE")) .AND. UPPER(LEFT(&("MEN"+IF(i=4,"T","")+"->MNACTIE"),1)) <> "*" .AND. UPPER(LEFT(&("MEN"+IF(i=4,"T","")+"->MNACTIE"),4)) <> "REM "
IF i <> 4
cActie := "{||StartSub(MEN->MNDISABLE)," + ALLTRIM(cActie) + ",EndSub(MEN->MNDISABLE)}"
ELSE
cActie := LEFT(ALLTRIM(cActie),LEN(ALLTRIM(cActie))-1) + ",OpenBase(.T.)}"
ENDIF
IF !EMPTY(&("MEN"+IF(i=4,"T","")+"->MNVIRTKEY"))
IF i = 2 .AND. AT("TAALACT(1)",UPPER(MEN->MNACTIE)) <> 0
MENUITEM ("Agendacontrole "+IF(US->UAGCONTR,"uitschakelen","inschakelen") + IF(!EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),"")) BLOCK &(cActie) ACCELERATOR MEN->MNSTATE,MEN->MNVIRTKEY
ELSEIF i = 4 .AND. MENT->MNVOLGNR >= 9999978 .AND. MENT->MNVOLGNR <= 9999980
MENUITEM (IF(MENT->MNVOLGNR=9999978,"Taalkeuze",IF(MENT->MNVOLGNR=9999979,"Taal spellingcontrole","Controle lettertekens"))+" "+IF((MENT->MNVOLGNR=9999978 .AND. US->UTXTTAAL) .OR. (MENT->MNVOLGNR=9999979 .AND. US->UTXTSPEL) .OR. (MENT->MNVOLGNR=9999980 .AND. US->UTXTFLET),"uitschakelen","activeren") + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),"")) BLOCK &(cActie) ACCELERATOR MENT->MNSTATE,MENT->MNVIRTKEY
ELSE
MENUITEM (ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT"))) + IF(!EMPTY(&("MEN"+IF(i=4,"T","")+"->MNFKEY")),CHR(9)+ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MNFKEY")),"")) BLOCK &(cActie) ACCELERATOR &("MEN"+IF(i=4,"T","")+"->MNSTATE"),&("MEN"+IF(i=4,"T","")+"->MNVIRTKEY")
ENDIF
ELSE
IF i = 2 .AND. AT("TAALACT(1)",UPPER(MEN->MNACTIE)) <> 0
MENUITEM ("Agendacontrole "+IF(US->UAGCONTR,"uitschakelen","inschakelen") + IF(!EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),"")) BLOCK &(cActie)
ELSEIF i = 4 .AND. MENT->MNVOLGNR >= 9999978 .AND. MENT->MNVOLGNR <= 9999980
MENUITEM (IF(MENT->MNVOLGNR=9999978,"Taalkeuze",IF(MENT->MNVOLGNR=9999979,"Taal spellingcontrole","Controle lettertekens"))+" "+IF((MENT->MNVOLGNR=9999978 .AND. US->UTXTTAAL) .OR. (MENT->MNVOLGNR=9999979 .AND. US->UTXTSPEL) .OR. (MENT->MNVOLGNR=9999980 .AND. US->UTXTFLET),"uitschakelen","activeren") + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),"")) BLOCK &(cActie)
ELSE
MENUITEM (ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT"))) + IF(!EMPTY(&("MEN"+IF(i=4,"T","")+"->MNFKEY")),CHR(9)+ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MNFKEY")),"")) BLOCK &(cActie)
ENDIF
ENDIF
ELSE
IF &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 2
IF i = 2 .AND. AT("TAALACT(1)",UPPER(MEN->MNACTIE)) <> 0
MENUITEM ("Agendacontrole "+IF(US->UAGCONTR,"uitschakelen","inschakelen") + IF(!EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),"")) DISABLED
ELSEIF i = 4 .AND. MENT->MNVOLGNR >= 9999978 .AND. MENT->MNVOLGNR <= 9999980
MENUITEM (IF(MENT->MNVOLGNR=9999978,"Taalkeuze",IF(MENT->MNVOLGNR=9999979,"Taal spellingcontrole","Controle lettertekens"))+" "+IF((MENT->MNVOLGNR=9999978 .AND. US->UTXTTAAL) .OR. (MENT->MNVOLGNR=9999979 .AND. US->UTXTSPEL) .OR. (MENT->MNVOLGNR=9999980 .AND. US->UTXTFLET),"uitschakelen","activeren") + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),"")) DISABLED
ELSE
MENUITEM (ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT"))) + IF(i<>4 .AND. !EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),"")) DISABLED
ENDIF
ELSE
IF i = 2 .AND. AT("TAALACT(1)",UPPER(MEN->MNACTIE)) <> 0
MENUITEM ("Agendacontrole "+IF(US->UAGCONTR,"uitschakelen","inschakelen") + IF(!EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),""))
ELSEIF i = 4 .AND. MENT->MNVOLGNR >= 9999978 .AND. MENT->MNVOLGNR <= 9999980
MENUITEM (IF(MENT->MNVOLGNR=9999978,"Taalkeuze",IF(MENT->MNVOLGNR=9999979,"Taal spellingcontrole","Controle lettertekens"))+" "+IF((MENT->MNVOLGNR=9999978 .AND. US->UTXTTAAL) .OR. (MENT->MNVOLGNR=9999979 .AND. US->UTXTSPEL) .OR. (MENT->MNVOLGNR=9999980 .AND. US->UTXTFLET),"uitschakelen","activeren") + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),""))
ELSE
MENUITEM (ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT"))) + IF(i<>4 .AND. !EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),""))
ENDIF
ENDIF
ENDIF
RETURN
******************************************************************************
I hope you can understand what I mean.
Thank you.