Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

ActivePage

This page frame property tells you which page is currently on top. Unlike similar properties for grids, this one lets you change things as well as find out what’s going on.

Usage

pgfPageFrame.ActivePage = nWhichPage
nWhichPage = pgfPageFrame.ActivePage

ActivePage is based on the display order of the pages, not their creation order. That is, the page frame’s ActivePage equals PageOrder for the page that’s on top.

Unfortunately, the Pages collection uses creation order, so Pages[ ActivePage ] is meaningless. The only way to get from the number ActivePage returns to the actual object that is the current page is brute force—loop through all the pages until you find one whose PageOrder matches the PageOrder of the active page. (Of course, in a method of the page itself, you can use This.)

If you create an Assign method for ActivePage, it doesn't fire when you change pages by clicking on the new page. It does fire when you change pages using the keyboard or programmatically.

Example

* Find the active page in a page frame.
* Assume this is a page frame method.
LOCAL nCurOrder, oCurPage, oActivePage

nCurOrder = This.ActivePage
FOR EACH oPage IN This.Pages
   IF oPage.PageOrder = nCurOrder
      oActivePage = oPage
      EXIT
   ENDIF
ENDFOR
* Now, act on oActivePage to manipulate the Active Page

See Also

Page, Pages, PageFrame, PageOrder