Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Codewriting for the Click-event of pages in a pagefram in VFP 9.0

Status
Not open for further replies.

german12

Programmer
Nov 12, 2001
563
DE
I created a form in VFP 9.0 and when the form is initiated a code runs, which makes it possible to create (based on a table) a Pageframe which could have between 2 and much more pages and each page has a different caption.
That works fine.

Coding:
SET SAFETY OFF
SELECT DISTINCT KATEGORIE FROM GOOGLEA INTO TABLE MYTABLE
USE MYTABLE
GO TOP
THISFORM.PAGEFRAME1.PAGECOUNT = RECCOUNT()

*CAPTION FOR EACH PAGE TO BUILD
SCAN
STORE KATEGORIE TO MKATEGORIE
THIS.PAGES(RECNO()).CAPTION = MKATEGORIE
ENDSCAN


Example: Caption of Page 1 = "Wood", Caption of Page 2 = "Iron", Caption of Page 3 = "Coal".
Now, i would like that when the user clicks on page 1 that all records are shown which are of category "Wood", and when he clicks on Page 2 of the Pageframe that "Iron" and so on.

So every click on a page should do the same which means : "Show me records of a file which contains something which is the same as the caption is."
Of course it would be easy to write a fixed code if it would be only and always 3 pages, but as I mentioned it could also be much more, depending of what the dbf.file will receive.
My question:
Where is the best place in the form, to locate such a code?
How would it look?

Thanks in advance
Klaus



Peace worldwide - it starts here...
 
Take a look at member classes and change your code to add individually customised pages:

Code:
WITH THISFORM.PAGEFRAME1
   .memberclasslibrary ="MyCategoryPages.vcx"
   SELECT DISTINCT KATEGORIE FROM GOOGLEA INTO CURSOR crsPAGES
   [s]THISFORM.PAGEFRAME1.PAGECOUNT = RECCOUNT()[/s]

    *Different Page FOR EACH KATEGORIE
    SCAN
       .Memberclass="CategoryPage"+crsPAGES.KATEGORIE
       .PAGECOUNT = .PAGECOUNT+1
       .Pages(.Pagecount).Caption = crsPAGES.KATEGORIE
    ENDSCAN
ENDWITH

MyCategoryPages.vcx is a library containing page classes CategoryPageWood, CategoryPageIron, CategoryPageCoal... and mayby also a base class CategoryPageBase all these classes inherit a general unspecific design from.

If all these pages really just differ by the category name, you could also use the same page class for every page and directly after adding it, set a category property of it, which controls filtering.

Anyway the base idea is you don't create N pages you customize as aftermathc you create each page individually in the first place and there also is no aftermath to do when activating each page.

Bye, Olaf.
 
Taking Olaf's suggestion one stage further:

In your member page class, place a grid on the page. Name it, say, grdKategorie. Then, in your SCAN loop:

Code:
SCAN
    .Memberclass="CategoryPage"+crsPAGES.KATEGORIE
    .PAGECOUNT = .PAGECOUNT+1
    .Pages(.Pagecount).Caption = crsPAGES.KATEGORIE

[b]    lcCursorName = "csrKat" + TRANSFORM(.PageCount)
    SELECT * FROM GoogleA WHERE Kategory = crsPAGES.KATEGORIE INTO CURSOR (lcCursorName)
    .Pages(.Pagecount).grdKategorie.RecordSource = lcCursorName[/b]

ENDSCAN

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I left the details to each category page class, though it's likely you don't even need a totally different layout for each category, and the data for each is just a subset of the same table.

If all pages look same and the category is just a main filter you could do that without page tabs, simply have a combobox with categories to pick from and in its interacivechange or valid simply SET FILTER or query that categories data. The pageframe page tabs have an advantage to be available all at once, the same goes for a listbox instead of combobox. It just looks dull in comparison and you don't have the categories in a horizontal line.

Another idea is you only use the pagetabs and collapse the pageframe just to that part of it. Instead of really switching pages you only set filter in the pages Acticate event. What is displayed underneath simply is the non changing grid Mike has sketched.

There are many ways to do similar things, as always.

Bye, Olaf.
 
Thank you very much, Olaf & Mike.
Meanwhile I would prefer to do that job with a listbox because the max. size of pages on a pagefrage are 99, and as I can not see, how many categories could be created from/with my dbf-file in future, it would be better to have a listbox, which is not limited like a pageframe.
That is, what Olaf already had mentioned.

Anyway - I was very pleased to see, that this forum still works, as I had received very good hints concerning VFP during the time when I had to work.
Now, 14 years later (I am already 75 !!) I could not believe that the forum is still alive. Congratulations!
A lot of VFP-practice is lost for me, but to keep my brain healthy I try to get back all the stuff and to write a program which gathers a lot of categories which belong around my hobby ( watercolor-paintings).
You can see my paintings here:
Link
What I want is, that one can click on names of painters (eg Turner, William, Pekel, Herman) and also can click on categories (trees, mountains, portraits etc.) and to have an immediate look into the web.
Of course that is all possible bei using GOOGLE, but the program has the advantage, that one can find links, which are new for him and as I have a lot of friends with the same hobby, I could make them happy.
So I have a long list of artist-names with their links and a list of items , so two dbf-files and two listboxes could do it. The list with the names is easier as the names are unique, but the list with the items are multiple records (e.g.a tree could be an oak-tree, a lime, or a beech or...) so the distinct categorie is at first TREE, and then e.g. these 3 items are to be shown with their links in a listbox.
I hope I can write this program before I am 80 years old, because - as I said - I have so much forgotten.....
I am sure that help is to be found here....perhaps even a similiar program?

Thank you again and regards from Germany
Klaus




Peace worldwide - it starts here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top