Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing a Form's method from a menu
Message
General information
Forum:
Visual FoxPro
Category:
Menus & Menu designer
Miscellaneous
Thread ID:
00275884
Message ID:
00276147
Views:
29
>I have created a new pad on the system menu programmatically from a form's init. I have quite a few bars on this menu and I want methods on the form to fire if they select a certain menu option. I tried setting the on selection bar command to do "thisform.somemethod" and found out that I couldn't this because I get the error "thisform is only allowed in a method. I even tried creating an object that referenced the form by issuing "oThisform = thisform" and then using oThisform in the on selection bar command. But then I get the error that the object oThisform does not exist.
>
>Does anybody have any ideas of how I can access the form's methods that called for the creation of this new menu pad?
>
>Thanks in advance,
>Paul

In many cases you can really use _SCREEN.Activeform, as was suggested. However, it's safer (and mandatory in some situations) if your application searches for the form. Either it does it in _SCREEN.Forms collection:
For Each oForm in _SCREEN.Forms
if oForm.name="myform"
oForm.mymethod() && run the method
endif
Endfor

or you may have special form manager object that will keep links to all open forms in your application, and when it's necessary, you call
oApp.oFormmanager.Allforms(5).Mymethod
Edward Pikman
Independent Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform