Reputation: 757
For example some simple form
define class myf as form
add object text1 as textbox
procedure init
do G:\mymenu.mpr with thisform
endproc
enddefine
and contents of mymeny.mpr file:
parameters f
Define Menu menubar in (m.f.Name) Bar
Define Pad qrs of menubar prompt "Queries"
ON SELECTION pad qrs OF menubar do dosth
procedure dosth
???.text1.value = "sample"
endproc
how can i refer to form myf from here?
Upvotes: 1
Views: 826
Reputation: 48139
Although Kassie has an option of _screen.ActiveForm, there's no guarantee that will always be available. You can however, always add a custom property to the _Screen object and set it to that of your form. Then, you can always refer to it even if it is not the "Active" form and want to bring focus TO it...
define class myf as form
add object text1 as textbox
procedure init
if NOT PEMSTATUS( _Screen, "oMyForm", 5 )
_Screen.AddProperty( "oMyForm" )
endif
_Screen.oMyForm = this
do G:\mymenu.mpr
endproc
enddefine
then, in the menu program, no need to require the parameter, you can just use the now publicly visible property attached to the _Screen object and go from that
Define Menu menubar in (_Screen.oMyForm.Name) Bar
Define Pad qrs of menubar prompt "Queries"
ON SELECTION pad qrs OF menubar do dosth
procedure dosth
_Screen.oMyForm.text1.Value = "sample"
endproc
Upvotes: 2
Reputation: 757
As one of possible solutions I've found is to use _screen.ActiveForm
_screen.ActiveForm.text1.value
Upvotes: 0