Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
PageFrame: generic handling of .ActivePage
Message
 
À
10/12/2014 16:35:04
Al Doman (En ligne)
M3 Enterprises Inc.
North Vancouver, Colombie Britannique, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01612127
Message ID:
01612129
Vues:
57
>From time to time I'm asked to enhance PageFrames by adding one or more new pages. Recently I added a seventh page to a pageframe and set its .PageOrder to 2 to make it the second page, rather than the last. All well and good.
>
>However, there is code in the parent form that depends on hard-coded .ActivePage values e.g.
>
>IF MyPageFrame.ActivePage = 3
>...
>
>Most of these are now broken, because what used to be the 2nd page is now the 3rd, third is the 4th etc.
>
>Has anyone come up with a generic handler for this? My first thought is that the name of the page isn't likely to change, regardless of its .PageOrder so I could look at implementing something like
>
>IF MyPageFrame.ActivePageName( MyPageFrame.ActivePage ) = "SomePageName"
>...
>
I faced a similar problem some time ago what I did was to add an array property (I did it on the form for I was planning to put it in the class later, which then I forgot until now that you mentioned..), I called PageToPageOrder, then in the init you can put code like this:
local lnPage, loPage

lnPage = 0
DIMENSION this.PageToPageOrder(this.PageCount, 2)

FOR EACH loPage IN this.Pages FOXOBJECT
	lnPage		= lnPage + 1
	this.PageToPageOrder[loPage.PageOrder, 1] = lnPage	&& Page[PageOrder, 1] returns PageNumber for a PageOrder
	this.PageToPageOrder[lnPage, 2] = loPage.PageOrder	&& Page[PageNumber, 2] returns a PageOrder for a PageNumber
ENDFOR
So now somewhere else where I needed I can do, for example:
lnActivePage = thisform.myPageFrame.PageToPageOrder[thisform.myPageFrame.ActivePage, 1]
loActivePage = evaluate('thisform.myPageFrame.page'+transform(lnActivePage))
In your example you would change
IF MyPageFrame.ActivePage = 3
...
to
IF MyPageFrame.PageToPageOrder[MyPageFrame.ActivePage, 1] = 3
...
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform