Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Boudewijn Lutgerink
  Where is Boudewijn Lutgerink?
 Hoonaardstraat, Driel
 Boudewijn Lutgerink
 To: Darren Ward
  Where is Darren Ward?
 United Kingdom
 Darren Ward
Subject: RE: A question of class
Thread ID: 92974 Message ID: 93332 # Views: 31 # Ratings: 1
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Saturday, April 15, 2006 8:04:49 AM         

>... Apart from managing my common controls are there any other real benefits that I would see from going through this process baring in mind that I would need to go through all the forms and make a list of 'quailfying' controls.
> Darrem

In addition to what Ken has already said.
In your particular case I think you might consider using the builder technology from VFP.

Once you have this list of controls you need to replace and you have your classes developed you can use this technology very well.
Let me share something I recently did.
I was creating an app that should be able to display both Double Byte character sets (Chinese, Japanese Hindi...) as well as Single Byte Char Sets
(English, Dutch etc...)
For that I use the microsoft forms controls, these are able to display the DBCS (as well as the SBCS of course)
The point with these activeX controls is that they do not automatically adjust in size.
What I mean with this is if you drag a field from the DE of a form on the form, the textbox resizes itself automatically.
ActiveX controls do not do that. So I needed a workaround.

I created a builder.
The functionality of that builder is to replace one type of control with another and give it exactly the same size, and set some more properties.
All this without an interface that would "bother" the user.

In your case the same could work as well.

The builder code itself is very simple, I needed 30 lines of code for that:

* although the parameter statement is not used here 
* The builder tech seems to need it.

Local laControls[1] as Object

Local loCntr as Object, lcname as String, lcNewname as String, lofrm as Object

IF ASELOBJ(laControls)>0
	FOR lni = 1 TO ALEN( laControls,1)
		IF UPPER(laControls[lni].class) == "BL_TEXT"
		* replace the above classname with the name of your own class.
		loCntr = lacontrols[lni]
         	lcname = loCntr.name
         	lcNewname = "_"+lcName
         	WITH locntr.Parent
	    	* same here, you need to replace this with your own classes.
			* set the properties here.
			* You need to use your own properties here of course.
            		.&lcNewname..left = loCntr.Left
            		.&lcNewname..top = loCntr.top
            		.&lcNewname..width = loCntr.width+4
            		.&lcNewname..height = loCntr.height+2
            		.&lcNewname..controlsource = loCntr.controlsource
         	lofrm = loCntr.Parent
         	lofrm.RemoveObject( loCntr.Name)
         	lofrm.&lcNewname..name = lcname

As you see, very simple and basic.
Now you need to register this builder.
Open the builder.dbf that can be found in the wizard folder under the home() folder of VFP.
add (at least) two records to that table.
In both cases the name is the description of the builder as shown in a dialog that will follow in this msg.
In line one add the name of the class that is selected once you invoke the builder, do that in the "Type" field.
In the "Program" fierld add the name of you application.

In the second line fill in the same stuff, with the exception that the type should contain "MULTISELECT".
That way you can select more than one control at the time rightclick then, select your builder (VFP has its own builder that does use this, so you get a choice)

(Here you see the description I spoke about earlier, so do not leave that empty)

now select the builder you need (BL textboxbuilder in this particular case) and voila, the controls are replaced.

No sweat, No thread, no pain, only gain...

You could use a table (of course) to put your list in AND the classes that should replace them, and ajust the code accordingly to use this table.
You MIGHT consider to use the readmethod() and writemethod() methods of the controls to automatically place written code of one control in the other (if not included in your classes that is.)

The other thing is, once you have your classes ready you might want to use them in the future as well.
As far as it goes for controls you can use the fieldmapping in VFP.
Go to tools->options, and select the fieldmapping tab.
Select there the field TYPE you want to use a particular class and next time you drop a field of that type on the form it will use the appropriate class.


Boudewijn LutgeĀ®ink
My Blog is here


A question of class Posted by Darren Ward @ 4/10/2006 6:19:23 PM
RE: A question of class Posted by Ken Murphy @ 4/10/2006 7:06:28 PM
RE: A question of class Posted by Darren Ward @ 4/13/2006 11:19:22 AM
RE: A question of class Posted by Jamie Osborn @ 4/11/2006 2:34:32 AM
RE: A question of class Posted by Boudewijn Lutgerink @ 4/15/2006 8:04:49 AM
RE: A question of class Posted by Ken Murphy @ 4/16/2006 12:33:22 AM
RE: A question of class Posted by Boudewijn Lutgerink @ 4/17/2006 12:33:47 AM