Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining Whether A Menu Exists Or Not
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00605682
Message ID:
00606386
Vues:
25
>>>Hello all,
>>>
>>>I've got a "File" menu in my program that I re-build whenever a new user logs in. Very rarely i'll get the error "Menu has not been defined with DEFINE POPUP", when I do a CNTBAR("File"). It doesn't have regularly however. What I'd like to do is just determine if the file HAS been defined, and if it hasn't, skip that code. I searched the help files, but couldn't find a command to do this. Any ideas? Thanks!
>>
>>See Forum: Visual FoxPro Category: Troubleshooting Title: Re: No such menu item Thread #510194 Message #510210
>
>Hrm. Well the problem is I seem to be getting the error ON the CNTBAR command. here's the code:
>
>FOR lnxxx = CNTBAR("File") TO 1 STEP -1 && Remove File Pull Down Menu
> RELEASE BAR GETBAR("File", lnxxx) OF FILE
>NEXT
>
>The "For" line gives me the error. If I change it like this:
>
>If CNTBAR("File") > 0
>FOR lnxxx = CNTBAR("File") TO 1 STEP -1 && Remove File Pull Down Menu
> RELEASE BAR GETBAR("File", lnxxx) OF FILE
>NEXT
>EndIf
>
>Do you think that will fix the error? I can't duplicate the error consistently, otherwise I'd just test it.. Thanks for your input.

Hi Scott,

I've searched through the help, but was unable to find out, how can we tell, if menu (popup) was defined or not.

Anyway, here is the code, I got working for System menu file. It doesn't remove documents and doesn't remove Exit item.
?popup()
lnInitialBars=cntbar('_MFILE')
lnBars = CntBar('_MSM_PROG')
for ix = 1 to lnBars
 if (_MPR_RESUM) = GetBar('_MSM_PROG',ix)
   ? 'Suspend exists and '+;
     iif(SKPBAR('_MSM_PROG', _MPR_RESUM),'dis','en')+'abled.'
   exit
 endif
endfor


*set step on
lnAttempts = 0
lnFiles = cntbar('_MFILE')
If m.lnInitialBars>0
do while m.lnFiles>1 and m.lnAttempts>m.lnInitialBars
    lnAttempts=m.lnAttempts+1
    lnBar = GETBAR('_MFILE', 1)
    if m.lnBar>0
         RELEASE BAR  m.lnBar OF _MFILE
     endif    
    lnFiles = cntbar('_MFILE')   
enddo
EndIf
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform