>Hi...vfp6 user here
> I am trying to display a container class on a page in a pageframe.
> Would I:
> 1. Use CreateObject()
>OR 2. Use AddObject()
>
> AND
>
> Would I:
> 1. Put the code in the 'Activate' method of the page?
>OR 2. Put the code in the 'AddObject' method of the page?
>
> In any case, when I try:
> oObj = CreateObject('myclass','myclasslib'), then
>oObj.Visible = .t., I cannot see my class on the screen. It is there, because it is in the debugger.
>
>thanks, Randy
Cetin explained a "how" to do it, now here's an explanation of "where" and "why":
You could put your code in a lot of different places, like the Init method of the page or in the Activate method of the page, using the Page's AddObject method. You don't put code *in* the AddObject method, you *use* the add object method by calling it. So to add an object to the page (say a textbox):
Page Init method:
this.AddObject("YourNewControlName","TextBox")
WITH this.YourNewControlName
.Left = 10
.Top = 10
.Visible = .T.
ENDWITH
Page Activate method (need to check if it exists first):
IF NOT PEMSTATUS(this,"YourNewControlName",5)
this.AddObject("YourNewControlName","TextBox")
WITH this.YourNewControlName
.Left = 10
.Top = 10
.Visible = .T.
ENDWITH
ENDIF
HTH