Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Expanding methods across forms
Message
De
20/04/2005 12:46:20
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01006144
Message ID:
01006602
Vues:
19
If the methods call properties or methods of the form, then Hilmar's recommendation is best. It is just better practice anyway. If the methods are generic and don't reference specific form properties or methods, then move them to a common program of shared functions or open the form minimized and call the method.
llcontinue = .T.
myvalue = "START VALUE"
oform1 = NEWOBJECT('form1')
oform2 = NEWOBJECT('form2')
oform1.show(0)
oform2.show(1)
DO WHILE llcontinue
	READ EVENTS
ENDDO
IF TYPE('oform1')="O" .and. !ISNULL(oform1)
	oform1.release()
ENDIF
IF TYPE('oform2')="O" .and. !ISNULL(oform2)
	oform2.release()
ENDIF
oform1 = null
oform2 = null
RELEASE oform1, oform2
RETURN

DEFINE CLASS form1 AS form


	DoCreate = .T.
	Caption = "Form1"
	Name = "FORM1"


	ADD OBJECT text1 AS textbox WITH ;
		ControlSource = "myvalue", ;
		Height = 23, ;
		Left = 60, ;
		Top = 48, ;
		Width = 100, ;
		Name = "Text1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 132, ;
		Left = 120, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Enter Text", ;
		Name = "Command1"

	PROCEDURE DESTROY
	   llcontinue = .F.
		IF TYPE('oform2')="O" .and. !ISNULL(oform2)
			oform2.release()
		ENDIF
	   DODEFAULT()
	ENDPROC

	PROCEDURE setvalue
		myvalue = "NEW VALUE"
	ENDPROC


	PROCEDURE command1.Click
		thisform.setvalue()
		thisform.refresh()
	ENDPROC


ENDDEFINE

DEFINE CLASS form2 AS form


	DoCreate = .T.
	Caption = "Form2"
	Name = "FORM2"


	ADD OBJECT text1 AS textbox WITH ;
		ControlSource = "myvalue", ;
		Height = 23, ;
		Left = 60, ;
		Top = 48, ;
		Width = 100, ;
		Name = "Text1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 132, ;
		Left = 120, ;
		Height = 27, ;
		Width = 132, ;
		Caption = "Call Form1 Method", ;
		Name = "Command1"


	PROCEDURE DESTROY
	   llcontinue = .F.
		IF TYPE('oform1')="O" .and. !ISNULL(oform1)
			oform1.release()
		ENDIF
	   DODEFAULT()
	ENDPROC

	PROCEDURE command1.Click
		IF TYPE('oform1')="O" .and. !ISNULL(oform1)
			oform1.setvalue()
			thisform.refresh()
		ENDIF
	ENDPROC


ENDDEFINE
>I have a number of methods on a form. Is there anyway I can use these methods on my new form?
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform