Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP6 Tip-o-the-day (a few minutes early)
Message
From
18/07/1998 08:40:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00118896
Message ID:
00118943
Views:
18
>Folks,
>
>You ahve seen the THI_Access method in a previous tip-o-the-day. Now let me introduce to the NewObject method that every FoxPro container class has. Read the code below and you will notice that the form has Text2 textbox, not until the command button is clicked anyway.
>
>The command button simply says THISFORM.Text2.Value = "ABC" when ther is no Text2 in the fomr. The form's THIS_Access fires, sees that ther is no Text2 and makes one.
>
>
>PUBLIC oform1
>
>oform1=NEWOBJECT("form1")
>oform1.Show
>RETURN
>
>
>	**************************************************
>*-- Form:         form1 (d:\program files\microsoft visual studio\vfp98\junk.scx)
>*-- ParentClass:  form
>*-- BaseClass:    form
>*
>DEFINE CLASS form1 AS form
>
>
>	DoCreate = .T.
>	Caption = "Form1"
>	Name = "Form1"
>
>
>	ADD OBJECT command1 AS commandbutton WITH ;
>		Top = 188, ;
>		Left = 199, ;
>		Height = 38, ;
>		Width = 106, ;
>		Caption = "Command1", ;
>		Name = "Command1"
>
>
>	ADD OBJECT text1 AS textbox WITH ;
>		Height = 32, ;
>		Left = 126, ;
>		Top = 53, ;
>		Width = 113, ;
>		Name = "Text1"
>
>
>	PROCEDURE this_access
>		LPARAMETERS cMember
>		IF TYPE("THISFORM."+cMember) = "U"
>			THISFORM.NewObject(cMember,"Textbox")
>			THISFORM.Text2.Visible = .T.
>		ENDIF
>		RETURN THIS
>	ENDPROC
>
>
>	PROCEDURE caption_access
>		*To do: Modify this routine for the Access method
>		Wait window "CAPTION Access fired"
>		RETURN THIS.CAPTION
>	ENDPROC
>
>
>	PROCEDURE command1.Click
>		THISFORM.Text2.Value = "ABC"
>		THISFORM.Text2.Refresh()
>	ENDPROC
>
>
>ENDDEFINE
>*
>*-- EndDefine: form1
>**************************************************
>
Modification a little bit to show the difference from addobject :
PROCEDURE this_access
		LPARAMETERS cMember
		IF TYPE("THISFORM."+cMember) = "U"
			THISFORM.NewObject(cMember,"myTextbox","myclasses.vcx")
			THISFORM.&cMember..Visible = .T.
		ENDIF
		RETURN THIS
	ENDPROC
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform