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:
01383310
Vues:
49
UPDATE: Please await another post from me. I have not considered the laOrder array into the code yet, thanks.

Hi, Martina

>You cannot use ActivePage with Pages[], because ActivePage is Order (visual) and index in Pages[] is nonvisual order.

Thanks for your help. I have updated my code as you specified, but sadly the performance has not changed from before, may be I am doing something wrong yet.

1) The next and prev buttons still have the wrong captions showing from the next page onwards
2) The activation of page is still on the collection order rather than the PageOrder

Any further help will be appreciated

Changing ln...PO to ln...Page still doe not work in the following piece of code:
...		CASE UPPER(tcAdvanceTo) = "PREVIOUS"
			THISFORM.pgf.ACTIVEPAGE = lnPrevPO

		CASE UPPER(tcAdvanceTo) = "NEXT"
			THISFORM.pgf.ACTIVEPAGE = lnNextPO...
My updated code as per your suggestion:
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

LOCAL ARRAY laOrder[1]


WITH THISFORM
	lnCurrPO      = .pgf.PAGES(.pgf.ACTIVEPAGE).PAGEORDER
	lnCurrPage    = .pgfToCollectionIndex(.pgf.ACTIVEPAGE)
	lcCurrCaption = .pgf.PAGES(.pgf.ACTIVEPAGE).CAPTION

	lnMinPO      = lnCurrPO
	lnMinPage    = lnCurrPage
	lcMinCaption = lcCurrCaption

	lnMaxPO      = lnCurrPO
	lnMaxPage    = lnCurrPage
	lcMaxCaption = lcCurrCaption

	lnPrevPO      = -999999
	lnPrevPage    = -999999
	lcPrevCaption = "-999999"

	lnNextPO      = 999999
	lnNextPage    = 999999
	lcNextCaption = "999999"

	lnAvailPO      = lnCurrPO
	lnAvailPage    = lnCurrPage
	lcAvailCaption = lcCurrCaption


	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, 1] = .pgf.PAGES(lnI).PAGEORDER
			DIMENSION laOrder[liY, 2] = .pgf.PAGES(lnI)
		ENDIF
	NEXT

	IF liY > 0
		DIMENSION laOrder[liY,2]

		ASORT(laOrder, 1, -1, 0, 0)
	ENDIF


	FOR  lnI = 1 TO liY
		*** track the available, first and last page order and no.
		lnAvailPO      = .pgf.PAGES(lnI).PAGEORDER
		lnAvailPage    = lnI
		lcAvailCaption = .pgf.PAGES(lnI).CAPTION


		lnMinPO = MIN(lnMinPO, lnAvailPO)

		IF lnMinPO = lnAvailPO
			lnMinPage    = lnAvailPage
			lcMinCaption = lcAvailCaption
		ENDIF


		lnMaxPO = MAX(lnMaxPO, lnAvailPO)

		IF lnMaxPO = lnAvailPO
			lnMaxPage    = lnAvailPage
			lcMaxCaption = lcAvailCaption
		ENDIF


		*** track the next and prev page order and no.
		IF lnAvailPO > lnCurrPO
			lnNextPO = MIN(lnNextPO, lnAvailPO)

			IF lnNextPO = lnAvailPO
				lnNextPage    = lnAvailPage
				lcNextCaption = lcAvailCaption
			ENDIF
		ENDIF

		IF lnAvailPO < lnCurrPO
			lnPrevPO = MAX(lnPrevPO, lnAvailPO)

			IF lnPrevPO = lnAvailPO
				lnPrevPage    = lnAvailPage
				lcPrevCaption = lcAvailCaption
			ENDIF
		ENDIF
	ENDFOR


	*** if default values, assign fisrt and last page order and no. resp.
	IF lnPrevPO = -999999
		lnPrevPO      = lnMaxPO
		lnPrevPage    = lnMaxPage
		lcPrevCaption = lcMaxCaption
	ENDIF

	IF lnNextPO = 999999
		lnNextPO      = lnMinPO
		lnNextPage    = lnMinPage
		lcNextCaption = lcMinCaption
	ENDIF


	*** change the buttons caption
	.cmdPrevious.CAPTION = "<< " + lcPrevCaption
	.cmdNext.CAPTION     = lcNextCaption + " >>"


	*** 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 = lnPrevPO

		CASE UPPER(tcAdvanceTo) = "NEXT"
			THISFORM.pgf.ACTIVEPAGE = lnNextPO
	ENDCASE
ENDWITH
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform