×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Forms as Classes (Easy Question, I suspect...)

Forms as Classes (Easy Question, I suspect...)

Forms as Classes (Easy Question, I suspect...)

(OP)
I've created a "Base Form" that I want to use as the standard default for most forms I create.  I've saved it as a class.  Now, how do I pick this form (or any other "Form as class" that I create?  If I pick New Form from the file menu, it just gives me the "Standard" blank form.

          Thanks,
           -Scott

Please let me know if this has helped!

RE: Forms as Classes (Easy Question, I suspect...)

You're right, it's a pretty easy question...  once you know the answer.  Anyway, you need to go to Tools / Options / Forms and then go down to the Template Classes box and search for and select the library you have it in and your class.  Finally click the 'set as default' button so that your form class will be used every time you start up VFP.  Of course you can set it to another class any time you want to.  

Dave Dardinger

RE: Forms as Classes (Easy Question, I suspect...)

(OP)
Thanks... If I have more than one form in a class, will I be able to select which form I want to use when creating a new form?

          Thanks,
           -Scott

Please let me know if this has helped!

RE: Forms as Classes (Easy Question, I suspect...)

Hi Maniac,
1. You can have more than one form in your class as a 'form Class',
2. You can have more than one class in your project..

As Dave said, you can set the 'form class' to the one you want. If you click on the 'Set as Defaults', this will be memorised and used as the default form class.. every time you start the work. If you dont set that as the default, that will stay til the VFP is quit.

Again you can still use the command prompt...

"CREATE FORM [FormName | ?] [AS cClassName FROM ;
    ClassLibraryName | ?] [NOWAIT] [SAVE] [DEFAULT] ;
    [[WINDOW WindowName1] ;
    [IN [WINDOW] WindowName2 | IN SCREEN]]"

This way you can override the default form class, and create the form with a base class of your choice. Remember to add suitable path for the cClassName and Library name. Once you create, you know to save it in your required directory.

Hope this helps

  

ramani
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK

RE: Forms as Classes (Easy Question, I suspect...)

Scott,

I suspect what you'd like and what would be nice would be to have a toolbar with various forms you'd put in a class library and you could click on the one you wanted to use.  But as far as I know, you can't do that, though I don't know know if VFP 7 might have had it added.  It might be possible, I suppose, that there could be an add-on to VFP which would in essence do the same thing sending a CREATE FORM command to the command window.

Actually you could create a simple kludge by putting a bunch of CREATE FORM commands, one for each class you want to use in a procedure file properly labeled and then just call the one you want.  If your procedure file is myForms and the name of the  form class is FancyForm here's sample code for myForms:

LPARAMETERS FormClass, FormName

DO &FormClass with FormName
RETURN

PROCEDURE FancyForm
LPARAMETERS FormName1
IF LEN(ALLTRIM(FormName1)) < 1
   FormName1 = "FancyForm1"
ENDIF
CREATE FORM &FormName1 AS FancyForm FROM libded_forms
ENDPROC


(Here libded_forms is the name of my forms class library.  Your name would be different)

Just add additional procedures for whatever other classes you want to use. Then in the commmand window type:

DO myforms with "fancyform","myfancyform"

The second parameter is optional and you could add a second IF to the program to make the first one optional as well.  

Dave Dardinger

RE: Forms as Classes (Easy Question, I suspect...)

(OP)
Dave,
     Cool trick!  Thanks!

          Thanks,
           -Scott

Please let me know if this has helped!

RE: Forms as Classes (Easy Question, I suspect...)

Actually I've got a little error in my code.  Since if you don't send a parameter it gives it the value of .F. not "", you need to change the IF statement to:

IF FormName1 = .F.

Dave Dardinger

RE: Forms as Classes (Easy Question, I suspect...)

Hi Dave..
Sorry.. I am not picky on this issue..
But I feel much more easy and comfortable to put the code

CREATE FORM myForm AS myFormClass FROM MyClassLib

and save the form in my forms directory. Add it to project.
This is surely easy, since the formclass name and the class name are all infront of you in the projects window.

If you have only one Base Form Class, you can set it as default option and when you add a form, it is opened in that class.


ramani
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK

RE: Forms as Classes (Easy Question, I suspect...)

Sure, that will work pretty well but it requires you to have memorized all the requisite syntax.  I always end up having to look it up.  Plus I've always got 6 things in front of my project window and then you have to look and see which library the form you want is in if you use more than one library.  Besides, I *said* it was a kludge.  It'd be nicer to just be able to pick the kind of form you want off a toolbar.  

Hmm...  Come to think about it, you could make a custom toolbar to do it, I believe.  Maybe I'll try it and see if it works.  

Dave Dardinger

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close