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

Switch form from Read Only to Edit 3

Status
Not open for further replies.

k2a

Programmer
Jun 26, 2012
133
DE
Hi to all,
I want to prevent accidental changing data in a form. Command buttons should only allow changing the data on the form.

Just tried to do this by mean of ThisForm.SetAll("Readonly",.F.,"TextBox") and ThisForm.SetAll("Readonly",.T.,"TextBox") but for some reason this does not work.

I would be glad for any assistance.

Regards,
Klaus
 
One possibility that comes to mind is that your textboxes are subclasses of the native VFP textbox. If that's the case, you need to pass the name of the subclass as the third parameter to SetAll, rather than "Textbox".

Off-hand, I can't think of any other explanation - unless there's something you haven't told us.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Dave, that's not true. Setall works recursing through all layers of a form, also pages of pageframes, containers, inner grid controls, everything.
Also, the third parameter is optional, you can simply say Thisform.SetAll("ReadOnly",.T.)

Bye, Olaf.
 

Hi Mike,
You are right, I used the name from the ParentClass field instead of the subclass. After changing that and then it worked.

Unfortunately, those form was created in earlier days using the form wizard and all textboxes became names like embossedfield, but in the meantime I have my own classes.
Is there a way to change the underlying form’s textbox classes to my classes without redesign the whole form?
What must be done to force the form wizard to use my classes and not the standard classes?

Regards,
Klaus
 
Is there a way to change the underlying form’s textbox classes to my classes without redesign the whole form?

Your forms are SCX and SCT files, which are just DBF and FPT files in drag. You can USE yourform.scx like any dbf and edit it directly. In this case, find the textbox records and change the CLASS and CLASSLOC fields. Work carefully, and only on backup copies. You can ruin your existing forms.

If it's something you need to do a lot, you can create a builder pretty easily that will do this for you on call. Over the years (decades now), much has been written about writing tools such as builders in VFP. Google can probably find a LOT for you to start with.

What must be done to force the form wizard to use my classes and not the standard classes?
The source code for the wizards ships with VFP so in theory you can make them dance and whistle "Dixie" if that's what you want. BUT... the wizards have never been the best way to work with VFP so your effort would probably be better spent finding other ways to work with the product.
 
Dan is right about the wizards. I just want to point out there is the "Field Mapping" tab of the options dialog (Menu:Tools->Options). This is not about the wizards, but about what control you get in a form when using drag&drop from dataenvironment to a form. The wizards use classes you find in Home()+"Wizards", all of that is "open source".

Bye, Olaf.
 
Klaus said:
Is there a way to change the underlying form’s textbox classes to my classes without redesign the whole form?

I use a tool called HackCX, from White Light Computing. As Dan says, you can do the job by hacking the SCX and VCX files yourself, but this tool does it for you in a safe and controlled way. It's not free, but if you do a lot of VFP programming, it will pay for itself many times over. See
Mike






__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thank you Mike, Dan and Olaf for your great help and very useful advices.
This forum is really amazing and deserves my sponsorship.

Regards
Klaus

 
Thank you Mike, Dan and Olaf for your great help and very useful advices.
This forum is really amazing and deserves my sponsorship.

Regards
Klaus

 
In the book 1001 things you always wanted to know about visual foxpro written by Marcia Akins, Andy Kramek and Rick Schummer and publiced in 2000 there is in chapter 12 a (working) tool-example of how to change classes.

Marcia sometimes hangs around here in the forum too; maybe she will give you the code if you don't own the book.

-Bart
 
In addition to the various suggestions provided here for changing control classes, there's also a terrific tool in Thor to do this. It only does one control at a time, but you can do while in the Designer.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top