How to override DATA in the FW class?

How to override DATA in the FW class?

Postby dutch » Tue Sep 15, 2009 9: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 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to override DATA in the FW class?

Postby ukoenig » 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 :lol:
Last edited by ukoenig on Tue Sep 15, 2009 10:58 pm, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to override DATA in the FW class?

Postby Adolfo » 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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: How to override DATA in the FW class?

Postby Marcelo Via Giglio » Wed Sep 16, 2009 2:13 am

Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: How to override DATA in the FW class?

Postby StefanHaupt » Wed Sep 16, 2009 8:09 am

Adolfo,

you can try to replace the New() method

Code: Select all  Expand view
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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: How to override DATA in the FW class?

Postby dutch » Wed Sep 16, 2009 3: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 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to override DATA in the FW class?

Postby Antonio Linares » Thu Sep 17, 2009 3:47 am

Adolfo,

You can do it this way:
Code: Select all  Expand view

   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
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to override DATA in the FW class?

Postby Antonio Linares » Thu Sep 17, 2009 4:32 am

Dutch,

Here you have a working example:
Code: Select all  Expand view

#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  
 

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to override DATA in the FW class?

Postby StefanHaupt » Thu Sep 17, 2009 7: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: How to override DATA in the FW class?

Postby Otto » Thu Sep 17, 2009 8:09 am

Antonio,
could you please post the values for:
HB_OO_MSG_CLSACCESS, uVal, HB_OO_CLSTP_EXPORTED
Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to override DATA in the FW class?

Postby StefanHaupt » Thu Sep 17, 2009 8: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: How to override DATA in the FW class?

Postby Antonio Linares » Thu Sep 17, 2009 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to override DATA in the FW class?

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to override DATA in the FW class?

Postby Adolfo » Thu Sep 17, 2009 12:45 pm

Antonio Linares wrote:Adolfo,

You can do it this way:
Code: Select all  Expand view

   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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 104 guests