Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SET SKIP OF BAR question
Message
From
21/11/2006 01:14:06
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01170464
Message ID:
01171335
Views:
8
That may work for a single menu item, but what if I want Something() to work for ALL menu items. Your suggestion would require Something() and SomethingElse() and MySomething()... One for each menu item because each would have different requirements.

I have created a MenuController object which turns items on and off and places the text of the Window Caption into a 'Window' menu. All that the MenuController requires is the menu name, it doesn't even need to know the Prompt() (because Prompt() handles that.) But the only thing that is stopping the obejct from doing exactly what it is suppose to do, is the stupid SET SKIP OF on a menu item that already has a SKIP clause set doesn't work.

I think Microsoft needs to create a menu function which will return the SKIP clause set on a menu item so that you can work around this exact problem.

>I would put all controll into the hands of Something()
>
>function Something
>if cCurrentYear >= '1999'
>  return .t.
>endif
>
>llFound = .F.
>
>FOR EACH loForm IN _SCREEN.Forms
>	IF loForm.Name == 'MyFormName'
>		llFound = .T.
>		EXIT
>	ENDIF
>ENDFOR
>...
>return llFound
>
>
>Hope it helps
>Kamil
>
>
>>A better example then...
>>
>>
>>SKIP FOR cCurrentYear >= '1999'
>>
>>
>>I need this to be in place all the time. If cCurrentYear = '2004', the item is disabled and if the cCurrentYear = '1998' the item is enabled.
>>
>>
>>When the cCurrentYear is '1998', the user will be allowed to enter the form. In the init or load of the form I want to SET SKIP OF BAR n OF myMenu .T. This is to disable the item because it is now running and I don't want the user to execute the form a second time.
>>
>>
>>Now what I am hearing from the two suggestions is that I need to put specific menu code into my form in order to disable the menu item.
>>
>>e.g.
>>
>>
>>* INIT or LOAD
>>* redefine the menu
>>DEFINE BAR n OF myMenu PROMPT "\<myPrompt"
>>
>>* Then set skip
>>SET SKIP OF BAR n OF myMenu .T.
>>
>>
>>then in the DESTROY or UNLOAD
>>
>>
>>* reset skip
>>SET SKIP OF BAR n OF myMenu .F.
>>
>>* redefine the menu
>>DEFINE BAR n OF myMenu PROMPT "\<myPrompt" ;
>>SKIP FOR cCurrentYear >= '1999'
>>
>>
>>
>>This would mean that my form must be cognizant of the exact nature of the menu settings; not very object oriented. I would need to maintain the code in two places; once in the menu, and then again in the form.
>>
>>There must be a better object oriented approach to this. I don't even like my idea...
>>
>>
>>* in the menu change to...
>>SKIP FOR cCurrentYear >= '1999' AND FormCheck('myFormName')
>>
>>
>>* global function defined in the mainline outside the application object.
>>PROCEDURE FormCheck
>>LPARAMETERS tcName
>>LOCAL loForm, llFound
>>
>>llFound = .F.
>>
>>FOR EACH loForm IN _SCREEN.Forms
>>	IF loForm.Name == tcName
>>		llFound = .T.
>>		EXIT
>>	ENDIF
>>ENDFOR
>>
>>RETURN llFound
>>
>>
>>This will not handle multiple calls to the same form with different parameters. Using the Caption won't work because the Caption might change in the INIT or LOAD of the form depending on the cCurrentYear. Too many holes!
>>
>>Any ideas?
>>
>>
>>
>>
>>>Control the bar enabled status either by
>>>
... SKIP FOR Something()
>>>or with
>>>
SET SKIP OF BAR 1 OF file .T.
>>>
>>>All the best
>>>
>>>
>>>>Does anyone know how to use the SET SKIP OF BAR when the menu already has a SKIP FOR clause?
>>>>
>>>>e.g.
>>>>
>>>>This would be defined in the menu.MPR. If something() returns true, then the item is disabled otherwise it is enabled.
>>>>
>>>>
>>>>DEFINE POPUP file MARGIN RELATIVE SHADOW COLOR SCHEME 4
>>>>DEFINE BAR 1 OF file PROMPT "\<Test" ;
>>>>	SKIP FOR Something()
>>>>
>>>>
>>>>
>>>>In your form INIT code you would use something like the following:
>>>>
>>>>
>>>>SET SKIP OF BAR 1 OF file .T.
>>>>
>>>>
>>>>Here we want to disable the first item in the file menu. If Something() is returning false, even with the SET SKIP OF BAR telling it to be TRUE, the first item will still be enabled.
>>>>
>>>>Does anyone know how to get around this?
Gordon de Rouyan
DC&G Consulting
Edmonton, Alberta
Email: derouyag@shaw.ca
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform