Inherit a class from another to add new methods for FW WIKI

Inherit a class from another to add new methods for FW WIKI

Postby Otto » Sat Oct 27, 2007 12:11 pm

(div. posts from the NG)
I am trying to inherit a class from another because I need to add a method.

I am getting an error that I don´t have if I use the original class.
The object seems not to be created at all...
The code is something like this:

Class CL2 from CL1
METHOD PrintCl()
ENDCLASS

METHOD PrintCl() class CL2
alert("CL2")
return NIL

Questions:
Al the CL1 methods are avaiable in CL2 ?
Do I need a constructor/destructor method or the CL1 one is used ?
--------------------------------------------------------------------------------

Don't forget to add:

CLASSDATA lRegistered AS LOGICAL
--------------------------------------------------------------------------------

Why ?
What is "lRegistered" ?


-It is a flag that allows a one-time registration of a control class. It is
needed to get Windows aware of the new control.

-Ok, but could you tell me when I need it and when I do not ?

-If you are creating a temporary stand alone class from scratch and you will
not inherit from it then it is not required

-If you plan on inheriting from your class or your class is inheriting from
another, then you will need to add it.

-And apparently you need it only sometimes when it is a control. For instance,
the DBCombo class inherits from the TCombobox class but doesn't have
lRegistered (and it works fine). Perhaps lRegistered should be added, but one
wonders why it works without it.

-Because you are inheriting from a standard Windows control and not creating a
new custom control.

-Thanks for clarifying that.


Then add your new class to a .ch file.
Example:
xTWbrowse inherits from tWbrose

#xcommand @ <nRow>, <nCol> XLISTBOX [ <oBrw> ] FIELDS [<Flds,...>] ;
[ ALIAS <cAlias> ] ;
[ <sizes:FIELDSIZES, SIZES, COLSIZES> <aColSizes,...> ] ;
[ <head:HEAD,HEADER,HEADERS,TITLE> <aHeaders,...> ] ;
[ SIZE <nWidth>, <nHeigth> ] ;
[ <dlg:OF,DIALOG> <oDlg> ] ;
[ SELECT <cField> FOR <uValue1> [ TO <uValue2> ] ] ;
[ ON CHANGE <uChange> ] ;
[ ON [ LEFT ] CLICK <uLClick> ] ;
[ ON [ LEFT ] DBLCLICK <uLDblClick> ] ;
[ ON RIGHT CLICK <uRClick> ] ;
[ FONT <oFont> ] ;
[ CURSOR <oCursor> ] ;
[ <color: COLOR, COLORS> <nClrFore> [,<nClrBack>] ] ;
[ MESSAGE <cMsg> ] ;
[ <update: UPDATE> ] ;
[ <pixel: PIXEL> ] ;
[ WHEN <uWhen> ] ;
[ <design: DESIGN> ] ;
[ VALID <uValid> ] ;
[ ACTION <uAction,...> ] ;
=> ;
[ <oBrw> := ] xTWBrowse():New( <nRow>, <nCol>, <nWidth>, <nHeigth>,;
[\{|| \{<Flds> \} \}], ;
[\{<aHeaders>\}], [\{<aColSizes>\}], ;
<oDlg>, <(cField)>, <uValue1>, <uValue2>,;
[<{uChange}>],;
[\{|nRow,nCol,nFlags|<uLDblClick>\}],;
[\{|nRow,nCol,nFlags|<uRClick>\}],;
<oFont>, <oCursor>, <nClrFore>, <nClrBack>, <cMsg>,;
<.update.>, <cAlias>, <.pixel.>, <{uWhen}>,;
<.design.>, <{uValid}>, <{uLClick}>,;
[\{<{uAction}>\}] )
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby James Bott » Sat Oct 27, 2007 8:44 pm

Otto,

>I am getting an error that I don´t have if I use the original class.
>The object seems not to be created at all...

The code looks OK. What is the error you are getting? Are you inheriting from an existing FWH class or one that you wrote? Have you read my OOP articles on my website?

I advise not naming your method PrintCl but rather just Print. Remember that one of the great features of OOP is that you can use the same method name in more than one class. This allows you to call the same method name without even knowing which object you are dealing with. Later you will see how valuable this feature is.

>All the CL1 methods are avaiable in CL2 ?

Yes.

>Do I need a constructor/destructor method or the CL1 one is used ?

The CL1 is used.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Otto » Sat Oct 27, 2007 8:53 pm

Sorry James,
I expressed my self wrong.
All is working. I though this could be transferred into the new Fivewin WIKI.
Regards,
Otto

Hua,

We are organizing a FiveTech wiki at:

www.fivetechsoft.com/wiki

Its empty by now. If someone wants to cooperate on its development, please request a login and password from us.
_________________
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 87 guests