Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Buttons to activate Prev / Next page, logic improvements
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01383298
Message ID:
01383314
Vues:
85
This message has been marked as the solution to the initial question of the thread.
Yes, sorry

Valid source code is...
*** create Array ordered by Page Order
FOR lnI = 1 TO .pgf.PAGECOUNT
		*** only consider active pages
		IF (PEMSTATUS(.pgf.PAGES(lnI), "lVisible", 5) AND .pgf.PAGES(lnI).lVisible) && ;
				OR ((NOT PEMSTATUS(.pgf.PAGES(lnI), "lVisible", 5)) AND .pgf.PAGES(lnI).ENABLED)

			liY = liY + 1
                                    DIMENSION laOrder[liY, 2]
			laOrder[liY, 1] = .pgf.PAGES(lnI).PAGEORDER
			laOrder[liY, 2] = .pgf.PAGES(lnI)
		ENDIF
NEXT


But your source code is complex...
**************************************************
*-- Form:         form1 (l:\test\pagex.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   02/22/09 08:42:13 AM
*
DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 406
	Width = 693
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT pgf AS pageframe WITH ;
		ErasePage = .T., ;
		PageCount = 3, ;
		Top = 33, ;
		Left = 25, ;
		Width = 586, ;
		Height = 293, ;
		Name = "pgf", ;
		Page1.Caption = "Page1", ;
		Page1.PageOrder = 1, ;
		Page1.Name = "Page1", ;
		Page2.Caption = "Page2", ;
		Page2.PageOrder = 3, ;
		Page2.Name = "Page2", ;
		Page3.Caption = "Page3", ;
		Page3.PageOrder = 2, ;
		Page3.Name = "Page3"


	ADD OBJECT form1.pgf.page1.label3 AS label WITH ;
		Caption = "Label3", ;
		Height = 17, ;
		Left = 23, ;
		Top = 17, ;
		Width = 40, ;
		Name = "Label3"


	ADD OBJECT form1.pgf.page2.label3 AS label WITH ;
		Caption = "Label3", ;
		Height = 17, ;
		Left = 326, ;
		Top = 73, ;
		Width = 40, ;
		Name = "Label3"


	ADD OBJECT form1.pgf.page3.label3 AS label WITH ;
		Caption = "Label3", ;
		Height = 17, ;
		Left = 280, ;
		Top = 49, ;
		Width = 40, ;
		Name = "Label3"


	ADD OBJECT txtpo AS textbox WITH ;
		Height = 23, ;
		Left = 116, ;
		Top = 341, ;
		Width = 100, ;
		Name = "txtPO"


	ADD OBJECT txtpi AS textbox WITH ;
		Height = 23, ;
		Left = 116, ;
		Top = 373, ;
		Width = 100, ;
		Name = "txtPI"


	ADD OBJECT label1 AS label WITH ;
		Caption = "Page Order:", ;
		Height = 17, ;
		Left = 41, ;
		Top = 348, ;
		Width = 68, ;
		Name = "Label1"


	ADD OBJECT label2 AS label WITH ;
		Caption = "Page Index:", ;
		Height = 17, ;
		Left = 41, ;
		Top = 376, ;
		Width = 66, ;
		Name = "Label2"


	ADD OBJECT cmdprevious AS commandbutton WITH ;
		Top = 2, ;
		Left = 113, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "cmdPrevious"


	ADD OBJECT cmdnext AS commandbutton WITH ;
		Top = 4, ;
		Left = 209, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command2", ;
		Name = "cmdNext"


	PROCEDURE changepage
		LPARAMETERS tcAdvanceTo


		IF TYPE("THISFORM.cmdPrevious.CAPTION") # "C"
			RETURN
		ENDIF


		LOCAL lnCurrPO, lnCurrPage, lcCurrCaption, ;
			lnMinPO, lnMinPage, lcMinCaption, ;
			lnMaxPO, lnMaxPage, lcMaxCaption, ;
			lnPrevPO, lnPrevPage, lcPrevCaption, ;
			lnNextPO, lnNextPage, lcNextCaption, ;
			lnAvailPO, lnAvailPage, lcAvailCaption, ;
			liY,loNextPage,loPrevPage,loCurrPage

		LOCAL ARRAY laOrder[1]


		WITH THISFORM
			DIMENSION laOrder[.pgf.PageCount, 2]

			liY = 0

			*** create Array ordered by Page Order
			FOR lnI = 1 TO .pgf.PAGECOUNT
				*** only consider active pages
				IF (PEMSTATUS(.pgf.PAGES(lnI), "lVisible", 5) AND .pgf.PAGES(lnI).lVisible) ;
						OR ((NOT PEMSTATUS(.pgf.PAGES(lnI), "lVisible", 5)) AND .pgf.PAGES(lnI).ENABLED)

					liY = liY + 1
					DIMENSION laOrder[liY, 2]
					laOrder[liY, 1] = .pgf.PAGES(lnI).PAGEORDER
					laOrder[liY, 2] = .pgf.PAGES(lnI)
				ENDIF
			NEXT

			IF liY > 0
				DIMENSION laOrder[liY,2]
				ASORT(laOrder, 1, -1, 0, 0)
			ENDIF

		    * Current Page
		    liy=ASCAN(laOrder,.pgf.ActivePage,1,-1,1,8)
		    
		    * Set new current page
		    IF UPPER(tcAdvanceTo) = "PREVIOUS"
		       IF liy=1
		          liy=ALEN(laOrder,1)
		       ELSE
		          liy=liy-1
		       ENDIF
		    ELSE
		       IF liy=ALEN(laOrder,1)
		          liy=1
		       ELSE
		          liy=liy+1
		       ENDIF
		    ENDIF
		    loCurrPage=laOrder(liy,2)
		       

		    * Set preview page
		    IF liy=1
		       loPrevPage=laOrder(ALEN(laOrder,1),2)
		    ELSE
		       loPrevPage=laOrder(liy-1,2)
		    ENDIF

		    * set next Page
		    IF liy=ALEN(laOrder,1)
		       loNextPage=laOrder(1,2)
		    ELSE
		       loNextPage=laOrder(liy+1,2)
		    ENDIF


			*** change the buttons caption
			.cmdPrevious.CAPTION = "<< " + loPrevPage.Caption
			.cmdNext.CAPTION     = loNextPage.Caption + " >>"


			*** hide buttons as required
		*!*		DO CASE
		*!*			CASE lcCurrCaption = lcPrevCaption
		*!*				*** current and the prev are same only one button
		*!*				THISFORM.cmdPrevious.MakeVisible(.F.)
		*!*				THISFORM.cmdNext.MakeVisible(.F.)

		*!*			CASE lcPrevCaption = lcNextCaption
		*!*				*** next and the prev are same no buttons
		*!*				THISFORM.cmdPrevious.MakeVisible(.F.)
		*!*				THISFORM.cmdNext.MakeVisible(.T.)

		*!*			OTHERWISE
		*!*				*** both buttons active
		*!*				THISFORM.cmdPrevious.MakeVisible(.T.)
		*!*				THISFORM.cmdNext.MakeVisible(.T.)
		*!*		ENDCASE


			*** change the active page if requested
			*** ie called from the click of the next and prev buttons
			DO CASE
				CASE PCOUNT() = 0

				CASE UPPER(tcAdvanceTo) = "PREVIOUS"
					THISFORM.pgf.ACTIVEPAGE = loCurrPage.PageOrder

				CASE UPPER(tcAdvanceTo) = "NEXT"
					THISFORM.pgf.ACTIVEPAGE = loCurrPage.PageOrder
			ENDCASE
		ENDWITH
	ENDPROC


	PROCEDURE tocontrolindex
		LPARAM lopgf,liPO
		LOCAL liCO
		FOR liCO=1 TO lopgf.PageCount
		    IF lopgf.Pages(liCO).PageOrder=liPO
		       RETURN liCO
		    ENDIF        
		NEXT
		RETURN 0
	ENDPROC


	PROCEDURE changedpage
		This.txtPO.Value=this.pgf.ActivePage
		This.txtPi.Value=this.ToControlIndex(this.pgf,this.pgf.ActivePage)
	ENDPROC


	PROCEDURE Init
		This.ChangedPage()
	ENDPROC


	PROCEDURE label3.UIEnable
		LPARAMETERS lEnable
		IF lEnable
		   Thisform.ChangedPage()
		ENDIF
	ENDPROC


	PROCEDURE label3.UIEnable
		LPARAMETERS lEnable
		IF lEnable
		   Thisform.ChangedPage()
		ENDIF
	ENDPROC


	PROCEDURE label3.UIEnable
		LPARAMETERS lEnable
		IF lEnable
		   Thisform.ChangedPage()
		ENDIF
	ENDPROC


	PROCEDURE cmdprevious.Click
		Thisform.ChangePage("PREVIOUS")
	ENDPROC


	PROCEDURE cmdnext.Click
		Thisform.ChangePage("NEXT")
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
>I even commented out the If condition in case it was returning wrong and not allowing the array to populate
>
	*** create Array ordered by Page Order
>	FOR lnI = 1 TO .pgf.PAGECOUNT
>		*** only consider active pages
>*		IF (PEMSTATUS(.pgf.PAGES(lnI), "lVisible", 5) AND .pgf.PAGES(lnI).lVisible) && ;
>*				OR ((NOT PEMSTATUS(.pgf.PAGES(lnI), "lVisible", 5)) AND .pgf.PAGES(lnI).ENABLED)
>
>			liY = liY + 1
>			DIMENSION laOrder[liY, 1] = .pgf.PAGES(lnI).PAGEORDER
>			DIMENSION laOrder[liY, 2] = .pgf.PAGES(lnI)
>*		ENDIF
>	NEXT
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform