![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have two pairs of classes that are nearly identical. The problem is that the differences are where it is awkward. The differences (apart from comments saying how similar the classes are) are merely define class atgettext as textboxbf vs. define class atgetedit as textboxbf and define class textboxbf as textbox vs. define class editboxbf as editbox Any changes I make to one, I make to the other. Is there any way to have only one copy of the code? #include will not work as it specifically ignores VFP statements. That is too bad, as define class atgettext as textboxbf #include "atgetcode.h" enddefine define class atgetedit as editboxbf #include "atgetcode.h" enddefine define class textboxbf as textbox #include "bf.h" enddefine define class editboxbf as editbox #include "bf.h" enddefine would have been a very concise solution. Is there something I am overlooking, or am I stuck with maintaining two copies of the code? Sincerely, Gene Wirchenko Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. |
#3
| |||
| |||
|
|
I have two pairs of classes that are nearly identical. The problem is that the differences are where it is awkward. The differences (apart from comments saying how similar the classes are) are merely define class atgettext as textboxbf vs. define class atgetedit as textboxbf and define class textboxbf as textbox vs. define class editboxbf as editbox Any changes I make to one, I make to the other. Is there any way to have only one copy of the code? #include will not work as it specifically ignores VFP statements. That is too bad, as define class atgettext as textboxbf #include "atgetcode.h" enddefine define class atgetedit as editboxbf #include "atgetcode.h" enddefine define class textboxbf as textbox #include "bf.h" enddefine define class editboxbf as editbox #include "bf.h" enddefine would have been a very concise solution. Is there something I am overlooking, or am I stuck with maintaining two copies of the code? Sincerely, Gene Wirchenko Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. |
#4
| |||
| |||
|
|
if you use those classes *not* very often in your app, I'ld wrap them in a common container. |
|
But if those controls are your most often used GUI elements, this will lower form speed if you have many GUI controls. |
|
In that case the above mentioned bridge should be used, but I'ld add a twist: give each control the necessary properties (duplicating those should be easy) and keep the common code in as few classes as possible, instatiating them ONCE at the app level and call the methods with a reference of the calling object. In the control: = goApp.oBehaveTextboxbf.ColorMethod(this, lnNewColour) or = this.oBridgePointer.ColorMethod(this, lnNewColour) and in the behaviour object you can set ColorMethod(this, lnNewColour) lParameter toCtrl, tnCol toCtrl.DisabledBackColour = m.tnCol |
#5
| |||
| |||
|
|
I do not understand what you mean here about wrapping *classes* in a container. |
#6
| |||
| |||
|
|
I do not understand what you mean here about wrapping *classes* in a container. Just put them in the container. The container container class is common, branching out with the added controls into different subclasses. HTH |
#7
| |||
| |||
|
|
"Thomas Ganss" <TGanss_RemoveForRealAdress (AT) T-Online (DOT) de> wrote: I do not understand what you mean here about wrapping *classes* in a container. Just put them in the container. The container container class is common, branching out with the added controls into different subclasses. HTH It does not. It sounds as if you are confusing classes and objects. Please be more specific. Sincerely, Gene Wirchenko Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. |
#8
| |||
| |||
|
|
not tested, but you should get the idea... Define Class AtGetStr as Container Function init() if pemstat(this, oInputCtrl, 5) = bindevent(oInputCtrl, "GotFocus", this, "GotFocusDelegate") else wait wind "Don't instantiate abstact classes" return .f. endif EndFunc Procedure GotFocusDelegate() this.oInputCtrl.BackColor = RGB(0,255,0) EndProc EndDefine Define class atgettext as AtGetStr Add Object oInputCtrl as TextBoxF EnDefine Define class atgettext as AtGetEdit Add Object oInputCtrl as EditBoxF EnDefine "Gene Wirchenko" <genew (AT) mail (DOT) ocis.net> schrieb im Newsbeitrag news:gcm0g0pi3al09b9ei879cboqfgvcb18vgv (AT) 4ax (DOT) com... "Thomas Ganss" <TGanss_RemoveForRealAdress (AT) T-Online (DOT) de> wrote: I do not understand what you mean here about wrapping *classes* in a container. Just put them in the container. The container container class is common, branching out with the added controls into different subclasses. HTH It does not. It sounds as if you are confusing classes and objects. Please be more specific. Sincerely, Gene Wirchenko Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. |
![]() |
| Thread Tools | |
| Display Modes | |
| |