Article ID: 141529
Article Last Modified on 6/29/2004
* The following refresh method will help automate the process
* of adding and removing pages from the pageframe.
*
* Display Page Not Display Page
* THISFORM.Page1 .T. .F.
* THISFORM.Page2 .T. .F.
* THISFORM.Page3 .T. .F.
IF THIS.PAGECOUNT > 0
DIMENSION lcPage(THIS.PAGECOUNT) && Array of names for visible pages
FOR lni=1 to THIS.PAGECOUNT
lcPage(lni)=UPPER(THIS.PAGES(lni).NAME) && Does page exist
ENDFOR
ELSE
DIMENSION lcPage(1)
lcPage(1) = ""
ENDIF
FOR lni = 1 to 3 && Looping stops at 3 because we only have 3
lcx = "Page"+ALLTRIM(STR(lni)) && possible pages to display.
IF THISFORM.&lcx. && IF true display the page
lny=ASCAN(lcPage,UPPER(lcx))
IF lny=0 && If lny=0, then the page does not exist
THISFORM.PAGEFRAME1.ADDOBJECT(lcx,lcx)
ENDIF
ELSE && ELSE (The page should NOT be displayed)
lny=ASCAN(lcPage,UPPER(lcx))
IF lny>0 && If lny>0, remove the page from the page frame
THISFORM.PAGEFRAME1.REMOVEOBJECT(lcx,lcx)
ENDIF
ENDIF
ENDFOR
SET PROCEDURE TO <this program>
DO FORM <form name>
* Three classes are defined as Page1, Page2, and Page3
* respectively. These are the pages that will be added
* with ADDOBJECT inside the PAGEFRAME1.REFRESH.
DEFINE CLASS Page1 AS PAGE
ADD OBJECT command1 AS COMMANDBUTTON
PROCEDURE CLICK
WAIT WINDOW "click" NOWAIT
ENDPROC
ENDDEFINE
DEFINE CLASS Page2 AS PAGE
ADD OBJECT command2 AS COMMANDBUTTON
ENDDEFINE
DEFINE CLASS Page3 AS PAGE
ADD OBJECT text1 AS TEXTBOX
ENDDEFINE
_SCREEN.FORMS(1).PAGE1 = .T. _SCREEN.FORMS(1).PAGE2 = .T. _SCREEN.FORMS(1).PAGE3 = .F. _SCREEN.FORMS(1).REFRESH
_SCREEN.FORMS(1).PAGE1 = .T. _SCREEN.FORMS(1).PAGE2 = .F. _SCREEN.FORMS(1).PAGE3 = .T. _SCREEN.FORMS(1).REFRESH
Keywords: kbhowto kbcode KB141529