FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to override DATA in the FW class?
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
How to override DATA in the FW class?
Posted: Tue Sep 15, 2009 09:12 PM

Dear All,

I would like to change DATA in TGET classes. I don't need to change original FIVEHX.LIB, because I don't want to worry about FW upgrade version.

::lTransparent := .T. // for default transparent say

Regards,
Dutch

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to override DATA in the FW class?
Posted: Tue Sep 15, 2009 10:02 PM
Hello Dutch,

Use the prg-file of the class, You want to change something.
Include the modified Prg ( Class ) in You Link RMK-File.
The included Prg will replace the Prg from the Lib.
Using the original Lib again, delete the file from the RMK.

Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: How to override DATA in the FW class?
Posted: Tue Sep 15, 2009 10:09 PM

Would be nice to know how to do it without cahnging the Libs, or adding modified prgs..

For instance to change CLASSDATA lClrFocus in Tget Class

From Chile
Adolfo

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: How to override DATA in the FW class?
Posted: Wed Sep 16, 2009 02:13 AM
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: How to override DATA in the FW class?
Posted: Wed Sep 16, 2009 08:09 AM
Adolfo,

you can try to replace the New() method

Code (fw): Select all Collapse
OVERRIDE METHOD New IN CLASS TGET WITH MyNew

STATIC FUNCTION MyNew

LOCAL Self := HB_QSelf()

  <your code>

RETURN (Self)


and write your own method, where you can set all default parameters you want.
kind regards

Stefan
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How to override DATA in the FW class?
Posted: Wed Sep 16, 2009 03:14 PM

Dear Stefan,

I can override class now but the case that I mention is override CLASSDATA in the CLASS as first Post Example. Because I need only change one DATA. If Override Method, It means to maintain this override class and every version.

Regards,
Dutch

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to override DATA in the FW class?
Posted: Thu Sep 17, 2009 03:47 AM
Adolfo,

You can do it this way:
Code (fw): Select all Collapse
   TGet():SetColorFocus( nRGB( 200, 120, 120 ) )

Please notice that we don't really create a GET control, as we don't call New() or Redefine() methods
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to override DATA in the FW class?
Posted: Thu Sep 17, 2009 04:32 AM
Dutch,

Here you have a working example:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oDlg

   // Just call it ONCE in your application!
   AddClassData( TSay(), "lTransparent", .T. ) // .T. -> initial value

   DEFINE DIALOG oDlg TITLE "Test" COLOR "W/B"

   @ 1, 2 SAY "Hello" COLOR "R/BG+"

   @ 2, 2 SAY "World!" COLOR "R/GR+"

   ACTIVATE DIALOG oDlg CENTERED

return nil

function AddClassData( oObj, cClsData, uVal )

   local hClass := oObj:ClassH

   __clsAddMsg( hClass, cClsData, __CLS_CNTCLSDATA( hClass ) + 1,;
                HB_OO_MSG_CLSACCESS, uVal, HB_OO_CLSTP_EXPORTED )   

   __clsAddMsg( hClass, "_" + cClsData, __CLS_CNTCLSDATA( hClass ) + 1,;
                HB_OO_MSG_CLSASSIGN,, HB_OO_CLSTP_EXPORTED )   
                
return nil

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: How to override DATA in the FW class?
Posted: Thu Sep 17, 2009 07:43 AM
Dutch,

dutch wrote:
I can override class now but the case that I mention is override CLASSDATA in the CLASS as first Post Example. Because I need only change one DATA. If Override Method, It means to maintain this override class and every version.

Regards,
Dutch


If you override a method this is valid for your application, you can copy and paste the original method and only change the data you need. Antonio´s solution is more simple and flexible, but it is also valid for every call of this class in your application.

If you need to change the DATA only in certain situations, you have to create a new class that inherits from the original one.
kind regards

Stefan
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: How to override DATA in the FW class?
Posted: Thu Sep 17, 2009 08:09 AM

Antonio,
could you please post the values for:
HB_OO_MSG_CLSACCESS, uVal, HB_OO_CLSTP_EXPORTED
Thanks in advance
Otto

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: How to override DATA in the FW class?
Posted: Thu Sep 17, 2009 08:19 AM

Otto,

in hboo.ch the value is defined

define HB_OO_CLSTP_EXPORTED 1 / No comment, default /

But I don´t find HB_OO_MSG_CLSACCESS, maybe it´s only in the last version of xHarbour

kind regards

Stefan
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to override DATA in the FW class?
Posted: Thu Sep 17, 2009 08:47 AM

Stefan,

It is a Harbour value, if does not exist in xharbour.
Maybe there is an equivalent value in xHarbour, I have not checked it.

You can review the source code of rtl\TClass.prg to see the way that the Harbour Classes engine adds new ClassDatas.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to override DATA in the FW class?
Posted: Thu Sep 17, 2009 10:35 AM

I want to clearify that I fully agree with Stefan that the right way is to inherit a new Class and modify it properly.

The published function is just an easy and quick way to test it, for Dutch requirement. That code may change and may not work in the future, etc. as it is highly based on Harbour internals.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: How to override DATA in the FW class?
Posted: Thu Sep 17, 2009 12:45 PM
Antonio Linares wrote:Adolfo,

You can do it this way:
Code (fw): Select all Collapse
   TGet():SetColorFocus( nRGB( 200, 120, 120 ) )

Please notice that we don't really create a GET control, as we don't call New() or Redefine() methods



Antonio.
Works Great

Thanks
Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650

Continue the discussion