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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change style of created form 3

Status
Not open for further replies.

Polly66

Programmer
Nov 3, 2001
42
AU
Hi,

I am using VFP9. Does anyone know if it is possible to change the style of forms after they are created, (or even before without using a data file in the builder). The option for [ok] is not available to me unless I allow the builder to select the data file for me. I have created an application using standard backgrounds, and now would like to "pretty" things up a bit, but somehow think that I am going to be dissapointed.

Thanks if anyone can advise.

Bill

 
If you used the Wizards class to create the form you will have some work to do.

You will have to create a form class, make it how you want the background etc to be, and base your forms off of this class. It is somewhat complex to think about, but not difficult to implement at all.

Once you create a form with the look you want, save it as a class (File Menu, Save As Class). Then every form you create will look this way. But best of all, if you change your mind, you just need to change/update the class form and every form will automatically inherit the look.

You can change a current form's class to your new class once you are happy with the look and feel.

Is that something you understand or do we need to explain it further. I know how hard it is to grasp this concept, and so do others here. Once you get "over the hump" it will flow nicely.

Let us know.


Don Higgins
 

Bill,

No, you won't be disappointed. VFP is capable of doing what you want.

If you using the form builder, you should follow Don's advice of creating a form class. This should include whatever buttons and other controls you want, plus all the needed cosmetic settings like background colour and the like.

When you want to create a new form, go to the command window and type:

CREATE FORM MyForm AS MyFormClass FROM MyLibrary

where MyFormClass is the form class created as above, and MyLibrary is the VCX files where it is stored.

You will now be in the form designer, and you should see a form that resembles your form class. You can now go ahead and use the form builder just as before.

If you later want to change any of the cosmetics, just go back to the class designer and change the form class. Any changes you make will be inherited by all forms based on that class.

Note that you will not be able to delete any of the class-based controls for a specific form. For example, if the class contains an OK button, that button will appear on all forms based on the class, and you won't be able to delete it (but you can make it invisible).

Hope this helps.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thank you Don and Mike. That helped, and by bodgying the builder (adding a data environment - then removing it) I think I am able to achieve what I need.

But is there a way to change the background of a form, say to slate, and maybe adding shadows to boxes without initially adding a file as data environment. The option to "OK" is inactive until I add a file.

Thanks again.

Bill
 
You can change the background of a form in two ways in two places.

The easiest way is to set the Picture property of the form to an image but this image will be a fixed size and will tile itself across the form. The nicer way is to put an Image control on the form and set the Picture property to the image that you want. The Picture control has a Stretch property. If you set this to 2-Stretch then the image will be stretched to fill the size of the control.

There are two places where you can do this. If you make either of these changes to the form itself then they will only apply to taht form. If you follow Mike's suggestion and use a form class then you can make the changes to the class and make all your forms look the same.

Geoff Franklin
 
Hi Geoff,

The second option is a pretty neat trick. I had already discovered the picture aspect in properties.

Thank you.

Bill
 

Hi Mike,

Thanks for your response. I think I have overcome the difficulties I had, but the problem initially was with the "Form Builder", which does not allow different attributes to shapes etc to be changed unless there is a data environment involved. Which means that you can only use the builder for this aspect on a form that has no file attached. I wasn't confused over these two separate issues. Thank you for your interest.

Bill
 

Bill,

I think I understand what you are saying. You are using the Style tab in the form builder, but you can't OK out of that until you have selected a table and some fields in the first tab. Is that right?

If you create a form class, along the lines I described in my earlier post, you don't use the Style tab. The colours and shapes defined by the class serve the same purpose.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

Hi Geoff, thanks for the second part of the "Neat Trick".

Mike, your earlier post, as with all your assistance you have given me in the past was correct and very informative. The explanation of creating a new class of form, based on the original provided by VFP was excellent, and I thank you for it. I was only trying to explain my difficulty with the builder and anvironment, as it seemed peculiar to me that shapes and styles of the form could not be used with the builder, unless there was a file attached. You have via this forum saved me many hours of investigative work over the past few months and I would like to give you a special thank you for your time and effort.

Bill
 

Bill,

I'm delighted that you have found my advice so useful, and I appreciate your kind words. Like you, I've also gained a lot from the information posted on this forum over the years.

Good luck with your form classes.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Bill - it's probably worth adding that you can actually add your own styles to the Wizard/Builder stuff. It's all table-driven. I've never done this and don't know how hard it is. I doubt there's much out there on the subject because very few people use the Form Builder.

If you really want to do it, I know that Steve Black explained how in his wonderful appendix on Wizards and Builders in my book, the Hacker's Guide to Visual FoxPro.

All that said, I recommend creating your own form classes and just using the Form/Class Designer rather than the Builder.

Tamar
 
Hi Tamar,

Thanks for your advice. It has been my experience in life that anything that comes easy, ain't really worth much. I am refering of course to wizards and builders, and although I recognise that they have their place in the world, sometimes they cause more problems than they solve. Thank you for your time and advice.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top