Been there done that! I tried returning .f. from page activation but my results were somewhat different. I still got page three to show it's ugly face when I tried to suppress it in addition to your results. It does however take som furious clicking to make it happen.
If I revise the code as follows, the exact behavior is duplicated. The primary difference is that I assign the caption to the label in the init event instead of the activate event.
LOCAL lof as form
lof = CREATEOBJECT('form')
lof.addobject('pf1','pf')
WITH lof.pf1
.visible = .t.
.top =0
.left = 0
.width = lof.Width
.height = lof.Height
ENDWITH
lof.Show()
READ events
DEFINE CLASS pf as PageFrame
ADD object page1 as pg with ;
caption = 'Page1'
ADD object page2 as pg with ;
caption = 'Page2'
ADD object page3 as pg with ;
caption = 'Page3'
FUNCTION destroy
CLEAR EVENTS
endfun
ENDDEFINE
DEFINE CLASS pg as Page
ADD OBJECT lbl as label WITH ;
caption = 'Label Caption', ;
autosize = .t., ;
top = 100, ;
left = 10, ;
visible = .t.
FUNCTION init
this.lbl.visible = .t.
this.lbl.caption = SYS(1272,this)
function activate
IF LOWER(this.Name) = 'page3'
NODEFAULT
this.Parent.activepage = 2
MESSAGEBOX('no way on 3')
RETURN .f.
ENDIF
ENDDEFINE
Glenn
>>When using a pageframe with more that 2 pages it seems that attempting to suppress page activate fails. Try the attached code and follow these steps:
>
>After I read your code, my first thought was "RETURN .F." to cancel the activation. When I tried that, things got...interesting. Each page.Activate I was working with has code; Page 1 loads a container object at runtime, page 2 has all its controls natively. I was unable to activate page3, but none of the contained controls loaded for page 1 or page 2.
>
>Still looking into it.
>Chris.