Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Methods and propertys from the class to a form.
Message
From
09/08/1999 22:26:06
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00251407
Message ID:
00251855
Views:
9
>For an especial requirements of my client, I need to create again a form without using his corresponding classes, (I know that it sound without sense..., I hate to do it). Anyone know a method more sophisticated than copy and paste...
>Thanks and greetings



Oh... That's you need to copy all the defined class properties and procedure coding to the Form Objects
instance. For example, you have a simply textbox class named: TxtUpper which have a code:
* TxtUpper.KeyPress()
lParameters nKeyCode, nShiftCtrlAlt
Do case
case Between(nKeyCode, 97, 122)
    NoDefault
    DoDefault(nKeyCode-32)  && Change to Upper Case 
EndCase
If there is 10 textbox in Form which use this class, you now need to change it to Normal Textbox with
copy the above coding at the KeyPress() event! +_+




Generally, You can copy them IFF there is No Extra New Properties/Procedure in that
Class...
i.e. If the class is a incremental search textbox(d/l in File Section) which has Extra properties on Search Tag,
Search Table...., Then You can't make it work by simply copy the coding into Corresponding Textbox.

Because All the New Properties/Procedure will add at the TOP level of Class/Form...
if there are more that one searching textbox... you need to add a different name on Top Form and
change the coding to make it work.... Otherwise, UnExpected Misuse on Common Variables...
(The most Poor point on Global Public Variable in Std structural programming!!)
It will totally AGAINST OOP propose and surely Hard to Maintain!!



Actually there is a quick But Not sure method to copy the coding from vcx class to form....
Please Make Backup before try this!!

According to my hacking level to VCX (Class) and SCX (Form), you can copy the coding to form instance
by coding.

Use MyLib.vcx && Open the Class
Locate for [txtUpper]$Objname && find the class...
Scatter Memvar && ;p My laziest method on Copy data!

Use MyForm.scx In 0 && Open the Form
Select MyForm
Set Filter to [txtUpper]$Class and [mylib.vcx]$Classloc && filter the needed class instance only!
* Copy the Method to Form IF the Instance HAS NO methods coding!!
Replace All Class With "textbox" For Empty(Methods) && Return Back to Standard class
Blank Fields ClassLoc For Empty(Methods) && Empty the Classloc as Standard
* After cleaning the class information, You can fill in the Methods Coding!!!!
Replace All Methods With Methods For Empty(Methods)
Use in MyForm
Use in MyLib




You may ask: Why I can't Copy the Properties, such as font size, font name etc..
But there is a Name in Properties memo.
You can't overwrite them directly!!

Maybe I am poor in handling memo coding especially to add what needed...

In here, I ask anyone know how to AddOrSkip the memo field..
For example,

SCX properties field has:
fontbold=.T.
name="txtUpperKeyField"
...

VCX properties field has:
name="txtUpper"
fontname="Arial"
fontsize=11
fontbold=.F.

and the Final Result will be Added or Skipped line by line EVEN in different ORDER:

fontbold=.T.
name="txtUpperKeyField"
fontname="Arial"
fontsize=11

but afterwards, you need to Re-Compile the form because the objcode is compiled binary code!

According to my Past experience on hacking vcx/scx, nearly fail to add/remove some methods coding
if the methods memo is NOT empty!
After I re-open the form, the coding will go wrong place and make it wrong!!
So, you really need to copy those Methods to the instances which has some extra code on them!

Anyway, the suggested action IS NOT a normal way to do, you need to take risk!!
Remember to Make enough Backup!!

p.s. The suggested coding may have error, you're better to add some Browse command to trace it!

Good Luck Anyway!! In my conclusion, you boss request IS a joking @!#^%@#
IT WASTE SO MUCH OF YOUR TIME but gain none effect/construction!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Reply
Map
View

Click here to load this message in the networking platform